Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setup: The program 'pg_config' is required but it could not be found

On nixos, when attempting to build my project with $ stack --nix build, I run into the following error.

$ stack --nix build

...

Linking /run/user/1000/stack25943/postgresql-libpq-0.9.2.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup ...
Configuring postgresql-libpq-0.9.2.0...
setup: The program 'pg_config' is required but it could not be found.

I have installed postgres following the nixos manual and do have pg_config installed, as shown by

$ which pg_config
/run/current-system/sw/bin/pg_config

It appears that stack does not know this location of my pg_config.

How do I proceed to get $ stack --nix build to succeed?

like image 801
mherzl Avatar asked Dec 14 '22 22:12

mherzl


1 Answers

You'll need to add Nix packages to the nix-shell environment that it's building Haskell packages in.

In stack.yaml:

nix:
  packages: [postgresql]
like image 158
iElectric Avatar answered Jan 12 '23 03:01

iElectric