-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathparts.nix
More file actions
111 lines (106 loc) · 3.05 KB
/
parts.nix
File metadata and controls
111 lines (106 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
lib,
flake-parts-lib,
config,
...
}:
let
inherit (lib) types mkOption;
file = ./parts.nix;
in
{
_file = file;
key = file;
options.flake = mkOption {
type = types.submoduleWith {
modules = [
(
{ options, ... }:
{
_file = file;
key = file;
options.wrappers = mkOption {
type = types.lazyAttrsOf ((import ./lib { inherit lib; }).types.subWrapperModuleWith { });
default = { };
description = ''
Submodule option for configuring and exporting wrapper modules!
https://github.com/BirdeeHub/nix-wrapper-modules
'';
};
options.wrapperModules = mkOption {
type = types.lazyAttrsOf types.deferredModule;
readOnly = true;
description = ''
contains importable module forms of your wrappers output
Read only. Modify `flake.wrappers` instead, this will reflect that option.
https://github.com/BirdeeHub/nix-wrapper-modules
'';
};
config.wrapperModules = (types.lazyAttrsOf types.deferredModule).merge options.wrappers.loc options.wrappers.definitionsWithLocations;
}
)
];
};
};
options.perSystem =
let
inherit (config.flake) wrappers;
in
flake-parts-lib.mkPerSystemOption (
{
pkgs,
config,
...
}:
{
_file = file;
key = file;
options.wrappers.pkgs = mkOption {
type = types.pkgs;
default = pkgs;
description = ''
The `pkgs` object used to build `outputs.wrappers` into packages
'';
};
options.wrappers.control_type = mkOption {
type = types.enum [
"build"
"exclude"
];
default = "exclude";
description = ''
The behavior of `perSystem.wrappers.packages`
`exclude` will cause true values in the set to exclude that package.
`build` will cause only true values in the set to be built.
'';
};
options.wrappers.packages = mkOption {
type = types.attrsOf types.bool;
default = { };
description = ''
A set of booleans indicating which packages should be built.
Behavior of this option is determined by `perSystem.wrappers.control_type`
'';
};
config.packages = lib.pipe wrappers [
(
v:
let
args = lib.filterAttrs (_: v: v) config.wrappers.packages;
in
if config.wrappers.control_type == "build" then
builtins.intersectAttrs args wrappers
else
lib.filterAttrs (n: _: !args ? "${n}") wrappers
)
(builtins.mapAttrs (
_: v:
v.wrap {
_file = file;
inherit (config.wrappers) pkgs;
}
))
];
}
);
}