Skip to content

Commit

Permalink
Merge pull request nix-community#96 from martinbaillie/master
Browse files Browse the repository at this point in the history
Parameterise `tools.go`
  • Loading branch information
adisbladis authored Feb 27, 2023
2 parents 1f15df6 + 29f6eb7 commit 3cbf3a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ 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;

Expand Down Expand Up @@ -201,11 +203,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
Expand Down
4 changes: 3 additions & 1 deletion docs/nix-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -16,5 +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`.

0 comments on commit 3cbf3a5

Please sign in to comment.