diff --git a/flake.nix b/flake.nix index e3af3c7..486a2fc 100644 --- a/flake.nix +++ b/flake.nix @@ -47,11 +47,11 @@ nixosModules.default = { config, lib, pkgs, ... }: let - cfg = config.services.phenix-website; + cfg = config.services.all-dressed-programming.phenix-website; phenix = self.packages.${pkgs.system}.website; pythonEnv = pkgs.python3.withPackages (ps: [ ps.requests ]); in { - options.services.phenix-website = { + options.services.all-dressed-programming.phenix-website = { enable = lib.mkEnableOption "Balle Phenix website"; domain = lib.mkOption { type = lib.types.str; @@ -65,6 +65,10 @@ type = lib.types.path; default = "/var/lib/phenix"; }; + databaseUrl = lib.mkOption { + type = lib.types.str; + default = ""; + }; sessionKey = lib.mkOption { type = lib.types.str; default = ""; @@ -87,13 +91,21 @@ Group = "phenix"; }; - environment = { - ASPNETCORE_URLS = "http://0.0.0.0:${toString cfg.port}"; - ASPNETCORE_ENVIRONMENT = "Production"; - ConnectionStrings__Default = "Data Source=${cfg.dataDir}/phenix.db"; - } // lib.optionalAttrs (cfg.sessionKey != "") { - SessionKey = cfg.sessionKey; - }; + environment = + { + ASPNETCORE_URLS = "http://0.0.0.0:${toString cfg.port}"; + ASPNETCORE_ENVIRONMENT = "Production"; + } + // lib.optionalAttrs (cfg.databaseUrl == "") { + ConnectionStrings__Default = "Data Source=${cfg.dataDir}/phenix.db"; + } + // lib.optionalAttrs (cfg.databaseUrl != "") { + DatabaseProvider = "Postgres"; + ConnectionStrings__Default = cfg.databaseUrl; + } + // lib.optionalAttrs (cfg.sessionKey != "") { + SessionKey = cfg.sessionKey; + }; postStart = '' mkdir -p ${cfg.dataDir} @@ -109,17 +121,6 @@ users.groups.phenix = {}; - services.nginx = lib.mkIf (cfg.domain != "") { - enable = true; - virtualHosts.${cfg.domain} = { - forceSSL = true; - enableACME = true; - locations."/" = { - proxyPass = "http://127.0.0.1:${toString cfg.port}"; - proxyWebsockets = false; - }; - }; - }; }; }; };