From 278ddca61c2ffdbd8808e9a30bb39a7f89a9b3c1 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 3 Feb 2024 00:04:38 +0300 Subject: [PATCH] Nix : Add switch function. --- .config/bash/module/Nix.sh | 12 ++++++++++++ .doc/Bash.md | 1 + 2 files changed, 13 insertions(+) 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.