k 3 retiolum: explicitly build users, secrets and services

This commit is contained in:
makefu 2016-07-20 14:15:47 +02:00
parent 24db6439c4
commit d35fc9f6d2
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -13,6 +13,9 @@ let
''; '';
type = with types; attrsOf (submodule (tinc: { type = with types; attrsOf (submodule (tinc: {
options = { options = {
enable = mkEnableOption "krebs.tinc.${tinc.config._module.args.name}" // { default = true; };
host = mkOption { host = mkOption {
type = types.host; type = types.host;
default = config.krebs.build.host; default = config.krebs.build.host;
@ -121,7 +124,17 @@ let
}; };
})); }));
}; };
imp = lib.mkMerge ( lib.mapAttrsToList (netname: cfg: imp = {
# TODO environment.systemPackages = [ tinc iproute ]; AND avoid conflicts
krebs.secret.files = lib.mapAttrs' (netname: cfg:
nameValuePair "${netname}.rsa_key.priv" cfg.privkey ) config.krebs.tinc;
users.users = lib.mapAttrs' (netname: cfg:
nameValuePair "${netname}" {
inherit (cfg.user) home name uid;
createHome = true;
} ) config.krebs.tinc;
systemd.services = lib.mapAttrs (netname: cfg:
let let
net = cfg.host.nets.${netname}; net = cfg.host.nets.${netname};
@ -153,11 +166,6 @@ let
''; '';
}); });
in { in {
krebs.secret.files."${netname}.rsa_key.priv" = cfg.privkey;
environment.systemPackages = [ tinc iproute ];
systemd.services.${netname} = {
description = "Tinc daemon for ${netname}"; description = "Tinc daemon for ${netname}";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
@ -168,11 +176,6 @@ let
ExecStart = "${tinc}/sbin/tincd -c ${confDir} -d 0 -U ${cfg.user.name} -D --pidfile=/var/run/tinc.${SyslogIdentifier}.pid"; ExecStart = "${tinc}/sbin/tincd -c ${confDir} -d 0 -U ${cfg.user.name} -D --pidfile=/var/run/tinc.${SyslogIdentifier}.pid";
SyslogIdentifier = netname; SyslogIdentifier = netname;
}; };
} ) config.krebs.tinc;
}; };
users.users.${cfg.user.name} = {
inherit (cfg.user) home name uid;
createHome = true;
};
}) {} ); # TODO <<<< replace with the "config.krebs.tinc" and avoid infinite recursion
in out in out