-
Notifications
You must be signed in to change notification settings - Fork 71
Draft for nixpkgs flake module #126
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
Changes from all commits
910198b
c330b7b
12c4090
9c9ec49
bbc2e83
8137d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,32 @@ | ||
| # | ||
| # Nixpkgs module. The only exception to the rule. | ||
| # | ||
| # Provides a `pkgs` argument in `perSystem`. | ||
| # | ||
| # Arguably, this shouldn't be in flake-parts, but in nixpkgs. | ||
| # Nixpkgs could define its own module that does this, which would be | ||
| # a more consistent UX, but for now this will do. | ||
| # | ||
| # The existence of this module does not mean that other flakes' logic | ||
| # will be accepted into flake-parts, because it's against the | ||
| # spirit of Flakes. | ||
| # | ||
| topLevel@{ config, options, inputs, lib, flake-parts-lib, ... }: | ||
| let | ||
| inherit (flake-parts-lib) mkPerSystemOption; | ||
|
|
||
| in | ||
| { | ||
| config = { | ||
| perSystem = { inputs', lib, ... }: { | ||
| config = { | ||
| _module.args.pkgs = lib.mkOptionDefault ( | ||
| builtins.seq | ||
| (inputs'.nixpkgs or (throw "flake-parts: The flake does not have a `nixpkgs` input. Please add it, or set `perSystem._module.args.pkgs` yourself.")) | ||
| inputs'.nixpkgs.legacyPackages | ||
| ); | ||
| }; | ||
| }; | ||
| imports = [ inputs.nixpkgs.flakeModules.default ]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't make assumptions about the |
||
|
|
||
| options = { | ||
| perSystem = mkPerSystemOption ({ config, system, ... }: | ||
| let | ||
| finalOverlay = lib.composeManyExtensions | ||
| # Last element has priority, so `perSystem` overlays rule | ||
| (topLevel.config.nixpkgs.overlays ++ config.nixpkgs.overlays); | ||
|
|
||
| finalPkgs = config.nixpkgs.mkPkgsFromArgs { | ||
| localSystem = { inherit system; }; | ||
| overlays = [ finalOverlay ]; | ||
| }; | ||
|
|
||
| in | ||
| { | ||
| imports = [ inputs.nixpkgs.flakeModules.default ]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a general rule, modules are imported at the top level only. This makes importing more consistent, not having to wonder where to import it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this would be needed to expose the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
See my comment above. Am I wrong? I'm using |
||
| _file = ./nixpkgs.nix; | ||
| config = { | ||
| _module.args.pkgs = lib.mkForce finalPkgs; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would give this responsibility to |
||
| }; | ||
| }); | ||
| }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think additions to this module are necessary.