Skip to content

top-level/all-packages: remove overwriting by-name callPackage#453948

Closed
wolfgangwalther wants to merge 15 commits intoNixOS:masterfrom
wolfgangwalther:by-name-explicit-defaults
Closed

top-level/all-packages: remove overwriting by-name callPackage#453948
wolfgangwalther wants to merge 15 commits intoNixOS:masterfrom
wolfgangwalther:by-name-explicit-defaults

Conversation

@wolfgangwalther
Copy link
Contributor

@wolfgangwalther wolfgangwalther commented Oct 20, 2025

In #444420, we changed the approach regarding the override interface for packages in by-name. This allows us to move a lot more packages to by-name - and also to get rid of callPackage in all-packages.nix for by-name packages.

This PR removes all cases where a by-name package was overwritten, aka with the same name. There are still plenty of callPackage into by-name folders in all-packages.nix, but these introduce new attributes.

This first step will allow us to disallow overwriting these by-name attributes and then simplify nixpkgs-vet accordingly.

Things done


Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: vscode A free and versatile code editor that supports almost every major programming language. labels Oct 20, 2025
@nix-owners nix-owners bot requested review from Profpatsch and natsukium October 20, 2025 18:45
Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

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

I would like to see the changes in “by-name/various: move default values to override interface”, “by-name/various: use scopes as arguments”, “aegisub: remove overrides from all-package.nix”, and “by-name/various: move overrides to package.nix” consistently move the overrides into a let … in … in package.nix rather than adjusting all the references in the files.

This will not always produce what I think is a superior end result, but in some cases it will, and it minimizes churn – both review and git blame – while making it easier to review for correctness. Since the packages were written this way to begin with, we should by default assume that the identifiers they chose are appropriate – and if we think we should remove that layer of indirection, that should be a separate refactoring change, distinct from this mechanical lifting.

Comment on lines -6 to +7
conf ? { },
config,
conf ? config.element-web.conf or { },
Copy link
Member

Choose a reason for hiding this comment

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

I don’t think we should be using config for this. (Not a blocker, because it was like that beforehand – but I’d like to drop this, as you did with config.aegisub. OTOH, conf is really not a great name for this anyway, so eh…)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem here is that conf is currently used from within nixpkgs, IIRC. So I can't drop it as easily. But I agree with you 100%.

Copy link
Contributor

Choose a reason for hiding this comment

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

Scrubbing most ad-hoc config. from pkgs is on my giant notebook of "changes-to-make".

@wolfgangwalther wolfgangwalther force-pushed the by-name-explicit-defaults branch from cbdfc0c to 136c599 Compare October 20, 2025 19:43
@wolfgangwalther
Copy link
Contributor Author

I would like to see the changes in “by-name/various: move default values to override interface”, “by-name/various: use scopes as arguments”, “aegisub: remove overrides from all-package.nix”, and “by-name/various: move overrides to package.nix” consistently move the overrides into a let … in … in package.nix rather than adjusting all the references in the files.

Will look into these things tomorrow, but I addressed all other feedback, so far.

@nixpkgs-ci nixpkgs-ci 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. and removed 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Oct 20, 2025
@wolfgangwalther wolfgangwalther force-pushed the by-name-explicit-defaults branch from 136c599 to 17d2489 Compare October 21, 2025 09:08
@wolfgangwalther
Copy link
Contributor Author

I would like to see the changes in “by-name/various: move default values to override interface”, “by-name/various: use scopes as arguments”, “aegisub: remove overrides from all-package.nix”, and “by-name/various: move overrides to package.nix” consistently move the overrides into a let … in … in package.nix rather than adjusting all the references in the files.

This will not always produce what I think is a superior end result, but in some cases it will, and it minimizes churn – both review and git blame – while making it easier to review for correctness. Since the packages were written this way to begin with, we should by default assume that the identifiers they chose are appropriate – and if we think we should remove that layer of indirection, that should be a separate refactoring change, distinct from this mechanical lifting.

Unfortunately, the addition of that let block is not easily automated with the ast-grep based scripts, I have.

I now addressed this feedback - in a compromise that is fair, I think. The majority of packages still uses the simple replacement, because they are really simple cases.

Everything that I felt was either more complex or where intent to do things differently in the expression was visible, uses the let pattern now.

There is one review comment open, but I just left that for visibility. I don't intend to do something about it in here.

From my perspective, this is ready.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 21, 2025
Overriding the argument with the same default value as in package.nix is
pointless.
The contributing guidelines have been changed to encourage breaking the
override interface to benefit from explicit conflict resolution on
upgrades.
Improves the override interface, because `withPython` does not conflict
with the old `python` package.
The config option was introduced in
9361acf, this should just be done via
overlays today.
wolfgangwalther and others added 4 commits October 21, 2025 21:24
This has the additional benefit, that the tests will run with
`finalPackage`, i.e. taking overrides into account.
fmt_11 is now the default.
@wolfgangwalther wolfgangwalther force-pushed the by-name-explicit-defaults branch from 17d2489 to 866eee1 Compare October 21, 2025 19:25
@wolfgangwalther
Copy link
Contributor Author

just rebased to resolve merge conflicts

@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 21, 2025
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

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

Diff LGTM, minus merge conflict

@nixpkgs-ci nixpkgs-ci bot added 2.status: merge conflict This PR has merge conflicts with the target branch 12.approvals: 1 This PR was reviewed and approved by one person. labels Oct 22, 2025
@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Oct 23, 2025

Current status: @emilazy is hacking on the ast-grep script I used for the initial changes to see whether we can make this more automated and less manual - and then scale this to tons of other packages that are not in by-name yet, but need the same treatment eventually.


let
# atf is a dependency of libiconv. Avoid an infinite recursion with `pkgsStatic` by using a bootstrap stdenv.
stdenv = if args.stdenv.hostPlatform.isDarwin then darwin.bootstrapStdenv else args.stdenv;
Copy link
Contributor

@reckenrode reckenrode Oct 23, 2025

Choose a reason for hiding this comment

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

This means that it’s impossible to override the stdenv on Darwin (without knowing implementation details of the derivation). Is there a way to do this that preserves the ability to override it? That’s why I originally did it in all-packages.nix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @emilazy's comment in #453948 (comment) applies to that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried moving this into darwin's stdenv bootstrap, but failed. I'm sure you'd be capable of doing that, though :)

Copy link
Member

Choose a reason for hiding this comment

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

I can try to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It can’t be in the bootstrap because then pkgsStatic will have an infinite recursion. To make things behave the same between native and cross, the “overrides” have to be in the package definitions not in the bootstrap overlay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, that would explain me failing to do it.

We could introduce a withStdenv ? if ... argument to allow overriding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Putting as draft for the moment. I am currently looking into a way to make this case better to solve here - it's really unsatisfactory, that we can't override stdenv for these packages afterwards anymore.

@wolfgangwalther wolfgangwalther marked this pull request as draft October 26, 2025 17:43
@wolfgangwalther wolfgangwalther mentioned this pull request Nov 3, 2025
13 tasks
@wolfgangwalther
Copy link
Contributor Author

Not going to pursue this anymore myself (#469692).

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

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: vscode A free and versatile code editor that supports almost every major 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. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants