diff --git a/defaults/nextcloud/default.nix b/defaults/nextcloud/default.nix index db21a58..11f52c7 100644 --- a/defaults/nextcloud/default.nix +++ b/defaults/nextcloud/default.nix @@ -13,7 +13,7 @@ owner = name; }; - qois.postgresql.enable = true; + services.postgresql.enable = true; qois.backup-client.includePaths = [ config.services.nextcloud.home ]; services.nextcloud = { diff --git a/nixos-configurations/lindberg-build/applications/attic.nix b/nixos-configurations/lindberg-build/applications/attic.nix index c0b0cc0..05f65a4 100644 --- a/nixos-configurations/lindberg-build/applications/attic.nix +++ b/nixos-configurations/lindberg-build/applications/attic.nix @@ -52,11 +52,10 @@ in imports = [ ../../../defaults/webserver ]; - qois.postgresql.enable = true; - # Note: Attic cache availability is "best effort", so no artifacts are backed up. services.postgresql = { + enable = true; ensureDatabases = [ "atticd" ]; ensureUsers = [ { diff --git a/nixos-configurations/lindberg-build/applications/default.nix b/nixos-configurations/lindberg-build/applications/default.nix index d634828..d38f4f0 100644 --- a/nixos-configurations/lindberg-build/applications/default.nix +++ b/nixos-configurations/lindberg-build/applications/default.nix @@ -7,4 +7,5 @@ ]; qois.git-ci-runner.enable = true; + qois.postgresql.package = pkgs.postgresql_15; } diff --git a/nixos-configurations/lindberg-nextcloud/applications/cloud.nix b/nixos-configurations/lindberg-nextcloud/applications/cloud.nix index 86716d2..8e6b4ff 100644 --- a/nixos-configurations/lindberg-nextcloud/applications/cloud.nix +++ b/nixos-configurations/lindberg-nextcloud/applications/cloud.nix @@ -6,7 +6,7 @@ in imports = [ ../../../defaults/nextcloud ]; - qois.postgresql.enable = true; + services.postgresql.enable = true; services.nextcloud = { hostName = host; diff --git a/nixos-configurations/lindberg-nextcloud/applications/default.nix b/nixos-configurations/lindberg-nextcloud/applications/default.nix index 6188fc9..d872c18 100644 --- a/nixos-configurations/lindberg-nextcloud/applications/default.nix +++ b/nixos-configurations/lindberg-nextcloud/applications/default.nix @@ -2,4 +2,6 @@ { imports = [ ./cloud.nix ]; + + qois.postgresql.package = pkgs.postgresql_14; } diff --git a/nixos-configurations/lindberg-webapps/applications/default.nix b/nixos-configurations/lindberg-webapps/applications/default.nix index c635d21..9efef42 100644 --- a/nixos-configurations/lindberg-webapps/applications/default.nix +++ b/nixos-configurations/lindberg-webapps/applications/default.nix @@ -6,4 +6,5 @@ qois.vault.enable = true; qois.git.enable = true; qois.static-page.enable = true; + qois.postgresql.package = pkgs.postgresql_15; } diff --git a/nixos-modules/postgresql/default.nix b/nixos-modules/postgresql/default.nix index e2a8e88..b67f574 100644 --- a/nixos-modules/postgresql/default.nix +++ b/nixos-modules/postgresql/default.nix @@ -11,11 +11,15 @@ in with lib; { options.qois.postgresql = { - enable = mkEnableOption ''Enable postgresql services with defaults''; + # Note: this module is auto-enabled if postgres is used. + package = mkPackageOption pkgs "postgresql" { + example = "postgresql_15"; + default = null; + }; }; - config = mkIf cfg.enable { - services.postgresql.enable = true; + config = mkIf config.services.postgresql.enable { + services.postgresql.package = cfg.package; services.postgresqlBackup.enable = true; qois.backup-client.includePaths = [ config.services.postgresqlBackup.location ]; }; diff --git a/nixos-modules/qois/git/default.nix b/nixos-modules/qois/git/default.nix index 20ba2dd..2bb34be 100644 --- a/nixos-modules/qois/git/default.nix +++ b/nixos-modules/qois/git/default.nix @@ -21,7 +21,7 @@ with lib; }; config = mkIf cfg.enable { - qois.postgresql.enable = true; + services.postgresql.enable = true; services.forgejo = { enable = true; diff --git a/nixos-modules/vault/default.nix b/nixos-modules/vault/default.nix index e61b5fe..9676d3d 100644 --- a/nixos-modules/vault/default.nix +++ b/nixos-modules/vault/default.nix @@ -48,8 +48,6 @@ with lib; }; }; - qois.postgresql.enable = true; - qois.backup-client.includePaths = [ config.services.vaultwarden.config.DATA_FOLDER ]; services.postgresql = @@ -57,6 +55,7 @@ with lib; name = config.users.users.vaultwarden.name; in { + enable = true; ensureUsers = [ { inherit name;