diff --git a/flake.nix b/flake.nix index f14a90efa..dbf5eb7d8 100644 --- a/flake.nix +++ b/flake.nix @@ -430,36 +430,9 @@ nixpkgsLibTests = forAllSystems ( system: - let + nixpkgsFor.${system}.native.callPackage ./tests/nixpkgs/lib.nix { + inherit nixpkgs system; inherit (self.packages.${system}) nix; - pkgs = nixpkgsFor.${system}.native; - testWithNix = - (import (nixpkgs + "/lib/tests/test-with-nix.nix") { - inherit pkgs lib nix; - }).overrideAttrs - (_: { - buildInputs = [ - (import (nixpkgs + "/lib/path/tests") { - inherit pkgs; - # NOTE: Override the nix version used here, we cannot rely on CppNix actually building - # c.f. https://github.com/NixOS/nixpkgs/blob/master/lib/path/tests/default.nix#L18 - nixVersions.stable = nix; - }) - ]; - }); - in - pkgs.symlinkJoin { - name = "nixpkgs-lib-tests"; - paths = [ - testWithNix - ] - # NOTE: nixpkgs 25.11 is being ... *creative*, and requires this dance to override - # the evaluator used for the test. it will break again in the future, don't worry. - ++ lib.optionals pkgs.stdenv.isLinux [ - ((pkgs.callPackage "${nixpkgs}/ci/eval" { inherit nix; } { }).attrpathsSuperset { - evalSystem = system; - }) - ]; } ); }; diff --git a/tests/nixpkgs/lib.nix b/tests/nixpkgs/lib.nix new file mode 100644 index 000000000..bd7604397 --- /dev/null +++ b/tests/nixpkgs/lib.nix @@ -0,0 +1,60 @@ +{ + lib, + stdenv, + symlinkJoin, + + pkgs, + + nix, + nixpkgs, + system, +}: + +# NOTE: Every endpoint used here is very fragile as nixpkgs is not built +# to test itself with anything other than CppNix. It will probably +# break during some nixpkgs bump. + +let + inherit (lib) concatStringsSep optionals; + + # Deprecated features to enable while running the nixpkgs test suite + deprecatedFeatures = [ ]; + + env.NIX_CONFIG = "extra-deprecated-features = ${concatStringsSep " " deprecatedFeatures}"; +in + +symlinkJoin { + name = "nixpkgs-lib-tests"; + paths = + map + ( + drv: + drv.overrideAttrs (old: { + env = (old.env or { }) // env; + }) + ) + ( + [ + ( + (import (nixpkgs + "/lib/tests/test-with-nix.nix") { + inherit pkgs lib nix; + }).overrideAttrs + (_: { + buildInputs = [ + (import (nixpkgs + "/lib/path/tests") { + inherit pkgs; + # NOTE: Override the nix version used here, we cannot rely on CppNix actually building + # c.f. https://github.com/NixOS/nixpkgs/blob/master/lib/path/tests/default.nix#L18 + nixVersions.stable = nix; + }) + ]; + }) + ) + ] + ++ optionals stdenv.isLinux [ + ((pkgs.callPackage (nixpkgs + "/ci/eval") { inherit nix; } { }).attrpathsSuperset { + evalSystem = system; + }) + ] + ); +}