diff --git a/doc/languages-frameworks/go.xml b/doc/languages-frameworks/go.xml
index bd1ee8eba275..53c891e66f87 100644
--- a/doc/languages-frameworks/go.xml
+++ b/doc/languages-frameworks/go.xml
@@ -66,6 +66,15 @@ pet = buildGoModule rec {
+
+
+ modSha256 can also take null 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.
+
diff --git a/pkgs/development/go-modules/generic/default.nix b/pkgs/development/go-modules/generic/default.nix
index b3c583da51e4..1bffb71e8f9d 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;