-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Postgres Service doesn't Run #339
Comments
I have the same issue. You can see what's going on by taking a look at postgres' logs: launchd.user.agents.postgresql.serviceConfig = {
StandardErrorPath = "/Users/vitor/postgres.error.log";
StandardOutPath = "/Users/vitor/postgres.log";
}; Postgres is trying to write to I created $ sudo mkdir -p /usr/local/var/postgres
$ sudo chown -R vitor:staff /usr/local/var Then I configured postgres to use this directory: postgresql = {
enable = true;
dataDir = "/usr/local/var/postgres";
package = pkgs.postgresql_13;
}; |
I just added a |
I'd suggest keeping the issue open. We solved it but the default behavior is broken. |
See also: [Postgres Service doesn't Run](LnL7/nix-darwin#339) Considering manage all services by `homebrew`
For what it's worth, I compiled @vmsp & @benkio's suggestions together into a # ❯ cat .nixpkgs/services/postgres.nix
{ config, pkgs, ... }:
{
services = {
postgresql = {
enable = true;
package = pkgs.postgresql;
# dataDir = /. + "/var/lib/postgresql/"; # Default value
};
};
# Create the PostgreSQL data directory, if it does not exist.
system.activationScripts.preActivation = {
enable = true;
text = ''
if [ ! -d "/var/lib/postgresql/" ]; then
echo "creating PostgreSQL data directory..."
sudo mkdir -m 775 -p /var/lib/postgresql/
chown -R cbzehner:staff /var/lib/postgresql/
fi
'';
};
# Direct log output to $XDG_DATA_HOME/postgresql for debugging.
launchd.user.agents.postgresql.serviceConfig = {
# Un-comment these values instead to avoid a home-manager dependency.
# StandardErrorPath = "/Users/cbzehner/postgres.error.log";
# StandardOutPath = "/Users/cbzehner/postgres.out.log";
StandardErrorPath = "/Users/cbzehner/.local/share/postgresql/postgres.error.log";
StandardOutPath = "/Users/cbzehner/.local/share/postgresql/postgres.out.log";
};
home-manager.users = {
cbzehner = {
# Create the directory ~/.local/share/postgresql/
xdg.dataFile."postgresql/.keep".text = "";
};
};
} |
I'd like to set Am I right in thinking that the postgres service is run as the logged in user? (The idea is I have a dedicated postgres user which owns the |
As of 511177f the postgresql module appears very unfinished and broken. Here is a list of my findings:
|
With latest nix-darwin postgresql service will fail because database cannot be created. Bug was introduced about a year ago by c9fcec4. Until the bug is not fixed you can create the database in the activationScript section: system.activationScripts.preActivation = {
enable = true;
text = ''
if [ ! -d "/var/lib/postgresql/" ]; then
echo "creating PostgreSQL data directory..."
sudo mkdir -m 750 -p /var/lib/postgresql/
chown -R fesplugas:staff /var/lib/postgresql/
fi
'';
};
services.postgresql.initdbArgs = ["-U fesplugas" "--pgdata=/var/lib/postgresql/15" "--auth=trust" "--no-locale" "--encoding=UTF8"];
services.postgresql.package = pkgs.postgresql_15;
services.postgresql.enable = true;
launchd.user.agents.postgresql.serviceConfig = {
StandardErrorPath = "/tmp/postgres.error.log";
StandardOutPath = "/tmp/postgres.log";
}; A PR #794 has been created. A few considerations:
|
Has anyone taken a stab at this at all? These seem like sensible steps to take to make this not-terrible and even almost usable! |
Hi,
I just added in my
darwin-configuration.nix
the basic configuration aboutpostgres
service:But I can't see any folder in
/var/lib/postgresql
and the server isn't running in background.Here a full pastebin of the commands as they are right now.
https://pastebin.com/fteqZ77g
The text was updated successfully, but these errors were encountered: