diff --git a/.config/bash/module/Nix.sh b/.config/bash/module/Nix.sh index a8dc5bf..ba761a2 100644 --- a/.config/bash/module/Nix.sh +++ b/.config/bash/module/Nix.sh @@ -46,6 +46,18 @@ function nix_rebuild() { cd - } +# Rebuild and switch system. +# Optionally force the hostname. +# Usage: nix_switch [HOSTNAME] +function nix_switch() { + local target="${1}" + [[ "${target}" = "" ]] && target="${HOSTNAME}" + + cd ${HOME}/.config/linux/system + nixos-rebuild switch --flake .#${target} + cd - +} + # Update system. # Optionally force the hostname. # Usage: nix_update [HOSTNAME] diff --git a/.doc/Bash.md b/.doc/Bash.md index ef90784..7f04567 100644 --- a/.doc/Bash.md +++ b/.doc/Bash.md @@ -270,6 +270,7 @@ Command|Description `nix_unstable`|Switch to Unstable branch. `nix_channel`|Display current channel. `nix_rebuild [HOSTNAME]`|Rebuild system. Optionally force the hostname. +`nix_switch [HOSTNAME]`|Rebuild and switch system. Optionally force the hostname. `nix_update [HOSTNAME]`|Update system. Optionally force the hostname. `nix_clean`|Free up root space. `nix_shell [NAME]`|Spawn shell with specified nix environment. `Main` is default.