From 0793f856ce2a7f5b3256ba923e264b96ed01b4a3 Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 17 Oct 2024 19:08:19 +0300 Subject: [PATCH] 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 3b600c22f60e8..e9e1ba02bf816 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; };