mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2025-03-28 02:37:12 +00:00
Add withSystem parameter
This commit is contained in:
parent
c7d1a3d101
commit
19e19dce5a
2 changed files with 40 additions and 0 deletions
|
@ -13,5 +13,6 @@
|
|||
./modules/overlays.nix
|
||||
./modules/packages.nix
|
||||
./modules/perSystem.nix
|
||||
./modules/withSystem.nix
|
||||
];
|
||||
}
|
||||
|
|
39
modules/withSystem.nix
Normal file
39
modules/withSystem.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{ config, lib, flake-parts-lib, self, getSystem, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
genAttrs
|
||||
mapAttrs
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
mkPerSystemOption
|
||||
;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
perSystem = mkPerSystemOption ({ config, options, system, specialArgs, ... }: {
|
||||
_file = ./perSystem.nix;
|
||||
options = {
|
||||
allModuleArgs = mkOption {
|
||||
type = types.lazyAttrsOf (types.raw or types.unspecified);
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
description = "Internal option that exposes _module.args, for use by withSystem.";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
allModuleArgs = config._module.args // specialArgs // { inherit config options; };
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
config = {
|
||||
_module.args = {
|
||||
withSystem =
|
||||
system: f:
|
||||
f
|
||||
(getSystem system).allModuleArgs;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue