nixos/services.jmusicbot: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-30 00:46:36 +02:00
parent 291d92e529
commit f645147c7e

View File

@ -1,18 +1,16 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.jmusicbot;
in
{
options = {
services.jmusicbot = {
enable = mkEnableOption "jmusicbot, a Discord music bot that's easy to set up and run yourself";
enable = lib.mkEnableOption "jmusicbot, a Discord music bot that's easy to set up and run yourself";
package = mkPackageOption pkgs "jmusicbot" { };
package = lib.mkPackageOption pkgs "jmusicbot" { };
stateDir = mkOption {
type = types.path;
stateDir = lib.mkOption {
type = lib.types.path;
description = ''
The directory where config.txt and serversettings.json is saved.
If left as the default value this directory will automatically be created before JMusicBot starts, otherwise the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions.
@ -23,20 +21,20 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.jmusicbot = {
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
description = "Discord music bot that's easy to set up and run yourself!";
serviceConfig = mkMerge [{
serviceConfig = lib.mkMerge [{
ExecStart = "${cfg.package}/bin/JMusicBot";
WorkingDirectory = cfg.stateDir;
Restart = "always";
RestartSec = 20;
DynamicUser = true;
}
(mkIf (cfg.stateDir == "/var/lib/jmusicbot") { StateDirectory = "jmusicbot"; })];
(lib.mkIf (cfg.stateDir == "/var/lib/jmusicbot") { StateDirectory = "jmusicbot"; })];
};
};