Skip to content

Instantly share code, notes, and snippets.

@illustris
Last active April 29, 2022 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save illustris/cdb2886b6e5d5f3e9d9d7c0026732d52 to your computer and use it in GitHub Desktop.
Save illustris/cdb2886b6e5d5f3e9d9d7c0026732d52 to your computer and use it in GitHub Desktop.
because I forget things

Nix

Get .drv for /etc/nixos/configuration.nix

nix-instantiate '<nixos>' -A system

Pretty print derivation

nix show-derivation /nix/store/qfriughbauiryghbauiobfghvoiadfbuhgvadffhngvn.drv

Explore dependency tree of derivation

nix-tree /nix/store/qfriughbauiryghbauiobfghvoiadfbuhgvadffhngvn.drv

Build package from local nixpkgs

nix-shell -I nixpkgs=$(pwd) -p python38Packages.percol

Diff two closures

source

nix --extra-experimental-features nix-command store diff-closures /run/{booted,current}-system

Get the store path for a package

source

nix-build '<nixpkgs>' --no-build-output -A snappy

Show why a package has another package in its closure

source

nix --extra-experimental-features nix-command why-depends /run/current-system /nix/store/hv5nhj0pc3zpnc3z44mvzbq0zjmgwcjr-snappy-1.1.9

Display a dependency diagram of any closure

nix-shell -p graphviz imagemagick --run 'nix-store -q --graph `which htop` | dot -Tsvg | display'

View nixos options from local nixpkgs

jq < $(nix-build nixos/release.nix -A options)/share/doc/nixos/options.json | less

PVE

Get next VMID

pvesh get /cluster/nextid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment