Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treewide: fail when nixpkgs.config is set with explicit pkgs, remove all nixpkgs.config usages in in-tree modules #257458

Merged
merged 8 commits into from
Oct 1, 2023

Conversation

K900
Copy link
Contributor

@K900 K900 commented Sep 26, 2023

Description of changes

This gun has been pointed at too many feet now. Kill it.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.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.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: qt/kde 8.has: documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 26, 2023
@ofborg ofborg bot added 8.has: clean-up 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Sep 26, 2023
Copy link
Contributor

@Gerg-L Gerg-L left a comment

Choose a reason for hiding this comment

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

Very nice!

@delroth delroth added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Sep 26, 2023
Copy link
Contributor

@alois31 alois31 left a comment

Choose a reason for hiding this comment

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

I tested this on my system, and everything still works. Although my system config doesn't make use of any of the places where this was previously defined, the diff looks good to me as well.

@delroth delroth added 12.approvals: 2 This PR was reviewed and approved by two reputable people and removed 12.approvals: 1 This PR was reviewed and approved by one reputable person labels Sep 26, 2023
@misuzu
Copy link
Contributor

misuzu commented Sep 29, 2023

Maybe add a changelog entry?

@K900
Copy link
Contributor Author

K900 commented Sep 29, 2023

I did?

@K900
Copy link
Contributor Author

K900 commented Sep 29, 2023

Oops. Had it on the wrong branch.

@K900
Copy link
Contributor Author

K900 commented Sep 29, 2023

Just realized ofborg doesn't automatically request reviews from affected module maintainers, so I've done that manually. Please check up on your modules and tell me what I did wrong here!

@delroth delroth added 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people and removed 12.approvals: 2 This PR was reviewed and approved by two reputable people labels Sep 29, 2023
@@ -1,8 +1,6 @@
{ lib, stdenv, fetchurl, config }:
{ lib, stdenv, fetchurl, config, dbfile ? config.locate.dbfile or "/var/cache/locatedb" }:
Copy link
Member

Choose a reason for hiding this comment

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

Tbh I don't know why we have this. Other packages also just hardcode paths.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe I just create a PR dropping this entirely if @peterhoeg does not object

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 guess someone wanted to put their locate database on some external storage?

Copy link
Member

Choose a reason for hiding this comment

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

I think this can be accomplished with symlinks which removes some not really required complexity.

@jtojnar
Copy link
Member

jtojnar commented Sep 29, 2023

👍 for removing the vim option from GNOME. It was introduced to avoid GTK 2 variant but I would hope that is the default these days. If not, we should probably do that – it would be nice to get GTK 2 out of graphical installation ISO.

@K900 K900 merged commit eb8ce79 into NixOS:master Oct 1, 2023
7 checks passed
@arcnmx
Copy link
Member

arcnmx commented Oct 1, 2023

This likely should've started as a warning; it's a rather broken and incomplete way to solve the problem, with no reasonable workarounds available to use while it's broken. Maybe it could assert that cfg.config == {} || cfg.config == pkgs.config to enable workarounds in some way?

@K900
Copy link
Contributor Author

K900 commented Oct 1, 2023

Why is it broken, and why is it an incomplete way to solve the problem?

@arcnmx
Copy link
Member

arcnmx commented Oct 1, 2023

I mostly just personally disagree with the strict approach when not everyone necessarily has control over whether a possibly out-of-tree module has decided to set an option under config, though I guess you could config = mkForce {} to work around that? It just seems fragile, and the way the meaning and interpretation of the option changes contextually based on how pkgs is passed is awkward.

The reason it's broken though is because not all uses of nixpkgs.config have been removed here:

Presumably these need to be changed to use pkgs.config? I haven't done a thorough check but that might be all that's left outside of tests using it?

@K900
Copy link
Contributor Author

K900 commented Oct 1, 2023

Read accesses to those shouldn't break anything, as the option isn't removed, and the assertion won't be triggered by reading it. However, yes, those all should be changed to pkgs.config, as that is more correct.

@alois31
Copy link
Contributor

alois31 commented Oct 1, 2023

It just seems fragile, and the way the meaning and interpretation of the option changes contextually based on how pkgs is passed is awkward.

This was already the case before, in fact that's the entire rationale for this PR.

K900 added a commit to K900/nixpkgs that referenced this pull request Oct 1, 2023
`pkgs` may be passed in externally, in which case `config.nixpkgs.config` will not be set.

Follow-up to NixOS#257458.
@arcnmx
Copy link
Member

arcnmx commented Oct 1, 2023

Read accesses to those shouldn't break anything, as the option isn't removed, and the assertion won't be triggered by reading it. However, yes, those all should be changed to pkgs.config, as that is more correct.

Oh I mean broken as in those config options are broken: if pkgs is set explicitly and one wants to set any of the options those module read, you're SoL. There's no migration path available here since the assertion prevents you from setting them temporarily in nixpkgs.config to be read by modules as a workaround.
It's not more correct, it's just currently impossible to set both enableAllFirmware and pkgs since you'll hit a error: attribute 'allowUnfree' missing error from it trying to check for that config entry. All reads and writes must be removed from nixpkgs.

This was already the case before, in fact that's the entire rationale for this PR.

At least one could import <nixpkgs. { inherit (config.nixpkgs) config; } previously. I'd argue this introduces a new footgun now that module authors must beware of an option they should never set or read from - though a gun pointed at nixpkgs contributors may be better than one pointed at users I suppose. Also reading from pkgs.config was likely more correct from the start (assuming that using config is even correct to begin with, which I won't comment on)

@K900
Copy link
Contributor Author

K900 commented Oct 1, 2023

That's actually a completely separate bug.

@K900
Copy link
Contributor Author

K900 commented Oct 1, 2023

(and using pkgs.config.allowUnfree does fix it)

@alyssais
Copy link
Member

alyssais commented Oct 2, 2023

The locate change doesn't work at all:

       error: attribute 'override' missing

       at /home/qyliss/src/nixpkgs/nixos/modules/misc/locate.nix:233:37:

          232|
          233|     environment.systemPackages = [ (cfg.locate.override { dbfile = cfg.output; }) ];
             |                                     ^
          234|

(Config is just services.locate.enable = true;.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: GNOME GNOME desktop environment and its underlying platform 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: qt/kde 8.has: changelog 8.has: clean-up 8.has: documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12.approvals: 3+ This PR was reviewed and approved by three or more reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.