diff options
Diffstat (limited to 'modules/nixosModules/watcharr.nix')
| -rw-r--r-- | modules/nixosModules/watcharr.nix | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/modules/nixosModules/watcharr.nix b/modules/nixosModules/watcharr.nix new file mode 100644 index 0000000..2263e4f --- /dev/null +++ b/modules/nixosModules/watcharr.nix @@ -0,0 +1,74 @@ +{ + inputs, + self, + ... +}: { + flake.nixosModules.watcharr = { + config, + lib, + pkgs, + ... + }: + with lib; let + cfg = config.services.watcharr; + port = builtins.toString cfg.settings.port; + in { + options = { + services.watcharr = { + enable = mkEnableOption "Enable watcharr service"; + subdomain = mkOption { + type = types.str; + description = '' + Subdomain to use for nginx. + ''; + }; + settings = { + dataDir = mkOption { + type = types.path; + description = '' + Watcharr data directory. + ''; + default = "/var/lib/watcharr"; + }; + port = mkOption { + type = types.port; + default = 3080; + description = '' + Port to use. + ''; + }; + }; + }; + }; + + config = mkIf cfg.enable { + createPaths = { + "${cfg.settings.dataDir}" = { + owner = "root"; + group = "root"; + permissions = "0750"; + }; + }; + + nginxProxy = { + enable = true; + subdomains = { + "${cfg.subdomain}" = { + proxyPass = "http://127.0.0.1:${port}"; + proxyWebsockets = true; + }; + }; + }; + + virtualisation.oci-containers.containers.watcharr = { + image = "ghcr.io/sbondco/watcharr:latest"; + ports = [ + "127.0.0.1${port}:3080" + ]; + volumes = [ + "${cfg.settings.dataDir}:/data" + ]; + }; + }; + }; +} |
