diff options
author | zimbatm <zimbatm@zimbatm.com> | 2019-12-28 20:36:42 +0000 |
---|---|---|
committer | Wael Nasreddine <wael.nasreddine@gmail.com> | 2019-12-28 12:36:42 -0800 |
commit | f373ecec8f49b24c3070ab4f66a680bee06980a5 (patch) | |
tree | 0d892fc2a010529511abd8b39cb666474a089f21 /pkgs/development/go-modules/generic | |
parent | 596fa2844824bd51653b0ca7ccd4d92dcefdfd0d (diff) | |
download | nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar.gz nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar.bz2 nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar.lz nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar.xz nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.tar.zst nixpkgs-f373ecec8f49b24c3070ab4f66a680bee06980a5.zip |
buildGoModule: support impure modules (#76532)
When modSha256 is null, disable the nix sandbox instead of using a fixed-output derivation. This requires the nix-daemon to have `sandbox = relaxed` set in their config to work properly. Because the output is (hopefully) deterministic based on the inputs, this should give a reproducible output. This is useful for development outside of nixpkgs where re-generating the modSha256 on each mod.sum changes is cumbersome. Don't use this in nixpkgs! This is why null is not the default value.
Diffstat (limited to 'pkgs/development/go-modules/generic')
-rw-r--r-- | pkgs/development/go-modules/generic/default.nix | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix index b3c583da51e..1bffb71e8f9 100644 --- a/pkgs/development/go-modules/generic/default.nix +++ b/pkgs/development/go-modules/generic/default.nix @@ -14,6 +14,10 @@ , modRoot ? "./" # modSha256 is the sha256 of the vendored dependencies +# +# CAUTION: if `null` is used as a value, the derivation won't be a +# fixed-output derivation but disable the build sandbox instead. Don't use +# this in nixpkgs as Hydra won't build those packages. , modSha256 # We want parallel builds by default @@ -84,10 +88,16 @@ let ''; dontFixup = true; - outputHashMode = "recursive"; - outputHashAlgo = "sha256"; - outputHash = modSha256; - }; in modArgs // overrideModAttrs modArgs); + }; in modArgs // ( + if modSha256 == null then + { __noChroot = true; } + else + { + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = modSha256; + } + ) // overrideModAttrs modArgs); package = go.stdenv.mkDerivation (args // { nativeBuildInputs = [ removeReferencesTo go ] ++ nativeBuildInputs; |