nix

nix Cheatsheet #

nix is a package manager for Linux and other Unix systems that allows users to manage packages and configurations in a reproducible manner. It uses a declarative configuration language and provides isolation for different environments.

Basic Commands #

Command/OptionExampleDescription
nix-env -inix-env -i package-nameInstall a package
nix-env -enix-env -e package-nameUninstall a package
nix-env -unix-env -u package-nameUpgrade a package
nix-env -qnix-env -q package-nameQuery information about a package
nix-env -lnix-env -lList all installed packages
nix-env -iAnix-env -iA nixpkgs.package-nameInstall a package from a specific attribute
nix-shellnix-shellStart a new shell with a specific environment
nix-buildnix-buildBuild a package or configuration
nix-collect-garbagenix-collect-garbageRemove old and unused packages

Configuration Management #

Command/OptionExampleDescription
nixos-rebuild switchsudo nixos-rebuild switchApply a new system configuration
nixos-rebuild testsudo nixos-rebuild testTest a new system configuration
nixos-rebuild bootsudo nixos-rebuild bootUpdate system configuration for next boot
nix-copy-closurenix-copy-closure --to ssh://remoteCopy closures to a remote machine

Package Management #

Command/OptionExampleDescription
nix-store --gcnix-store --gcPerform garbage collection on the Nix store
nix-store --verifynix-store --verifyVerify the integrity of the Nix store
nix-store --querynix-store --query --requisites /path/to/storeList the dependencies of a store path

Advanced Commands #

Command/OptionExampleDescription
nix-opsnix-ops deployDeploy configuration with NixOps
nix-shell -pnix-shell -p package-nameStart a shell with a specified package
nix-prefetch-urlnix-prefetch-url https://example.com/fileFetch and hash a file from a URL

Environment Management #

Command/OptionExampleDescription
nix-env --switch-profilenix-env --switch-profile /path/to/profileSwitch to a different user profile
nix-env --setnix-env --set package-nameSet a specific package version

This cheatsheet covers the essential nix commands for package management, configuration, and advanced operations in the Nix ecosystem.

nix

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.