%title NixOS Quick Tips
:nix:dev:ops:
%date 2020-10-19 19:05

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`

upgrade to new channel:
`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`
