aboutsummaryrefslogtreecommitdiffstats
path: root/modules/system
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar@gmail.com>2026-09-24 04:19:59 +0530
committerArpit Chakladar <arpitchakladar@gmail.com>2026-09-24 04:19:59 +0530
commit3a6e45ad18c519b21c9cadb2d374148647886b05 (patch)
treec8ad94d5be285a770a319e6a6a6fdda6021b652a /modules/system
parent574b4e4651495ed3fb14ef53a00374782d45b378 (diff)
downloadhome-manager-config-3a6e45ad18c519b21c9cadb2d374148647886b05.tar.gz
home-manager-config-3a6e45ad18c519b21c9cadb2d374148647886b05.zip
refactor: ran newly configured formatter for the whole project
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/deep-clean/deep-clean.sh17
-rw-r--r--modules/system/nix-update/nix-update.sh83
2 files changed, 53 insertions, 47 deletions
diff --git a/modules/system/deep-clean/deep-clean.sh b/modules/system/deep-clean/deep-clean.sh
index f22a620..025366a 100644
--- a/modules/system/deep-clean/deep-clean.sh
+++ b/modules/system/deep-clean/deep-clean.sh
@@ -4,10 +4,13 @@
set -euo pipefail
-info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
-warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
-die() { error "$*"; exit 1; }
+die() {
+ error "$*"
+ exit 1
+}
info "Starting Nix Deep Clean (keeping only current generations)"
@@ -20,9 +23,9 @@ info "Removing old NixOS system generations..."
sudo nix-env -p /nix/var/nix/profiles/system --delete-generations +1
info "Removing old Home Manager generations..."
-if command -v home-manager &> /dev/null; then
- home-manager generations | \
- awk 'NR>1 {print $1}' | \
+if command -v home-manager &>/dev/null; then
+ home-manager generations |
+ awk 'NR>1 {print $1}' |
xargs -r home-manager remove-generations
fi
@@ -39,4 +42,4 @@ nix-collect-garbage -d
info "Optimising Nix store..."
nix store optimise
-info "Cleanup Complete." \ No newline at end of file
+info "Cleanup Complete."
diff --git a/modules/system/nix-update/nix-update.sh b/modules/system/nix-update/nix-update.sh
index 79718fd..6ceaaa3 100644
--- a/modules/system/nix-update/nix-update.sh
+++ b/modules/system/nix-update/nix-update.sh
@@ -3,10 +3,13 @@
set -euo pipefail
-info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
-warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
+info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
+warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; }
error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; }
-die() { error "$*"; exit 1; }
+die() {
+ error "$*"
+ exit 1
+}
HOME_MANAGER_CONFIG_DIR="$HOME/.config/home-manager"
NIXOS_CONFIG_DIR="/etc/nixos"
@@ -31,33 +34,33 @@ print_usage() {
parse_command_line_arguments() {
while [[ $# -gt 0 ]]; do
case "$1" in
- home-manager | nixos | both)
- if [[ -n "$UPDATE_TARGET" ]]; then
- error "only one target allowed"
- print_usage
- fi
- UPDATE_TARGET="$1"
- shift
- ;;
- --only-flake)
- ONLY_UPDATE_FLAKE_INPUTS=true
- shift
- ;;
- --only-switch)
- ONLY_SWITCH_CONFIGURATION=true
- shift
- ;;
- -h | --help)
- print_usage
- ;;
- *)
- error "unknown option '$1'"
+ home-manager | nixos | both)
+ if [[ -n $UPDATE_TARGET ]]; then
+ error "only one target allowed"
print_usage
- ;;
+ fi
+ UPDATE_TARGET="$1"
+ shift
+ ;;
+ --only-flake)
+ ONLY_UPDATE_FLAKE_INPUTS=true
+ shift
+ ;;
+ --only-switch)
+ ONLY_SWITCH_CONFIGURATION=true
+ shift
+ ;;
+ -h | --help)
+ print_usage
+ ;;
+ *)
+ error "unknown option '$1'"
+ print_usage
+ ;;
esac
done
- if [[ -z "$UPDATE_TARGET" ]]; then
+ if [[ -z $UPDATE_TARGET ]]; then
error "no target specified"
print_usage
fi
@@ -72,12 +75,12 @@ update_home_manager_configuration() {
trap 'git rm --cached users/arpit/private.nix >/dev/null 2>&1 || true' EXIT INT TERM HUP
- if [[ "$ONLY_SWITCH_CONFIGURATION" == false ]]; then
+ if [[ $ONLY_SWITCH_CONFIGURATION == false ]]; then
info "Running nix flake update..."
nix flake update
fi
- if [[ "$ONLY_UPDATE_FLAKE_INPUTS" == false ]]; then
+ if [[ $ONLY_UPDATE_FLAKE_INPUTS == false ]]; then
info "Running home-manager switch..."
home-manager switch --flake "$HOME_MANAGER_CONFIG_DIR#arpit"
fi
@@ -100,12 +103,12 @@ update_nixos_configuration() {
trap 'git rm --cached hardware-configuration.nix >/dev/null 2>&1 || true' EXIT INT TERM HUP
- if [[ "$ONLY_SWITCH_CONFIGURATION" == false ]]; then
+ if [[ $ONLY_SWITCH_CONFIGURATION == false ]]; then
info "Running nix flake update..."
nix flake update
fi
- if [[ "$ONLY_UPDATE_FLAKE_INPUTS" == false ]]; then
+ if [[ $ONLY_UPDATE_FLAKE_INPUTS == false ]]; then
info "Running nixos-rebuild switch..."
sudo nixos-rebuild switch
fi
@@ -121,14 +124,14 @@ update_nixos_configuration() {
parse_command_line_arguments "$@"
case "$UPDATE_TARGET" in
- home-manager)
- update_home_manager_configuration
- ;;
- nixos)
- update_nixos_configuration
- ;;
- both)
- update_nixos_configuration
- update_home_manager_configuration
- ;;
+home-manager)
+ update_home_manager_configuration
+ ;;
+nixos)
+ update_nixos_configuration
+ ;;
+both)
+ update_nixos_configuration
+ update_home_manager_configuration
+ ;;
esac