Skip to content

splice.nix: make pkgs splicedPackages#349316

Merged
Artturin merged 2 commits intoNixOS:masterfrom
Artturin:pkgsisspliced
Dec 6, 2024
Merged

splice.nix: make pkgs splicedPackages#349316
Artturin merged 2 commits intoNixOS:masterfrom
Artturin:pkgsisspliced

Conversation

@Artturin
Copy link
Member

@Artturin Artturin commented Oct 17, 2024

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»;
}

Will allow getting rid of many of these https://github.com/search?q=lang%3Anix+NOT+is%3Afork+%2Fpkgs.%2B__splicedPackages%2F&type=code
#251005 is required to get rid of all of them

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Oct 17, 2024
@Atemu
Copy link
Member

Atemu commented Oct 21, 2024

This sounds like an obvious win to me, is there anything left to test or verify?

@kjeremy
Copy link
Contributor

kjeremy commented Oct 23, 2024

Would #263082 have caught this? Maybe it would be worth reviving that.

@Aleksanaa
Copy link
Member

I got the feeling of this may be doable a couple of weeks ago. But now there are not many people who really dare to change the cross logic, come on 🫣

@Artturin Artturin marked this pull request as ready for review October 31, 2024 16:46
@nix-owners nix-owners bot requested a review from Ericson2314 October 31, 2024 16:47
@github-actions github-actions bot added the 6.topic: erlang General-purpose, concurrent, functional high-level programming language label Oct 31, 2024
@Artturin Artturin force-pushed the pkgsisspliced branch 2 times, most recently from 4bb1955 to 47c47cc Compare October 31, 2024 17:28
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ericson2314
I wonder why you didn't do this instead of adding __splicedPackages? f27f491

@ofborg ofborg bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Oct 31, 2024
@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 1, 2024
@nix-owners nix-owners bot requested a review from natsukium November 1, 2024 01:30
@Artturin Artturin force-pushed the pkgsisspliced branch 2 times, most recently from 01b7508 to 8614381 Compare November 1, 2024 01:43
@Artturin
Copy link
Member Author

Artturin commented Nov 1, 2024

Interesting, the fetchpatch changes in 8614381 cause infinite recursion https://gist.github.com/GrahamcOfBorg/784e668fe0b8a16a5bf11b5b622654cc

Because pkgs isn't __splicedPackages in all-packages.nix

diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index a14ffa88fd95..a0e8dead9df9 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -11,6 +11,7 @@ res: pkgs: super:
 with pkgs;
 
 {
+  pkgs1 = pkgs;
   # A module system style type tag
   #
   # Allows the nixpkgs fixpoint, usually known as `pkgs` to be distinguished
nix-repl> pkgsStatic.pkgs1.bash ? __spliced
false

Copy link
Member Author

@Artturin Artturin Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah #58327
If the pkgs used in all-packages.nix was __splicedPackages it would break with infinite recursion

nix-repl> pkgsStatic.pkgs1.bash ? __spliced
false

nix-repl> pkgsStatic.pkgs1.pkgs.bash ? __spliced
true

The pkgs in patchutils = pkgs.patchutils_0_3_3; in all-packages.nix is coming from this pkgs: https://github.com/NixOS/nixpkgs/blob/b6e486730fc875ec79a3dea0f1f46eaf9f6ffa9d/pkgs/top-level/all-packages.nix#L9
instead of the pkgs in with pkgs;

Copy link
Member

@lilyinstarlight lilyinstarlight Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've posted this patch a few times before, but it does still seem (when updated slightly (gccCrossStageStatic has a new attr name gccWithoutTargetLibc since that patch was written) and applied on top of this PR) to fix the infrec from inheriting from __splicedPackages: lilyinstarlight@9639e73

I didn't do rigorous testing, but it does result in the same .drvs for already-cross-safe attrs I tested

@github-actions github-actions bot removed the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 1, 2024
@Artturin Artturin force-pushed the pkgsisspliced branch 2 times, most recently from 259c3f0 to 96fb948 Compare November 5, 2024 15:45
@ofborg ofborg bot added the 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. label Nov 5, 2024
@ofborg ofborg bot removed the 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. label Nov 5, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 10, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/is-it-possible-for-us-to-remove-builtins-functionargs/51960/6

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»;
}
```
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;`
@Aleksanaa Aleksanaa added the 2.status: wait for branch‐off Waiting for the next Nixpkgs branch‐off label Nov 11, 2024
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 11, 2024
@roberth
Copy link
Member

roberth commented Nov 15, 2024

This seems like a massive improvement, at no apparent cost.

Would it be possible to do the same to the overlay fixpoint, final?
I believe that solution would then also have the same effect on the pkgs attribute.

Currently in this PR:

nix-repl> p.hello?__spliced
false

nix-repl> p.pkgs.hello?__spliced
true

@philiptaron
Copy link
Contributor

This has the label 2.status: wait for branch‐off -- and the branch cutoff has happened. Let's get this merged!

@Atemu
Copy link
Member

Atemu commented Dec 6, 2024

Is there anything left to test or think more closely about? Otherwise I'd be in favour of merging and seeing whether anything breaks.

@Artturin
Copy link
Member Author

Artturin commented Dec 6, 2024

I want to get #341067 evalling first and then apply #341067 and 6761b8e (#341067) here to see the actual perf diff

@Artturin Artturin marked this pull request as draft December 6, 2024 16:47
@Artturin
Copy link
Member Author

Artturin commented Dec 6, 2024

I was thinking of a different PR, there's no perf diff here :P I have 3 PRs touching splice.nix so got confused.

@Artturin Artturin marked this pull request as ready for review December 6, 2024 16:47
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look great -- and if they eval, let's merge.

@Artturin Artturin merged commit debf997 into NixOS:master Dec 6, 2024
@Artturin Artturin deleted the pkgsisspliced branch December 6, 2024 16:49
@Artturin
Copy link
Member Author

Artturin commented Dec 6, 2024

Weird seems like the github actions eval got inf rec https://github.com/NixOS/nixpkgs/actions/runs/12202727756/job/34044092263 and this PR didn't yet use github actions eval #362499 (comment)

@Artturin
Copy link
Member Author

Artturin commented Dec 6, 2024

Take 2 #362499

@wolfgangwalther
Copy link
Contributor

I'm working on this again in #456138.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: wait for branch‐off Waiting for the next Nixpkgs branch‐off 6.topic: erlang General-purpose, concurrent, functional high-level programming language 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants