From d9ea49c898755348f154b434aead7e9316596d68 Mon Sep 17 00:00:00 2001 From: Martin Baillie Date: Tue, 13 Sep 2022 10:17:46 +1000 Subject: [PATCH 1/2] Parameterise `tools.go` Signed-off-by: Martin Baillie --- builder/default.nix | 5 +++-- docs/nix-reference.md | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builder/default.nix b/builder/default.nix index 42c95c7..9ae2845 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -161,6 +161,7 @@ let mkGoEnv = { pwd + , toolsGo ? pwd + "/tools.go" }@attrs: let goMod = parseGoMod (readFile "${toString pwd}/go.mod"); @@ -201,11 +202,11 @@ let export GOSUMDB=off export GOPROXY=off - '' + optionalString (pathExists (pwd + "/tools.go")) '' + '' + optionalString (pathExists toolsGo) '' mkdir source cp ${pwd + "/go.mod"} source/go.mod cp ${pwd + "/go.sum"} source/go.sum - cp ${pwd + "/tools.go"} source/tools.go + cp ${toolsGo} source/tools.go cd source rsync -a -K --ignore-errors ${vendorEnv}/ vendor diff --git a/docs/nix-reference.md b/docs/nix-reference.md index bb4317f..7e1a431 100644 --- a/docs/nix-reference.md +++ b/docs/nix-reference.md @@ -16,5 +16,6 @@ All other arguments are passed verbatim to `stdenv.mkDerivation`. ### mkGoEnv Arguments: - **pwd** Path to working directory. +- **toolsGo** Path to `tools.go` (_default: `pwd + "/tools.go"`). All other arguments are passed verbatim to `stdenv.mkDerivation`. From 29f6eb7bd57975b27a7ee1149aac3624b4e81b97 Mon Sep 17 00:00:00 2001 From: Martin Baillie Date: Mon, 26 Sep 2022 19:57:18 +1000 Subject: [PATCH 2/2] Parameterise modules file in mkGoEnv This makes `mkGoEnv` more similar to `buildGoApplication`. Signed-off-by: Martin Baillie --- builder/default.nix | 3 ++- docs/nix-reference.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builder/default.nix b/builder/default.nix index 9ae2845..f6df7d0 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -162,10 +162,11 @@ let mkGoEnv = { pwd , toolsGo ? pwd + "/tools.go" + , modules ? pwd + "/gomod2nix.toml" }@attrs: let goMod = parseGoMod (readFile "${toString pwd}/go.mod"); - modulesStruct = fromTOML (readFile "${toString pwd}/gomod2nix.toml"); + modulesStruct = fromTOML (readFile modules); go = selectGo attrs goMod; diff --git a/docs/nix-reference.md b/docs/nix-reference.md index 7e1a431..7dffabe 100644 --- a/docs/nix-reference.md +++ b/docs/nix-reference.md @@ -4,7 +4,7 @@ ### buildGoApplication Arguments: -- **modules** Path to gomod2nix.toml (_default: `pwd + "/gomod2nix.toml"`). +- **modules** Path to `gomod2nix.toml` (_default: `pwd + "/gomod2nix.toml"`). - **src** Path to sources (_default: `pwd`). - **pwd** Path to working directory (_default: `null`). - **go** The Go compiler to use (can be omitted). @@ -16,6 +16,7 @@ All other arguments are passed verbatim to `stdenv.mkDerivation`. ### mkGoEnv Arguments: - **pwd** Path to working directory. +- **modules** Path to `gomod2nix.toml` (_default: `pwd + "/gomod2nix.toml"`). - **toolsGo** Path to `tools.go` (_default: `pwd + "/tools.go"`). All other arguments are passed verbatim to `stdenv.mkDerivation`.