6

I'm wondering how to install the psql command on NixOS. To be clear: I'm only interested in the client, not the server.

I've looked at the derivation but couldn't find any pointers.

Is there a way to create a derivation without building from source?

Thanks!

Melle
  • 7,639
  • 1
  • 30
  • 31
  • 2
    You've found the *NixOS module*. The [derivation is here.](https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/sql/postgresql/default.nix). It does not define a client-only derivation. I have double checked with `nix repl ''`. – Robert Hensing Sep 17 '18 at 08:41

2 Answers2

6

The psql command is in any of the postgresql* packages, so you can just add that to environment.systemPackages and rebuild:

environment.systemPackages = [ pkgs.postgresql ];
Silvan Mosberger
  • 1,786
  • 14
  • 19
3

Instead of installing the package you can also use nix shell / run, and define a shell alias:

alias psql="nix shell nixpkgs#postgresql --command psql"
jla
  • 9,684
  • 2
  • 21
  • 18