From 276c0a88f5ed89dddfccb7d197559dbc6c95f5b4 Mon Sep 17 00:00:00 2001 From: Ethel Morgan Date: Sun, 24 May 2020 11:41:49 +0100 Subject: move eth.upmpdcli to eth.services.umpdcli also, the default FriendlyName now includes the system hostname. --- module-list.nix | 2 +- modules/services/upmpdcli.nix | 82 +++++++++++++++++++++++++++++++++++++++++++ modules/upmpdcli.nix | 78 ---------------------------------------- 3 files changed, 83 insertions(+), 79 deletions(-) create mode 100644 modules/services/upmpdcli.nix delete mode 100644 modules/upmpdcli.nix diff --git a/module-list.nix b/module-list.nix index 8885c39..c24ae39 100644 --- a/module-list.nix +++ b/module-list.nix @@ -5,7 +5,7 @@ ./modules/overlays.nix ./modules/services/mosquitto.nix ./modules/services/snapclient.nix - ./modules/upmpdcli.nix + ./modules/services/upmpdcli.nix ./modules/users.nix ./modules/yubikey.nix ] diff --git a/modules/services/upmpdcli.nix b/modules/services/upmpdcli.nix new file mode 100644 index 0000000..d301a49 --- /dev/null +++ b/modules/services/upmpdcli.nix @@ -0,0 +1,82 @@ +{ config, lib, pkgs, ... }: +with lib; + +let + cfg = config.eth.services.upmpdcli; + + cacheDir = "upmpdcli"; + + upmpdConf = pkgs.writeText "upmpd.conf" '' + cachedir = /var/cache/${cacheDir} + + friendlyname = ${cfg.friendlyName} + + mpdhost = ${cfg.mpd.host} + mpdport = ${toString cfg.mpd.port} + + ${optionalString (cfg.mpd.password != "") "${cfg.mpd.password}"} + + ${cfg.extraConfig} + ''; + +in { + options.eth.services.upmpdcli = { + enable = mkEnableOption "Run upmpdcli server"; + + friendlyName = mkOption { + type = types.str; + default = "UpMpd (${config.networking.hostName})"; + description = "Friendly Name used for UPnP discovery."; + }; + + mpd = { + host = mkOption { + type = types.str; + default = config.services.mpd.network.listenAddress; + description = "Host of the MPD server."; + }; + port = mkOption { + type = types.int; + default = config.services.mpd.network.port; + description = "Port of the MPD server."; + }; + password = mkOption { + type = types.str; + default = ""; + description = "Password of the MPD server."; + }; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + }; + }; + + config = mkIf cfg.enable { + systemd.services.upmpdcli = { + enable = true; + description = ""; + wants = [ "network.target" ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.openssl pkgs.python3 ]; + serviceConfig = { + DynamicUser = true; + + CacheDirectory = cacheDir; + + Type = "simple"; + ExecStart="${pkgs.eth.upmpdcli}/bin/upmpdcli -c ${upmpdConf}"; + Restart = "always"; + RestartSec = "1min"; + + NoNewPrivileges = true; + ProtectHome = true; + ProtectKernelTunables = true; + ProtectControlGroups = true; + ProtectKernelModules = true; + }; + }; + }; +} diff --git a/modules/upmpdcli.nix b/modules/upmpdcli.nix deleted file mode 100644 index 5b83a2f..0000000 --- a/modules/upmpdcli.nix +++ /dev/null @@ -1,78 +0,0 @@ -{ config, lib, pkgs, ... }: -with lib; - -let - cfg = config.services.upmpdcli; - - cacheDir = "upmpdcli"; - - upmpdConf = pkgs.writeText "upmpd.conf" '' - cachedir = /var/cache/${cacheDir} - - friendlyname = ${cfg.friendlyName} - - mpdhost = ${cfg.mpd.host} - mpdport = ${toString cfg.mpd.port} - - ${optionalString (cfg.mpd.password != "") "${cfg.mpd.password}"} - - ${cfg.extraConfig} - ''; - -in { - options.services.upmpdcli = { - enable = mkEnableOption "Run upmpdcli server"; - - friendlyName = mkOption { - type = types.str; - default = "UpMpd"; - description = "Friendly Name used for UPnP discovery."; - }; - - mpd = { - host = mkOption { - type = types.str; - default = config.services.mpd.network.listenAddress; - description = "Host of the MPD server."; - }; - port = mkOption { - type = types.int; - default = config.services.mpd.network.port; - description = "Port of the MPD server."; - }; - password = mkOption { - type = types.str; - default = ""; - description = "Password of the MPD server."; - }; - }; - - extraConfig = mkOption { - type = types.lines; - default = ""; - }; - }; - - config = mkIf cfg.enable { - environment.systemPackages = [ - pkgs.eth.upmpdcli - ]; - - systemd.services.upmpdcli = { - enable = true; - description = ""; - wants = [ "network.target" ]; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - path = [ pkgs.openssl pkgs.python3 ]; - serviceConfig = { - DynamicUser = "yes"; - CacheDirectory = cacheDir; - Type = "simple"; - ExecStart="${pkgs.eth.upmpdcli}/bin/upmpdcli -c ${upmpdConf}"; - Restart = "always"; - RestartSec = "1min"; - }; - }; - }; -} -- cgit v1.2.3