-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
41 lines (35 loc) · 844 Bytes
/
default.nix
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
{ lib, pkgs, ... }@args:
let
inherit (lib)
types
subtractLists
removeSuffix
filter
genAttrs
mkEnableOption
mkOption
mkIf
;
inherit (types) lazyAttrsOf unspecified;
allSrvPath = (subtractLists [ "default.nix" ] (with builtins; attrNames (readDir ./.)));
allSrvName = map (removeSuffix ".nix") allSrvPath;
existSrvName = filter (n: args.config.services ? ${n}) allSrvName;
in
{
options.srv = genAttrs allSrvName (sn: {
enable = mkEnableOption "${sn} service";
override = mkOption {
type = lazyAttrsOf unspecified;
default = { };
};
});
config.services = genAttrs existSrvName (
n:
(
let
perSrv = args.config.srv.${n};
in
(mkIf (perSrv.enable) ((removeAttrs (import ./${n}.nix args) [ "attach" ]) // perSrv.override))
)
);
}