1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Add mkTransposedPerSystemModule for simple per-system exposed attrs

This commit is contained in:
Shea Levy 2022-10-30 06:52:28 -04:00
parent d707369f93
commit 8e6bca1b0a
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27

28
lib.nix
View file

@ -98,6 +98,34 @@ let
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