Try this @jkt:
- Create a
shell.nixinside your source code:
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
name = "cpp_project";
buildInputs = with pkgs; [
cmake
ninja
swig
pcre
bison
flex
openssl
];
nativeBuildInputs = [ pkgs.pkg-config ];
shellHook = ''
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOME/project/libmanolo/"
'';
}
Change buildInputs to your needs. Keep pkgs.pkg-config in nativeBuildInputs. In shellHook you put any variable you want to export or some commands you want to run on the creation of the new shell. In this example I’m extending $PKG_CONFIG_PATH.
-
Inside the folder with the
shell.nixfile run the commandnix-shell. -
If you print
PKG_CONFIG_PATHit’ll show you thatPKG_CONFIG_PATHwas extended with$HOME/project/libmanolo/.
echo $PKG_CONFIG_PATH
/nix/store/izfyh5hr9as4ihx2vwi2yrnkiz6gn4qi-pcre-8.44-dev/lib/pkgconfig:/nix/store/lwcrmj44j6s5ww3j0ybar2jc7kf9ddzq-openssl-1.1.1g-dev/lib/pkgconfig:/nix/store/izfyh5hr9as4ihx2vwi2yrnkiz6gn4qi-pcre-8.44-dev/lib/pkgconfig:/nix/store/lwcrmj44j6s5ww3j0ybar2jc7kf9ddzq-openssl-1.1.1g-dev/lib/pkgconfig:/home/thiago/project/libmanolo/