{ pkgs, config, lib, ... }: let cfg = config.modules.services.; ids = ; default_port = ; data_dir = "/var/lib/"; in { options.modules.services. = { enable = lib.mkEnableOption "enables "; # set port options port = lib.mkOption { type = lib.types.int; default = cfg.default_port; description = "set port for (default: ${toString default_port}"; }; backup = lib.mkOption { type = lib.types.bool; default = true; description = "enable backups for "; }; }; config = lib.mkIf cfg.enable { # declare group users.groups. = { gid = ids; }; # declare user users.users. = { description = " server user"; uid = ids; isSystemUser = true; home = "/var/lib/"; createHome = true; group = ""; extraGroups = [ "media" ]; }; # enable the service services. = { enable = true; openFirewall = true; user = ""; group = ""; dataDir = data_dir; settings = { server.port = cfg.port; }; }; # override umask to make permissions work out systemd.services..serviceConfig = { UMask = lib.mkForce "0007"; }; # # open firewall # networking.firewall.allowedTCPPorts = [ cfg.port ]; # internal reverse proxy entry services.nginx.virtualHosts.".snowbelle.lan" = { enableACME = false; forceSSL = true; sslCertificate = config.sops.secrets."ssl_blakedheld_crt".path; sslCertificateKey = config.sops.secrets."ssl_blakedheld_key".path; locations."/" = { proxyPass = "http://127.0.0.1:${toString cfg.port}"; }; # external reverse proxy entry services.nginx.virtualHosts.".blakedheld.xyz" = { enableACME = false; forceSSL = true; sslCertificate = config.sops.secrets."ssl_blakedheld_crt".path; sslCertificateKey = config.sops.secrets."ssl_blakedheld_key".path; locations."/" = { proxyPass = "http://127.0.0.1:${toString cfg.port}"; }; }; # add to backups modules.system.backups.paths = lib.mkIf cfg.backup [ data_dir ]; }; }