Kitaab

NixOS Quick Tips

nix dev ops

published 2020-10-19 19:05

updated 2024-05-03 17:19

install a package

nix-env -i hello <-- not reproducible and hence not advisable or
edit /etc/nixos/configuration.nix to ensure system wide install nixos-rebuild switch <-- create new generation nixos-rebuild test <-- only active while computer on

sudo nixos-rebuild test -I nixpkgs=~/usr/nixpkgs/ ^-- use local repo to build pkgs

find out where in the store a binary is

readlink -f $(which hello)

search packages

nix-env -qaP '.*hello.*' or nix search <pkg>

search nix package options

nixos-option <option>

clear up space

nix-collect-garbage -d Run with sudo!

upgrade to new channel

(non flakes only) nix-channel --list # show what version we're on nix-channel --add https://nixos.org/channels/nixos-XX.XX nixos nix-channel --update nixos-rebuild switch remember to use sudo if you want to update the system

= use a package through nix-shell = nix-shell -p <package>

list generations

nix-env --list-generations

list installed packages

nixos-option environment.systemPackages or nix-env --query

= install a nixOS .nix file through nix package manager = nix-env -f nvim.nix -i neovim