Skip to content
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/postgresql: add option for domain sockets #207736

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

shivak
Copy link
Contributor

@shivak shivak commented Dec 25, 2022

Adds a socketDir option corresponding to PostgreSQL's unix_socket_directories setting, and uses it in the setup scripts run post-start.

Previously, in these scripts, psql tried to connect to the PostgreSQL via its TCP port. In a typical pg_hba.conf, all TCP connections, even those of localhost, are password protected. Since these scripts run unattended with no passwords provided, they actually worked by falling back to the domain socket. But when a non-standard socket directory is used, it must be explicitly passed to psql. Thus, these scripts were previously broken for those using non-standard socket directories.

PostgreSQL actually supports multiple socket directories, as well as @-prefixed paths for sockets in the "abstract namespace". However, supporting these would upset the types and serialization within the module.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Adds a `socketDir` option corresponding to PostgreSQL's `unix_socket_directories` setting, and uses it in the setup scripts run post-start.
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Dec 25, 2022
If both a nonstandard port and a nonstandard socket directory are used, then both must be passed to `psql`, since the socket filename includes the port number.
@shivak
Copy link
Contributor Author

shivak commented May 17, 2023

Bump: this module is still broken when custom socket directories are desired.

This becomes a problem when running two PostgreSQL instances on the same host. In NixOS, this is accomplished by running a container with its own PostgreSQL service enabled. In order to make this instance externally accessible, one bind-mounts a host directory, which must then be configured as the socket directory.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin and removed 10.rebuild-darwin: 1 10.rebuild-darwin: 1-10 labels May 17, 2023
@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Apr 5, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 5, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@wolfgangwalther
Copy link
Contributor

I think this change makes sense. Could you rebase?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 2, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants