at 25.11-pre 2.2 kB view raw
1{ 2 config, 3 pkgs, 4 lib, 5 ... 6}: 7let 8 cfg = config.services.ombi; 9 10in 11{ 12 options = { 13 services.ombi = { 14 enable = lib.mkEnableOption '' 15 Ombi, a web application that automatically gives your shared Plex or 16 Emby users the ability to request content by themselves! 17 18 Optionally see <https://docs.ombi.app/info/reverse-proxy> 19 on how to set up a reverse proxy 20 ''; 21 22 package = lib.mkPackageOption pkgs "ombi" { }; 23 24 dataDir = lib.mkOption { 25 type = lib.types.str; 26 default = "/var/lib/ombi"; 27 description = "The directory where Ombi stores its data files."; 28 }; 29 30 port = lib.mkOption { 31 type = lib.types.port; 32 default = 5000; 33 description = "The port for the Ombi web interface."; 34 }; 35 36 openFirewall = lib.mkOption { 37 type = lib.types.bool; 38 default = false; 39 description = "Open ports in the firewall for the Ombi web interface."; 40 }; 41 42 user = lib.mkOption { 43 type = lib.types.str; 44 default = "ombi"; 45 description = "User account under which Ombi runs."; 46 }; 47 48 group = lib.mkOption { 49 type = lib.types.str; 50 default = "ombi"; 51 description = "Group under which Ombi runs."; 52 }; 53 }; 54 }; 55 56 config = lib.mkIf cfg.enable { 57 systemd.tmpfiles.rules = [ 58 "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" 59 ]; 60 61 systemd.services.ombi = { 62 description = "Ombi"; 63 after = [ "network.target" ]; 64 wantedBy = [ "multi-user.target" ]; 65 66 serviceConfig = { 67 Type = "simple"; 68 User = cfg.user; 69 Group = cfg.group; 70 ExecStart = "${lib.getExe cfg.package} --storage '${cfg.dataDir}' --host 'http://*:${toString cfg.port}'"; 71 Restart = "on-failure"; 72 }; 73 }; 74 75 networking.firewall = lib.mkIf cfg.openFirewall { 76 allowedTCPPorts = [ cfg.port ]; 77 }; 78 79 users.users = lib.mkIf (cfg.user == "ombi") { 80 ombi = { 81 isSystemUser = true; 82 group = cfg.group; 83 home = cfg.dataDir; 84 }; 85 }; 86 87 users.groups = lib.mkIf (cfg.group == "ombi") { ombi = { }; }; 88 }; 89}