{ config, lib, ... }: with lib; let cfg = config.nixfiles.modules.lidarr; in { options.nixfiles.modules.lidarr = { enable = mkEnableOption "Lidarr"; domain = mkOption { description = "Domain name sans protocol scheme."; type = with types; str; default = "lidarr.${config.networking.domain}"; }; }; config = mkIf cfg.enable { nixfiles.modules.nginx = { enable = true; upstreams.lidarr.servers."127.0.0.1:8686" = {}; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://lidarr"; extraConfig = nginxInternalOnly; }; }; services.lidarr = { enable = true; user = "rtorrent"; group = "rtorrent"; }; }; }