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

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

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.

@roberth roberth changed the title Nixos nixpkgs pkgs use overlays NixOS: use overlays when nixpkgs.pkgs is set Oct 28, 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.

nixos/modules/misc/nixpkgs.nix Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants