From 41960fcdacbafa81ed5daf40d378b490fc5e81ca Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 17 Oct 2024 19:08:19 +0300 Subject: [PATCH 1/2] splice.nix: make `pkgs` `splicedPackages` when required MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will make `pkgs` used in `callPackage`, and `pkgsCross.X.pkgs` have packages with `__spliced`. https://www.github.com/NixOS/nixpkgs/blob/3029741718f4c765fbc5ebf76bea3d6c8ff15fe5/pkgs/development/interpreters/python/passthrufun.nix#L37 https://www.github.com/NixOS/nixpkgs/blob/d2bd9a39dec88eddd5c192abee69939e67f43d12/pkgs/top-level/python-packages.nix#L10720 ``` nix-repl> pkgsCross.aarch64-multiplatform.python3Packages.protobuf4.protobuf.__spliced error: … while evaluating the attribute 'aarch64-multiplatform.python3Packages.protobuf4.protobuf.__spliced' at /home/artturin/nixgits/my-nixpkgs/.worktree/1/pkgs/development/python-modules/protobuf/4.nix:119:13: 118| passthru = { 119| inherit protobuf; | ^ 120| }; error: attribute '__spliced' missing at «string»:1:1: 1| pkgsCross.aarch64-multiplatform.python3Packages.protobuf4.protobuf.__spliced | ^ ``` to ``` nix-repl> pkgsCross.aarch64-multiplatform.python3Packages.protobuf4.protobuf.__spliced { buildBuild = «derivation /nix/store/s7da5mfvx4h1n86j78knaj9cprglxqz6-protobuf-25.4.drv»; buildHost = «derivation /nix/store/s7da5mfvx4h1n86j78knaj9cprglxqz6-protobuf-25.4.drv»; buildTarget = «repeated»; hostHost = «derivation /nix/store/mszvybzs4zxh43awyrjnybsfcb265n9r-protobuf-aarch64-unknown-linux-gnu-25.4.drv»; hostTarget = «repeated»; } ``` --- pkgs/top-level/splice.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix index 3b600c22f60e..e9e1ba02bf81 100644 --- a/pkgs/top-level/splice.nix +++ b/pkgs/top-level/splice.nix @@ -151,6 +151,8 @@ in newScope = extra: lib.callPackageWith (pkgsForCall // extra); + pkgs = if actuallySplice then splicedPackages // { recurseForDerivations = false; } else pkgs; + # prefill 2 fields of the function for convenience makeScopeWithSplicing = lib.makeScopeWithSplicing splicePackages pkgs.newScope; makeScopeWithSplicing' = lib.makeScopeWithSplicing' { inherit splicePackages; inherit (pkgs) newScope; }; From a27e48e1b24504bc134ba05640c5663c7af0fd80 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 1 Nov 2024 20:21:38 +0200 Subject: [PATCH 2/2] treewide: remove `= __splicedPackages` Now that `pkgs` is `__splicedPackages` on cross we can remove these variables I set. Assignments like `patchutils = pkgs.patchutils_0_3_3;` in `all-packages.nix` cannot be removed because the `pkgs` in `patchutils = pkgs.patchutils_0_3_3;` in `all-packages.nix` is coming from this `pkgs:` https://www.github.com/NixOS/nixpkgs/blob/b6e486730fc875ec79a3dea0f1f46eaf9f6ffa9d/pkgs/top-level/all-packages.nix#L9 instead of the `pkgs` in `with pkgs;` --- pkgs/development/beam-modules/default.nix | 3 +-- pkgs/development/beam-modules/lib.nix | 5 +---- pkgs/development/interpreters/perl/default.nix | 6 +----- pkgs/top-level/all-packages.nix | 10 +++------- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/pkgs/development/beam-modules/default.nix b/pkgs/development/beam-modules/default.nix index 23649ca76f26..b5a4188a0b2a 100644 --- a/pkgs/development/beam-modules/default.nix +++ b/pkgs/development/beam-modules/default.nix @@ -1,7 +1,6 @@ -{ lib, __splicedPackages, erlang }: +{ lib, pkgs, erlang }: let - pkgs = __splicedPackages; inherit (lib) makeExtensible; lib' = pkgs.callPackage ./lib.nix { }; diff --git a/pkgs/development/beam-modules/lib.nix b/pkgs/development/beam-modules/lib.nix index 2d93b28cda6b..1b021cf93472 100644 --- a/pkgs/development/beam-modules/lib.nix +++ b/pkgs/development/beam-modules/lib.nix @@ -1,8 +1,5 @@ -{ __splicedPackages, lib }: +{ pkgs, lib }: -let - pkgs = __splicedPackages; -in rec { /* Similar to callPackageWith/callPackage, but without makeOverridable diff --git a/pkgs/development/interpreters/perl/default.nix b/pkgs/development/interpreters/perl/default.nix index 8fd99172be10..1080f02f6e4d 100644 --- a/pkgs/development/interpreters/perl/default.nix +++ b/pkgs/development/interpreters/perl/default.nix @@ -19,11 +19,7 @@ let # - adds spliced package sets to the package set ({ stdenv, pkgs, perl, callPackage, makeScopeWithSplicing' }: let perlPackagesFun = callPackage ../../../top-level/perl-packages.nix { - # allow 'perlPackages.override { pkgs = pkgs // { imagemagick = imagemagickBig; }; }' like in python3Packages - # most perl packages aren't called with callPackage so it's not possible to override their arguments individually - # the conditional is because the // above won't be applied to __splicedPackages and hopefully no one is doing that when cross-compiling - pkgs = if stdenv.buildPlatform != stdenv.hostPlatform then pkgs.__splicedPackages else pkgs; - inherit stdenv; + inherit stdenv pkgs; perl = self; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 13d3da983e2f..41da7a024b2f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5577,9 +5577,7 @@ with pkgs; inherit (darwin.apple_sdk.frameworks) Security; }; - tmuxPlugins = recurseIntoAttrs (callPackage ../misc/tmux-plugins { - pkgs = pkgs.__splicedPackages; - }); + tmuxPlugins = recurseIntoAttrs (callPackage ../misc/tmux-plugins { }); tokei = callPackage ../development/tools/misc/tokei { inherit (darwin.apple_sdk.frameworks) Security; @@ -5944,7 +5942,7 @@ with pkgs; yarn-berry = callPackage ../development/tools/yarn-berry { }; - yarn2nix-moretea = callPackage ../development/tools/yarn2nix-moretea/yarn2nix { pkgs = pkgs.__splicedPackages; }; + yarn2nix-moretea = callPackage ../development/tools/yarn2nix-moretea/yarn2nix { }; inherit (yarn2nix-moretea) yarn2nix @@ -6653,7 +6651,6 @@ with pkgs; idrisPackages = dontRecurseIntoAttrs (callPackage ../development/idris-modules { idris-no-deps = haskellPackages.idris; - pkgs = pkgs.__splicedPackages; }); idris = idrisPackages.with-packages [ idrisPackages.base ] ; @@ -17353,8 +17350,7 @@ with pkgs; openmw-tes3mp = libsForQt5.callPackage ../games/openmw/tes3mp.nix { }; openraPackages_2019 = import ../games/openra_2019 { - inherit lib; - pkgs = pkgs.__splicedPackages; + inherit lib pkgs; }; openra_2019 = openraPackages_2019.engines.release;