2021-09-03 08:57:05 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
2022-06-11 18:13:07 +00:00
|
|
|
options.services.syndicate = mkOption {
|
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
tty1 = {
|
|
|
|
enable = true;
|
|
|
|
user = "jane";
|
|
|
|
config = [ "/etc/syndicate" ];
|
|
|
|
};
|
2021-11-12 13:29:37 +00:00
|
|
|
};
|
2022-06-11 18:13:07 +00:00
|
|
|
description = ''
|
|
|
|
Syndicate dataspace server instances.
|
|
|
|
If the key is in the form of "tty''${N}" it will
|
|
|
|
be attached to the appropriate teletypwriter.
|
|
|
|
'';
|
|
|
|
type = types.attrsOf (types.submodule {
|
|
|
|
options = {
|
|
|
|
enable = mkEnableOption "this Syndicate dataspace server instance";
|
2021-11-12 13:29:37 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "jane";
|
|
|
|
description = "User account under which the Syndicate server runs.";
|
|
|
|
};
|
2021-09-03 08:57:05 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.syndicate-server;
|
|
|
|
defaultText = "pkgs.syndicate-server";
|
|
|
|
type = types.package;
|
|
|
|
description =
|
|
|
|
"The package to use for the Syndicate dataspace server.";
|
|
|
|
};
|
2021-09-03 08:57:05 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
config = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
description = "Configurations to load.";
|
|
|
|
example = [ "/etc/syndicate" ];
|
|
|
|
};
|
2021-09-03 08:57:05 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
};
|
|
|
|
});
|
2021-09-03 08:57:05 +00:00
|
|
|
};
|
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
config = {
|
|
|
|
|
|
|
|
systemd.services = lib.attrsets.mapAttrs' (name: cfg: {
|
|
|
|
name = "syndicate-${name}";
|
|
|
|
value = let
|
|
|
|
flags = lib.strings.concatMapStrings (c: " --config ${c}") cfg.config;
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart =
|
|
|
|
"${cfg.package}/bin/syndicate-server --no-banner ${flags}";
|
|
|
|
User = cfg.user;
|
|
|
|
};
|
|
|
|
in if builtins.match "tty[0-9]" name != null then {
|
2022-06-22 18:53:03 +00:00
|
|
|
enable = true;
|
2022-06-11 18:13:07 +00:00
|
|
|
description = "Syndicate dataspace server";
|
|
|
|
after = [
|
|
|
|
"systemd-user-sessions.service"
|
|
|
|
"systemd-logind.service"
|
|
|
|
"getty@${name}.service"
|
|
|
|
];
|
|
|
|
before = [ "graphical.target" ];
|
|
|
|
wants = [ "dbus.socket" "systemd-logind.service" ];
|
|
|
|
wantedBy = [ "graphical.target" ];
|
|
|
|
conflicts = [ "getty@${name}.service" ];
|
2021-09-03 08:57:05 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
restartIfChanged = false;
|
|
|
|
unitConfig.ConditionPathExists = "/dev/${name}";
|
2021-12-05 11:11:24 +00:00
|
|
|
|
2022-06-11 18:13:07 +00:00
|
|
|
serviceConfig = serviceConfig // {
|
|
|
|
PAMName = "login";
|
|
|
|
StandardError = "journal";
|
|
|
|
StandardInput = "tty-fail";
|
|
|
|
StandardOutput = "journal";
|
|
|
|
TTYPath = "/dev/${name}";
|
|
|
|
TTYReset = "yes";
|
|
|
|
TTYVHangup = "yes";
|
|
|
|
TTYVTDisallocate = "yes";
|
|
|
|
UtmpIdentifier = "%n";
|
|
|
|
UtmpMode = "user";
|
|
|
|
WorkingDirectory = "~";
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
description = "Syndicate dataspace server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
inherit serviceConfig;
|
2021-09-03 08:57:05 +00:00
|
|
|
};
|
2022-06-11 18:13:07 +00:00
|
|
|
})
|
|
|
|
(lib.attrsets.filterAttrs (_: cfg: cfg.enable) config.services.syndicate);
|
2021-09-03 08:57:05 +00:00
|
|
|
|
|
|
|
};
|
2022-06-11 18:13:07 +00:00
|
|
|
|
2021-09-03 08:57:05 +00:00
|
|
|
}
|