diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-21 04:35:03 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:28 +0530 |
| commit | 610e951914eb60683e24c610a3ecbaeb848e2900 (patch) | |
| tree | 6f4a69d89ec1dcc223e04f9f5681e21f62c23b93 /modules/scripts | |
| parent | 58cd82c184b5f321930eed614462f69b0a0d9fa3 (diff) | |
| download | home-manager-config-610e951914eb60683e24c610a3ecbaeb848e2900.tar.gz home-manager-config-610e951914eb60683e24c610a3ecbaeb848e2900.zip | |
script: added --only-switch mode to nix-update script
- added --only-switch option to nix-update script, that just runs
home-manager switch or nixos-rebuild switch and no nix flake update
- renamed the --flake-only option to --only-flake for consistency
Diffstat (limited to 'modules/scripts')
| -rw-r--r-- | modules/scripts/nix-update/completion.zsh | 3 | ||||
| -rw-r--r-- | modules/scripts/nix-update/script.sh | 36 |
2 files changed, 26 insertions, 13 deletions
diff --git a/modules/scripts/nix-update/completion.zsh b/modules/scripts/nix-update/completion.zsh index ee4115c..a9500e6 100644 --- a/modules/scripts/nix-update/completion.zsh +++ b/modules/scripts/nix-update/completion.zsh @@ -16,6 +16,7 @@ case $state in ;; flags) _arguments \ - '--flake-only[Only run nix flake update, skip switch commands]' + '--only-flake[Only run nix flake update, skip switch commands]' \ + '--only-switch[Only run switch commands, skip nix flake update]' ;; esac diff --git a/modules/scripts/nix-update/script.sh b/modules/scripts/nix-update/script.sh index 7f2b6d0..0f1c0c1 100644 --- a/modules/scripts/nix-update/script.sh +++ b/modules/scripts/nix-update/script.sh @@ -4,11 +4,12 @@ set -euo pipefail HM_DIR="$HOME/.config/home-manager" NIXOS_DIR="/etc/nixos" -FLAKE_ONLY=false +ONLY_FLAKE=false +ONLY_SWITCH=false TARGET="" usage() { - echo "Usage: nix-update <home-manager|nixos|both> [--flake-only]" + echo "Usage: nix-update <home-manager|nixos|both> [--only-flake|--only-switch]" echo "" echo "Options:" echo " home-manager Update and switch home-manager configuration" @@ -16,7 +17,8 @@ usage() { echo " both Update and switch both configurations" echo "" echo "Flags:" - echo " --flake-only Only run nix flake update, skip switch commands" + echo " --only-flake Only run nix flake update, skip switch commands" + echo " --only-switch Only run switch commands, skip nix flake update" exit 1 } @@ -31,8 +33,12 @@ parse_args() { TARGET="$1" shift ;; - --flake-only) - FLAKE_ONLY=true + --only-flake) + ONLY_FLAKE=true + shift + ;; + --only-switch) + ONLY_SWITCH=true shift ;; -h | --help) @@ -58,16 +64,20 @@ update_home_manager() { echo " Staging modules/private..." git add modules/private -f - echo " Running nix flake update..." - nix flake update + if [[ "$ONLY_SWITCH" == false ]]; then + echo " Running nix flake update..." + nix flake update + fi - if [[ "$FLAKE_ONLY" == false ]]; then + if [[ "$ONLY_FLAKE" == false ]]; then echo " Running home-manager switch..." home-manager switch --flake "$HM_DIR#arpit" fi echo " Unstaging modules/private..." - git rm --cached -r modules/private + for f in modules/private/*.nix; do + [[ "$f" == *.example.nix ]] || git rm --cached "$f" + done echo "==> home-manager update complete" } @@ -80,10 +90,12 @@ update_nixos() { echo " Staging hardware-configuration.nix..." git add hardware-configuration.nix -f - echo " Running nix flake update..." - nix flake update + if [[ "$ONLY_SWITCH" == false ]]; then + echo " Running nix flake update..." + nix flake update + fi - if [[ "$FLAKE_ONLY" == false ]]; then + if [[ "$ONLY_FLAKE" == false ]]; then echo " Running nixos-rebuild switch..." sudo nixos-rebuild switch fi |
