nix: module improvements
This commit is contained in:
28
module.nix
28
module.nix
@@ -14,6 +14,12 @@ in {
|
|||||||
The package implementing disconic
|
The package implementing disconic
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "yrmos";
|
||||||
|
description = "Service user that will run the daemon.";
|
||||||
|
};
|
||||||
|
|
||||||
subsonicUrl = mkOption {
|
subsonicUrl = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = "Subsonic library base API URL";
|
description = "Subsonic library base API URL";
|
||||||
@@ -30,6 +36,10 @@ in {
|
|||||||
type = types.path;
|
type = types.path;
|
||||||
description = "File path containing discord token";
|
description = "File path containing discord token";
|
||||||
};
|
};
|
||||||
|
discordGuild = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Your server's guild ID, to auto-register commands";
|
||||||
|
};
|
||||||
extraArgs = mkOption {
|
extraArgs = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
@@ -41,13 +51,27 @@ in {
|
|||||||
systemd.services.disconic = {
|
systemd.services.disconic = {
|
||||||
description = "Disconic, a Discord Subsonic Bot";
|
description = "Disconic, a Discord Subsonic Bot";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig.ExecStart = lib.escapeShellArgs ([
|
serviceConfig = {
|
||||||
|
Restart = "always";
|
||||||
|
User = cfg.user;
|
||||||
|
ExecStart = lib.escapeShellArgs ([
|
||||||
(lib.getExe cfg.package)
|
(lib.getExe cfg.package)
|
||||||
"--subsonic-url=${cfg.subsonicUrl}"
|
"--subsonic-url=${cfg.subsonicUrl}"
|
||||||
"--subsonic-user=${cfg.subsonicUser}"
|
"--subsonic-user=${cfg.subsonicUser}"
|
||||||
"--subsonic-password=$(cat ${cfg.subsonicPasswordFile})"
|
"--subsonic-password=$(cat ${cfg.subsonicPasswordFile})"
|
||||||
"--discord-token=$(cat ${cfg.discordTokenFile}"
|
"--discord-token=$(cat ${cfg.discordTokenFile})"
|
||||||
|
"--discord-guild=${cfg.discordGuild}"
|
||||||
] ++ cfg.extraArgs);
|
] ++ cfg.extraArgs);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users = {
|
||||||
|
users.${cfg.user} = {
|
||||||
|
description = "disconic service user";
|
||||||
|
isSystemUser = true;
|
||||||
|
group = cfg.user;
|
||||||
|
};
|
||||||
|
groups.${cfg.user} = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user