# Find Nix package path. # Usage: nix_find function nix_find() { local IFS=$'\n' local package="${1}" if [[ "${package}" = "" ]]; then help find_nix return 2 fi local found=$(ls --classify /nix/store/ | grep "${package}".*/) if [[ "${found}" != "" ]]; then echo "/nix/store/${found%/}" else false fi } # Switch to Unstable branch. function nix_unstable() { nix-channel --add https://nixos.org/channels/nixos-unstable nixos } # Switch to Small Unstable branch (for server). function nix_unstable_small() { nix-channel --add https://nixos.org/channels/nixos-unstable-small nixos } # Display current channel. function nix_channel() { nix-channel --list } # Update system (rebuild). function nix_update() { nixos-rebuild switch -I nixos-config=/root/.config/linux/nix/${HOSTNAME}/Configuration.nix } # Upgrade system. function nix_upgrade() { nixos-rebuild switch --upgrade -I nixos-config=/root/.config/linux/nix/${HOSTNAME}/Configuration.nix } # Free up root space. function nix_clean() { nix-collect-garbage -d [[ "${UID}" = 0 ]] && nix-store --gc } # Spawn temporary shell. function shell() { nix-shell -p "${@}" }