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

fix: Override option nixpkgs.config to avoid failed assertion #144

Merged

Conversation

lordkekz
Copy link
Contributor

@lordkekz lordkekz commented Apr 8, 2024

Fixes #142

Note that other modules could conceivably be affected if they read the value of config.nixpkgs.config, but I find that exceedingly unlikely.

@gytis-ivaskevicius
Copy link
Owner

why mkforce is required there?

@lordkekz
Copy link
Contributor Author

lordkekz commented Apr 9, 2024

Because we need to override the value that other modules have set.
Let's say nixpkgs.config is being set by some module cheese.nix

{ config, outputs, lib, ... }: {
  nixpkgs.config.allowUnfree = true;
}

And flake-utils-plus will add a module similar to this:

{ config, outputs, lib, ... }: {
  nixpkgs.pkgs = // generated from channels
}

Now, nixpkgs will throw an assertion failure because you can only set either nixpkgs.config or nixpkgs.pkgs but not both.
In the nixpkgs.pkgs which flake-utils-plus generates, the value nixpkgs.config is being applied, so we won't lose information by using the generated pkgs.

To get rid of the nixpkgs assertion failure, we need to reset nixpkgs.config to an empty set in the final evaluation; to override the nixpkgs.config which cheese.nix presumably sets without mkDefault or such, we need to choose a higher priority, like mkForce. If we used a priority less than or equal to the definitions in cheese.nix, it would have no effect.

I think it's fine to use mkForce here because no user could ever want to override it; doing so would just break the configuration.

@gytis-ivaskevicius
Copy link
Owner

Thanks!

@gytis-ivaskevicius gytis-ivaskevicius merged commit fe008c5 into gytis-ivaskevicius:master May 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use flakes inputs modifying nixpkgs.config anymore
2 participants