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

Add mkPerSystemType, mkPerSystemModule

This commit is contained in:
Robert Hensing 2022-05-13 10:14:10 +02:00
parent 1fb0d37021
commit 783e29f7dd
2 changed files with 26 additions and 13 deletions

15
lib.nix
View file

@ -3,6 +3,7 @@ let
inherit (lib)
mkOption
types
functionTo
;
flake-modules-core-lib = {
@ -26,6 +27,20 @@ let
modules = [ { inherit options; } ];
};
};
mkPerSystemType =
module:
types.functionTo (types.submoduleWith {
modules = [ module ];
shorthandOnlyDefinesConfig = false;
});
mkPerSystemModule =
module:
mkOption {
type = flake-modules-core-lib.mkPerSystemType module;
};
};
in

View file

@ -1,4 +1,4 @@
{ config, lib, self, ... }:
{ config, lib, flake-modules-core-lib, self, ... }:
let
inherit (lib)
genAttrs
@ -6,6 +6,9 @@ let
mkOption
types
;
inherit (flake-modules-core-lib)
mkPerSystemType
;
rootConfig = config;
@ -23,18 +26,13 @@ in
};
perSystem = mkOption {
description = "A function from system to flake-like attributes omitting the <system> attribute.";
type = types.functionTo (types.submoduleWith {
modules = [
({ config, system, ... }: {
_file = ./perSystem.nix;
config = {
_module.args.inputs' = mapAttrs (k: rootConfig.perInput system) self.inputs;
_module.args.self' = rootConfig.perInput system self;
};
})
];
shorthandOnlyDefinesConfig = false;
description = "A function from system to flake-like attributes omitting the <literal>&lt;system></literal> attribute.";
type = mkPerSystemType ({ config, system, ... }: {
_file = ./perSystem.nix;
config = {
_module.args.inputs' = mapAttrs (k: rootConfig.perInput system) self.inputs;
_module.args.self' = rootConfig.perInput system self;
};
});
};