Finding files in Nix packages:
Nix packages live in /nix/store with unique hashes. Each package can have multiple "outputs" (out/dev/doc/man) - separate store paths for binaries, headers, docs, etc. Get a package's path:
$ nix eval --raw nixpkgs#bash
/nix/store/f43k3lffqlz3n864inxz8zf28jvks1q6-bash-interactive-5.3p3
List what's in a package:
$ ls -R $(nix eval --raw nixpkgs#bash)
/nix/store/f43k3lffqlz3n864inxz8zf28jvks1q6-bash-interactive-5.3p3:
bin/ lib/ share/
/nix/store/f43k3lffqlz3n864inxz8zf28jvks1q6-bash-interactive-5.3p3/bin:
bash bashbug sh
Run the binary:
$ $(nix eval --raw nixpkgs#bash)/bin/bash --version
GNU bash, version 5.3.3(1)-release
Get paths for compilation flags. The .dev output has headers:
$ echo "gcc -I$(nix-build '<nixpkgs>' -A ncurses.dev --no-out-link)/include -L$(nix-build '<nixpkgs>' -A ncurses --no-out-link)/lib -lncurses main.c"
gcc -I/nix/store/hcjy3bl88bqv1h5w6cpm7f9ffd5d9myj-ncurses-6.5-dev/include -L/nix/store/kpi3v5fl8hlgy5lagjvn6ayq78mla49k-ncurses-6.5/lib -lncurses main.c
QEMU bundles OVMF firmware. Find it:
$ find $(nix eval --raw nixpkgs#qemu)/share/qemu -name "edk2*.fd"
/nix/store/3dl18j5j9q1h7k6a5pk59452k8069i81-qemu-10.1.2/share/qemu/edk2-x86_64-code.fd
Boot with UEFI:
$ nix shell nixpkgs#qemu -c qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=$(nix eval --raw nixpkgs#qemu)/share/qemu/edk2-x86_64-code.fd
nixpkgs#bash - from nixpkgs flake
github:NixOS/nixpkgs#bash - explicit GitHub
/path/to/nixpkgs#bash - local path
Multiple outputs save space:
- out: binaries/libraries (default)
- dev: headers for compilation
- man/doc: documentation
More: https://nixos.org/manual/nixpkgs/stable/#chap-multiple-output