From a4ebccca57e8d50d0e94fa61672d6e2e2765b76a Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 24 May 2024 22:10:57 +0200 Subject: [PATCH] pkgsCross: prevent nested pkgsCross 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. --- pkgs/top-level/stage.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 3b3e4e1d5041259..fa71b51c4ad0fbd 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -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; }); @@ -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" {