Merge pull request #96 from martinbaillie/master

Parameterise `tools.go`
This commit is contained in:
adisbladis 2023-02-27 13:54:07 +13:00 committed by GitHub
commit 3cbf3a51fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -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;
@ -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

View file

@ -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,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`.