mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
stdenv: make inputDerivation never require system features
This change removes a limitation with inputDerivations. See stdenv.tests.inputDerivationRequiredSystemFeatures.meta.longDescription for details. I had originally ran into this limitation when trying to write a test for pull request #319420. That pull request adds a setup hook that can only be used with derivations that have "uid-range" in their requiredSystemFeatures. I want to be able to build the inputDerivation for part of the test on systems that don’t have that system feature.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
40
pkgs/stdenv/tests/inputDerivationRequiredSystemFeatures.nix
Normal file
40
pkgs/stdenv/tests/inputDerivationRequiredSystemFeatures.nix
Normal file
@@ -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]: <https://nix.dev/manual/nix/2.32/command-ref/conf-file.html#conf-system-features>
|
||||
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,
|
||||
`<originalDerivation>.inputDerivation.requiredSystemFeatures` would
|
||||
always be the same as `<originalDerivation>.requiredSystemFeatures`. This
|
||||
meant that if a builder wasn’t able to build `<originalDerivation>` due
|
||||
to a lack of system features, then that builder would also not be able to
|
||||
build `<originalDerivation>.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 ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user