more removal of servers bits

This commit is contained in:
Aaron Bieber 2024-08-23 09:09:12 -06:00
parent b6ac2665c9
commit 11eb7bf37c
No known key found for this signature in database

View File

@ -6,7 +6,6 @@
with lib; with lib;
let let
cfg = config.services.tsns; cfg = config.services.tsns;
enabledServers = filterAttrs (_: conf: conf.enable) cfg.servers;
in in
{ {
options = { options = {
@ -39,38 +38,32 @@ in
}; };
}; };
config = mkIf (enabledServers != { }) { config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
users.groups = mapAttrs' users.groups."${cfg.group}" = {};
(name: _: nameValuePair name { }) users.users."${cfg.user}" = {
enabledServers;
users.users = mapAttrs'
(name: conf: nameValuePair name {
description = "System user for tsns instance ${name}"; description = "System user for tsns instance ${name}";
isSystemUser = true; isSystemUser = true;
group = name; group = cfg.group;
home = "${conf.dataDir}"; home = "${cfg.dataDir}";
createHome = true; createHome = true;
}) };
enabledServers;
systemd.services = mapAttrs' systemd.services.tsns = {
(name: conf: nameValuePair name { description = "tsns";
description = "tsns instance ${name}"; enable = true;
enable = true; after = [ "network-online.target" ];
after = [ "network-online.target" ]; wants = [ "network-online.target" ];
wants = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ];
wantedBy = [ "multi-user.target" ];
environment = { HOME = "${cfg.dataDir}"; };
environment = { HOME = "${conf.dataDir}"; };
serviceConfig = {
serviceConfig = { User = cfg.user;
User = conf.user; Group = cfg.group;
Group = conf.group; ExecStart = "${cfg.package}/bin/tsns -d ${cfg.dataDir}";
ExecStart = "${cfg.package}/bin/tsns -d ${conf.dataDir}"; };
}; };
})
enabledServers;
}; };
} }