Hi, I’m having some trouble making my psql behave nicely in NixOS. Since NixOS’s psql is wrapped, it doesn’t read my $EDITOR and I’m having to use nano to edit my SQL commands . I’d like to configure the wrapper, or set a psqlrc.
Having read PostgreSQL - NixOS Wiki, I understand that I can use services.postgresql.settings to configure the PostgreSQL server settings, but I couldn’t find mention on how to configure the psql client. I didn’t figure out configuration options from reading the source either.
What makes you say that psql on NixOS is wrapped? It doesn’t seem to be to me: psql is a binary rather than a script on my system. In my testing, it also seemed to respect the EDITOR variable.
Indeed it seems that wrapping is not the issue. file /nix/store/cf5rrb1l9hmhys7346ghi13qd97p34xf-postgresql-15.3/bin/psql tells us the binary is an ELF.
The issue here is probably sudo, not psql. sudo generally only keeps around environment variables it’s configured to. And indeed, if I compare the output of env | sort and sudo env | sort, the latter is missing my EDITOR among many other things.