mirror of
https://github.com/hercules-ci/flake-parts.git
synced 2025-03-16 21:38:24 +00:00
Add mkTransposedPerSystemModule for simple per-system exposed attrs
This commit is contained in:
parent
d707369f93
commit
8e6bca1b0a
1 changed files with 28 additions and 0 deletions
28
lib.nix
28
lib.nix
|
@ -98,6 +98,34 @@ let
|
||||||
type = flake-parts-lib.mkPerSystemType module;
|
type = flake-parts-lib.mkPerSystemType module;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Helper function for defining a per-system option that
|
||||||
|
# gets transposed by the usual flake system logic to a
|
||||||
|
# top-level flake attribute.
|
||||||
|
mkTransposedPerSystemModule = { name, option, file }: {
|
||||||
|
_file = file;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
flake = flake-parts-lib.mkSubmoduleOptions {
|
||||||
|
${name} = mkOption {
|
||||||
|
type = types.lazyAttrsOf option.type;
|
||||||
|
default = { };
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
See {option}`perSystem.${name}` for description and examples.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
perSystem = flake-parts-lib.mkPerSystemOption {
|
||||||
|
_file = file;
|
||||||
|
|
||||||
|
options.${name} = option;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
transposition.${name} = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
Loading…
Add table
Reference in a new issue