at 23.11-pre 2.1 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.services.lidarr; 7in 8{ 9 options = { 10 services.lidarr = { 11 enable = mkEnableOption (lib.mdDoc "Lidarr"); 12 13 dataDir = mkOption { 14 type = types.str; 15 default = "/var/lib/lidarr/.config/Lidarr"; 16 description = lib.mdDoc "The directory where Lidarr stores its data files."; 17 }; 18 19 package = mkOption { 20 type = types.package; 21 default = pkgs.lidarr; 22 defaultText = literalExpression "pkgs.lidarr"; 23 description = lib.mdDoc "The Lidarr package to use"; 24 }; 25 26 openFirewall = mkOption { 27 type = types.bool; 28 default = false; 29 description = lib.mdDoc '' 30 Open ports in the firewall for Lidarr 31 ''; 32 }; 33 34 user = mkOption { 35 type = types.str; 36 default = "lidarr"; 37 description = lib.mdDoc '' 38 User account under which Lidarr runs. 39 ''; 40 }; 41 42 group = mkOption { 43 type = types.str; 44 default = "lidarr"; 45 description = lib.mdDoc '' 46 Group under which Lidarr runs. 47 ''; 48 }; 49 }; 50 }; 51 52 config = mkIf cfg.enable { 53 systemd.tmpfiles.rules = [ 54 "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" 55 ]; 56 57 systemd.services.lidarr = { 58 description = "Lidarr"; 59 after = [ "network.target" ]; 60 wantedBy = [ "multi-user.target" ]; 61 62 serviceConfig = { 63 Type = "simple"; 64 User = cfg.user; 65 Group = cfg.group; 66 ExecStart = "${cfg.package}/bin/Lidarr -nobrowser -data='${cfg.dataDir}'"; 67 Restart = "on-failure"; 68 }; 69 }; 70 71 networking.firewall = mkIf cfg.openFirewall { 72 allowedTCPPorts = [ 8686 ]; 73 }; 74 75 users.users = mkIf (cfg.user == "lidarr") { 76 lidarr = { 77 group = cfg.group; 78 home = "/var/lib/lidarr"; 79 uid = config.ids.uids.lidarr; 80 }; 81 }; 82 83 users.groups = mkIf (cfg.group == "lidarr") { 84 lidarr = { 85 gid = config.ids.gids.lidarr; 86 }; 87 }; 88 }; 89}