From 323d69fc6ad5f5d7543b2c194feca4e9ebed9f35 Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 21 Nov 2023 02:31:40 +0000 Subject: [PATCH] nixos/gitea: fix auth error for non-default database users fixes fallout from . a common idiom is to run the git server as user `git`, instead of `gitea`, with configuration like this: ```nix services.gitea.user = "git"; services.gitea.database.user = "git"; ``` after #266270, this requires setting `services.gitea.database.createDatabase = false` (as recommended by the assertion). however, this causes a few other fields relevant to database connection to no longer be set, and so that upgrade path would lead to a failed connection: ``` gitea-pre-start: cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: pq: password authentication failed for user "git" ``` instead, preserve the old connection settings (socket path) to make this upgrade path work. --- nixos/modules/services/misc/gitea.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix index d43250c882683f..0e4ed331c27706 100644 --- a/nixos/modules/services/misc/gitea.nix +++ b/nixos/modules/services/misc/gitea.nix @@ -143,7 +143,7 @@ in socket = mkOption { type = types.nullOr types.path; - default = if (cfg.database.createDatabase && usePostgresql) then "/run/postgresql" else if (cfg.database.createDatabase && useMysql) then "/run/mysqld/mysqld.sock" else null; + default = if usePostgresql then "/run/postgresql" else if useMysql then "/run/mysqld/mysqld.sock" else null; defaultText = literalExpression "null"; example = "/run/mysqld/mysqld.sock"; description = "Path to the unix socket file to use for authentication."; @@ -400,7 +400,7 @@ in message = '' When creating a database via NixOS, the db user and db name must be equal! If you already have an existing DB+user and this assertion is new, you can safely set - `services.gitea.createDatabase` to `false` because removal of `ensureUsers` + `services.gitea.database.createDatabase` to `false` because removal of `ensureUsers` and `ensureDatabases` doesn't have any effect. ''; } @@ -523,7 +523,7 @@ in systemd.services.gitea = { description = "gitea"; after = [ "network.target" ] ++ optional usePostgresql "postgresql.service" ++ optional useMysql "mysql.service"; - requires = optional (cfg.database.createDatabase && usePostgresql) "postgresql.service" ++ optional (cfg.database.createDatabase && useMysql) "mysql.service"; + requires = optional usePostgresql "postgresql.service" ++ optional useMysql "mysql.service"; wantedBy = [ "multi-user.target" ]; path = [ cfg.package pkgs.git pkgs.gnupg ];