diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index d28af17692cb..8a13194e6110 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -214,6 +214,9 @@ let shellDryRun = "${stdenv.shell} -n -O extglob"; tests = { + inputDerivationRequiredSystemFeatures = import ../tests/inputDerivationRequiredSystemFeatures.nix { + inherit lib stdenv; + }; succeedOnFailure = import ../tests/succeedOnFailure.nix { inherit stdenv; }; }; passthru.tests = lib.warn "Use `stdenv.tests` instead. `passthru` is a `mkDerivation` detail." stdenv.tests; diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 8ae991cb5366..2933cbf50463 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -882,6 +882,9 @@ let name = derivationArg.name or "inputDerivation"; # This always only has one output outputs = [ "out" ]; + # This doesn’t require any system features even if the original + # derivation did. + requiredSystemFeatures = [ ]; # Propagate the original builder and arguments, since we override # them and they might contain references to build inputs diff --git a/pkgs/stdenv/tests/inputDerivationRequiredSystemFeatures.nix b/pkgs/stdenv/tests/inputDerivationRequiredSystemFeatures.nix new file mode 100644 index 000000000000..487e55bf7f0b --- /dev/null +++ b/pkgs/stdenv/tests/inputDerivationRequiredSystemFeatures.nix @@ -0,0 +1,40 @@ +{ lib, stdenv }: +let + impossibleToBuildPackage = stdenv.mkDerivation { + name = "impossible-to-build-package"; + # According to the Nix manual, the "apple-virt" system feature is + # Darwin-only and the "kvm" system feature is Linux-only [1]. + # + # [1]: + requiredSystemFeatures = if stdenv.buildPlatform.isLinux then "apple-virt" else "kvm"; + + buildCommand = '' + echo ERROR: It’s supposed to be impossible to start building this package. >&2 + exit 1 + ''; + }; +in +stdenv.mkDerivation { + name = "stdenv-test-inputDerivationRequiredSystemFeatures"; + + impossibleToBuildPackageInputDerivation = impossibleToBuildPackage.inputDerivation; + buildCommand = '' + ln --symbolic "$impossibleToBuildPackageInputDerivation" "$out" + ''; + + meta = { + longDescription = '' + In previous versions of Nixpkgs, + `.inputDerivation.requiredSystemFeatures` would + always be the same as `.requiredSystemFeatures`. This + meant that if a builder wasn’t able to build `` due + to a lack of system features, then that builder would also not be able to + build `.inputDerivation`. + + That was an aribtrary (and probably accidental) limitation. Building + input derivations never requires any system features. This test checks to + make sure that that limitation no longer exists. + ''; + maintainers = [ lib.maintainers.jayman2000 ]; + }; +}