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

38 lines
833 B
Nix
Raw Normal View History

2023-05-29 17:52:03 +00:00
{ lib, flake-parts-lib, getSystem, ... }:
2022-05-27 15:41:07 +00:00
let
inherit (lib)
mkOption
types
;
inherit (flake-parts-lib)
mkPerSystemOption
;
in
{
options = {
2023-05-29 17:52:03 +00:00
perSystem = mkPerSystemOption ({ config, options, specialArgs, ... }: {
2022-05-27 15:41:07 +00:00
_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;
};
};
}