-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/gitea: don't configure the database if createDatabase == false
#268849
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, there was a discussion in the past on when to declare dependencies (because requires
will cause problems when undefined services are listed in there): #237544
If you declare createDatabase = false;
, I'd expect that the module leaves the entire task of configuring the database connection to me.
I think the correct fix is to add an assertion here that ensures that the system user is equal to the database user (and thus the PAM authentication used by createDatabase = true;
will work again) and ask everybody who doesn't do that (system user == db user == db name) to configure it themselves.
adc3949
to
323d69f
Compare
fixes fallout from <NixOS#266270>. 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 NixOS#266270, this requires setting `services.gitea.database.createDatabase = false` (as recommended by the assertion). however, the module then plumbs defaults which no longer make sense into the gitea config causing a failed connection at runtime: ``` gitea-pre-start: cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: pq: password authentication failed for user "git" ``` instead, don't default any of the connection settings when `createDatabase == false`: error at eval time (instead of runtime) if the user hasn't explicitly configured the remaining connection settings.
323d69f
to
92662a9
Compare
@Ma27 took me a bit to find something ergonomic, pushed a patch which i think does a good job. if services.gitea.enable = true;
services.gitea.database.type = "postgres";
services.gitea.database.createDatabase = false;
# if eval'd here, user will see an error about `config.services.gitea.database.{name,user,...}` being referenced but not defined
services.gitea.database.name = "gitea";
services.gitea.database.user = "git";
services.gitea.database.socket = "/run/postgresql";
# then user is expected to manually configure services.postgresql, and define a `requires` from gitea onto postgresql if applicable |
createDatabase == false
fixes fallout from #266270.
a common idiom is to run the git server as user
git
, instead ofgitea
, with configuration like this:after #266270, this requires setting
services.gitea.database.createDatabase = false
(as recommended by the assertion). however, the module then plumbs defaults which no longer make sense into the gitea config causing a failed connection at runtime:instead, don't default any of the connection settings when
createDatabase == false
: error at eval time (instead of runtime) if the user hasn't explicitly configured the remaining connection settings.Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)