mirror of
https://github.com/nix-community/flakelight.git
synced 2024-11-21 23:13:09 +01:00
Add pkgsFor module arg
This enables modules to access packages given some system, outside of per-system attributes.
This commit is contained in:
parent
a7e2fe5468
commit
bcaa85757e
@ -57,6 +57,7 @@ The following module arguments are available:
|
||||
- `flakelight`: flakelight lib attribute
|
||||
- `inputs`: value of inputs option
|
||||
- `outputs`: resulting output (i.e. final flake attributes)
|
||||
- `pkgsFor`: attrset mapping systems to the pkgs set for that system
|
||||
- `moduleArgs`: All of the above arguments (passed to auto-loaded files)
|
||||
|
||||
## Additional pkgs values
|
||||
|
@ -5,7 +5,7 @@
|
||||
{ config, inputs, lib, flakelight, ... }:
|
||||
let
|
||||
inherit (builtins) all head isAttrs length;
|
||||
inherit (lib) foldAttrs getFiles getValues mapAttrs mergeAttrs mkOption
|
||||
inherit (lib) foldAttrs genAttrs getFiles getValues mapAttrs mergeAttrs mkOption
|
||||
mkOptionType showFiles showOption;
|
||||
inherit (lib.types) functionTo lazyAttrsOf listOf nonEmptyStr raw uniq;
|
||||
inherit (flakelight.types) optListOf overlay;
|
||||
@ -20,6 +20,12 @@ let
|
||||
(lazyAttrsOf outputs).merge loc defs
|
||||
else throw "The option `${showOption loc}' has conflicting definitions in ${showFiles (getFiles defs)}";
|
||||
};
|
||||
|
||||
pkgsFor = genAttrs config.systems (system: import inputs.nixpkgs {
|
||||
inherit system;
|
||||
inherit (config.nixpkgs) config;
|
||||
overlays = config.withOverlays ++ [ config.packageOverlay ];
|
||||
});
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@ -54,16 +60,15 @@ in
|
||||
};
|
||||
|
||||
config = {
|
||||
_module.args = { inherit (config) inputs outputs; };
|
||||
_module.args = {
|
||||
inherit (config) inputs outputs;
|
||||
inherit pkgsFor;
|
||||
};
|
||||
|
||||
outputs = foldAttrs mergeAttrs { } (map
|
||||
(system: mapAttrs
|
||||
(_: v: { ${system} = v; })
|
||||
(config.perSystem (import inputs.nixpkgs {
|
||||
inherit system;
|
||||
inherit (config.nixpkgs) config;
|
||||
overlays = config.withOverlays ++ [ config.packageOverlay ];
|
||||
})))
|
||||
(config.perSystem pkgsFor.${system}))
|
||||
config.systems);
|
||||
};
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
, flakelight
|
||||
, inputs
|
||||
, outputs
|
||||
, pkgsFor
|
||||
, specialArgs
|
||||
, modulesPath
|
||||
, moduleArgs
|
||||
|
Loading…
Reference in New Issue
Block a user