diff options
author | zowoq <59103226+zowoq@users.noreply.github.com> | 2020-10-20 09:03:20 +1000 |
---|---|---|
committer | zowoq <59103226+zowoq@users.noreply.github.com> | 2020-10-28 09:06:55 +1000 |
commit | 092aa94ca729de84df9cb9a29406c854fa879024 (patch) | |
tree | 7ef6c8648a6ad847f25aee2fe4d393455290c562 /pkgs/development | |
parent | f08a5cc832809dd28ac95be1cf94db19c8f53ba6 (diff) |
buildGoModule: use optionalString
Diffstat (limited to 'pkgs/development')
-rw-r--r-- | pkgs/development/go-modules/generic/default.nix | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index 9efaa8608323..1549c83234a8 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -47,10 +47,6 @@ let removeExpr = refs: ''remove-references-to ${lib.concatMapStrings (ref: " -t ${ref}") refs}''; - deleteFlag = lib.boolToString deleteVendor; - - vendCommand = if runVend then "${vend}/bin/vend" else "false"; - go-modules = if vendorSha256 != null then go.stdenv.mkDerivation (let modArgs = { name = "${name}-go-modules"; @@ -81,27 +77,26 @@ let buildPhase = args.modBuildPhase or '' runHook preBuild - - if [ ${deleteFlag} == "true" ]; then - if [ ! -d vendor ]; then - echo "vendor folder does not exist, 'deleteVendor' is not needed" - exit 10 - else - rm -rf vendor - fi + '' + lib.optionalString (deleteVendor == true) '' + if [ ! -d vendor ]; then + echo "vendor folder does not exist, 'deleteVendor' is not needed" + exit 10 + else + rm -rf vendor fi - + '' + '' if [ -d vendor ]; then echo "vendor folder exists, please set 'vendorSha256 = null;' in your expression" exit 10 fi - if [ ${vendCommand} != "false" ]; then - echo running vend to rewrite vendor folder - ${vendCommand} - else - go mod vendor - fi + ${if runVend then '' + echo "running 'vend' to rewrite vendor folder" + ${vend}/bin/vend + '' else '' + go mod vendor + ''} + mkdir -p vendor runHook postBuild |