example refactor snowflake module system
This commit is contained in:
parent
0314109bc0
commit
3e29615db9
26 changed files with 1306 additions and 165 deletions
37
nix/snow/flake/modules/withSystem.nix
Normal file
37
nix/snow/flake/modules/withSystem.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ lib, flake-parts-lib, getSystem, ... }:
|
||||
let
|
||||
inherit (lib)
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
inherit (flake-parts-lib)
|
||||
mkPerSystemOption
|
||||
;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
perSystem = mkPerSystemOption ({ config, options, 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
Add a link
Reference in a new issue