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.
This commit is contained in:
parent
596fa28448
commit
f373ecec8f
|
@ -66,6 +66,15 @@ pet = buildGoModule rec {
|
||||||
</callout>
|
</callout>
|
||||||
</calloutlist>
|
</calloutlist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<varname>modSha256</varname> can also take <varname>null</varname> as an input.
|
||||||
|
|
||||||
|
When `null` is used as a value, the derivation won't be a
|
||||||
|
fixed-output derivation but disable the build sandbox instead. This can be useful outside
|
||||||
|
of nixpkgs where re-generating the modSha256 on each mod.sum changes is cumbersome,
|
||||||
|
but will fail to build by Hydra, as builds with a disabled sandbox are discouraged.
|
||||||
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section xml:id="ssec-go-legacy">
|
<section xml:id="ssec-go-legacy">
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
, modRoot ? "./"
|
, modRoot ? "./"
|
||||||
|
|
||||||
# modSha256 is the sha256 of the vendored dependencies
|
# 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
|
, modSha256
|
||||||
|
|
||||||
# We want parallel builds by default
|
# We want parallel builds by default
|
||||||
|
@ -84,10 +88,16 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
outputHashMode = "recursive";
|
}; in modArgs // (
|
||||||
outputHashAlgo = "sha256";
|
if modSha256 == null then
|
||||||
outputHash = modSha256;
|
{ __noChroot = true; }
|
||||||
}; in modArgs // overrideModAttrs modArgs);
|
else
|
||||||
|
{
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHash = modSha256;
|
||||||
|
}
|
||||||
|
) // overrideModAttrs modArgs);
|
||||||
|
|
||||||
package = go.stdenv.mkDerivation (args // {
|
package = go.stdenv.mkDerivation (args // {
|
||||||
nativeBuildInputs = [ removeReferencesTo go ] ++ nativeBuildInputs;
|
nativeBuildInputs = [ removeReferencesTo go ] ++ nativeBuildInputs;
|
||||||
|
|
Loading…
Reference in New Issue