C: Difference between revisions
imported>Tfc mNo edit summary |
imported>Mic92 add pkg-config |
||
Line 119: | Line 119: | ||
Further options are described in the [https://nixos.org/nixpkgs/manual/#sec-hardening-in-nixpkgs manual] | Further options are described in the [https://nixos.org/nixpkgs/manual/#sec-hardening-in-nixpkgs manual] | ||
== pkg-config == | |||
pkg-config is a tool and file format to describe what compiler and linker flags a build process needs to add | |||
to use a certain library. It is often used as part of the build process to check if needed dependencies are | |||
present and in the right version. In nix expression pkg-config will find its <code>.pc</code> files | |||
by looking up the <code>PKG_CONFIG_PATH</code> variable. This variable is automatically set | |||
when <code>pkg-config</code> is present in <code>nativeBuildInputs</code> by a build-support | |||
hook provided by the <code>pkg-config</code> package. | |||
If you save the following file as <code>shell.nix</code>: | |||
<syntaxHighlight lang=nix> | |||
with import <nixpkgs> {}; | |||
stdenv.mkDerivation { | |||
name = "env"; | |||
nativeBuildInputs = [ pkgconfig ]; | |||
buildInputs = [ | |||
cryptsetup | |||
]; | |||
} | |||
</syntaxHighlight> | |||
The <code>PKG_CONFIG_PATH</code> variable will have the following content when running <code>nix-shell</code> | |||
<syntaxHighlight lang=console> | |||
[nix-shell:~] echo $PKG_CONFIG_PATH | |||
/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig:/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig | |||
[nix-shell:~] pkg-config --cflags libcryptsetup | |||
-I/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/include | |||
</syntaxHighlight> |