Skip to content

Commit

Permalink
pkgsCross: prevent nested pkgsCross
Browse files Browse the repository at this point in the history
Trying to evaluate pkgsXYZ.pkgsCross is conceptually unsound: pkgsCross
expects to reset crossSystem from scratch, because the whole point about
this layer is to start with "well known" example configurations. It's
fine to make modifications on top of that, though.

Thus, nested pkgsCross is now forbidden and will throw an evaluation
error.
  • Loading branch information
wolfgangwalther committed Sep 25, 2024
1 parent d1325cf commit a4ebccc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ let
# these will instantiate a new version of allPackages.
otherPackageSets = let
# helper function to call nixpkgsFun to make sure each package set
# references itself as a no-op.
# references itself as a no-op and to prevent nested pkgsCross.
# Nested pkgsCross doesn't make sense fundamentally, because it replaces
# the full crossSystem argument, thus starting "from scratch".
createPackageSet = name: { overlays ? [], ... }@args:
nixpkgsFun (args // {
overlays = [
(self: super: {
"${name}" = super;
pkgsCross = throw "Nested pkgsCross not allowed.";
})
] ++ overlays;
});
Expand Down Expand Up @@ -212,7 +215,14 @@ let
# will refer to the "hello" package built for the ARM6-based
# Raspberry Pi.
pkgsCross = lib.mapAttrs (n: crossSystem:
nixpkgsFun { inherit crossSystem; })
nixpkgsFun {
inherit crossSystem;
overlays = [
(self': super': {
pkgsCross = throw "Nested pkgsCross not allowed.";
})
];
})
lib.systems.examples;

pkgsLLVM = createPackageSet "pkgsLLVM" {
Expand Down

0 comments on commit a4ebccc

Please sign in to comment.