Skip to content

NixOS: use overlays when nixpkgs.pkgs is set #49256

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

Merged
merged 9 commits into from
Nov 13, 2018

Conversation

roberth
Copy link
Member

@roberth roberth commented Oct 27, 2018

Motivation for this change

In the current situation, when specifying nixpkgs.pkgs in NixOS, the nixpkgs.overlays option is ignored. Now that we have pkgs.extend since #47430, we can actually support the combination.

It makes the nixpkgs options a bit more predictable and when pkgs.nixosTest #47684 is merged, this will enable project-specific NixOS tests to reuse pkgs while also supporting test machine-specific overlays.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@roberth roberth added 0.kind: enhancement Add something new 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: user experience 6.topic: developer experience nixpkgs development workflow labels Oct 27, 2018
@roberth roberth requested review from Ericson2314 and nbp October 27, 2018 13:05
@GrahamcOfBorg GrahamcOfBorg removed the 8.has: documentation This PR adds or changes documentation label Oct 27, 2018
@roberth roberth mentioned this pull request Oct 27, 2018
9 tasks
@GrahamcOfBorg GrahamcOfBorg 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 27, 2018
@roberth roberth changed the title Nixos nixpkgs pkgs use overlays NixOS: use overlays when nixpkgs.pkgs is set Oct 28, 2018
@roberth roberth requested a review from matthewbauer as a code owner November 3, 2018 18:50
@GrahamcOfBorg GrahamcOfBorg added 8.has: changelog 8.has: documentation This PR adds or changes documentation 2.status: merge conflict This PR has merge conflicts with the target branch labels Nov 3, 2018
@GrahamcOfBorg GrahamcOfBorg removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Nov 4, 2018
inherit (cfg) config overlays localSystem crossSystem;
};

finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not so sure about this. While I see the use case of setting pkgs and overlays, there's no reason you can't set overlays yourself when you init pkgs. Since we don't do this for config, crossSystem, or localSystem, it seems a little unexpected. We probably should have an assertion for those so that you don't set pkgs and something that has no effect.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was going to add the assertion when I ran into #49765. I actually wrote the assertion yesterday, but forgot to push it here. I don't think it is necessary to add the other assertion about the host system.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding whether we should, this elegantly enables a use case pointed out by aszlig for nixosTest where one of the machines has an extra overlay. So that is one reason why you can't set overlays yourself when you init pkgs.

We could support the other options but I can't tell at this point how well that would work.

Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

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

Sounds good to me.

@roberth roberth requested a review from infinisil as a code owner November 10, 2018 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new 6.topic: developer experience nixpkgs development workflow 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: user experience 8.has: changelog 8.has: documentation This PR adds or changes 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: 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.

None yet

6 participants