So I started a project following the official guide
cargo new my-gtk-app
cd my-gtk-app
But when I look for the development version
[antonio@nixos:~]$ pkg-config --modversion gtk4
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found
only add executables to path, and doesn’t add thing like header files and libraries that you need for development, buildInputs using mkShell will do that.
nix-shell doesn’t need to be temproray , you can create shell.nix file and commit it to project you are working on
with import <nixpkgs> ; mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
meson
ninja
];
buildInputs = with pkgs; [
gtk4
libadwaita
glib
gsettings-desktop-schemas
adwaita-icon-theme
];
}
Nixers typically avoid adding arbitrary software development project concerns to their NixOS configurations. Instead, development shells are used. Those are local to each software project in which they are used. Here’s some documentation:
FYI direnv is also quite useful to automatically activate devshells with nix-direnv. Not mandatory by any means, but quite nice. Just add this to your project’s .envrc, next to your shell.nix:
#!/usr/bin/env bash
if ! has nix_direnv_version || ! nix_direnv_version 3.1.2; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.1.2/direnvrc" "sha256-Di03ad3a0ueGi6CGrfhrQzyGdQIg9APXIPCAMNQgWYM="
fi
use nix