aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-21 03:59:06 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:28 +0530
commit9096fc6607a196f48df1da1dbe9b3f2b0908d76d (patch)
tree5f8194416d0fc7b70f42e8dc237c22c630493b34
parent5725301fd66c243dd21de23a49602209bcf8fa80 (diff)
downloadhome-manager-config-9096fc6607a196f48df1da1dbe9b3f2b0908d76d.tar.gz
home-manager-config-9096fc6607a196f48df1da1dbe9b3f2b0908d76d.zip
scripts: added nix-update script
- nix-update script can be used to automatically update both home-manager and nixos, either just update the flake inputs or recompute/rebuild the entire configuration with the updated derivations - fixed fzf unknown option error that appeared in the newer versions
-rw-r--r--flake.lock20
-rw-r--r--modules/scripts/default.nix1
-rw-r--r--modules/scripts/nix-update/default.nix25
-rw-r--r--modules/scripts/nix-update/script.sh110
-rw-r--r--modules/terminal/fzf/default.nix8
5 files changed, 150 insertions, 14 deletions
diff --git a/flake.lock b/flake.lock
index bd44c33..371f42e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -84,11 +84,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
- "lastModified": 1787143951,
- "narHash": "sha256-XSGBBYbNhmXBruOR3abM5ffctdKr5XiEw44V1njJi5k=",
+ "lastModified": 1787244866,
+ "narHash": "sha256-yRtH4Vs49zZE+u3CR1iBs6jTUp1o/4SdCyshZ5+ojbw=",
"owner": "cachix",
"repo": "devenv",
- "rev": "57846ab226555be38118ed4d83a1419a99244ba6",
+ "rev": "4b10b32036245a13efdb0d77d69d6990d1c8a3f5",
"type": "github"
},
"original": {
@@ -219,11 +219,11 @@
]
},
"locked": {
- "lastModified": 1787152495,
- "narHash": "sha256-zWjKwcMt0h+FIr0lgn0PWVN/24+IfNf4RhfL6hId2b4=",
+ "lastModified": 1787176219,
+ "narHash": "sha256-djoRr6jBpe35q/0JwAvXpFXg1Ktf+X54NU2RLR7wnHw=",
"owner": "nix-community",
"repo": "home-manager",
- "rev": "3c3ede6ad886a6d9b0938ef19112523118fe62c2",
+ "rev": "c53d643b3737e2fcd04e6cb3b3580ef50b2087a0",
"type": "github"
},
"original": {
@@ -301,11 +301,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1787111413,
- "narHash": "sha256-93GX5Q/npwBE92xpHlktxgGztuIP/2kwOMukz+qyJBk=",
- "rev": "afe3d8ac4395617bdcdac9f188ac8717a062e014",
+ "lastModified": 1787172299,
+ "narHash": "sha256-LS/aXgJh+/1UgtrOxdS5Wum/PgmQYa1AMFZHdH+xGyo=",
+ "rev": "07e1d92cdc0ed416cfa11ff3ca40d17e61cfba7a",
"type": "tarball",
- "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1057999.afe3d8ac4395/nixexprs.tar.xz"
+ "url": "https://releases.nixos.org/nixpkgs/nixpkgs-26.11pre1058374.07e1d92cdc0e/nixexprs.tar.xz"
},
"original": {
"id": "nixpkgs",
diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix
index caa3af7..ae18329 100644
--- a/modules/scripts/default.nix
+++ b/modules/scripts/default.nix
@@ -8,6 +8,7 @@
./deep-clean
./gopass-ssh-load
./gpg-backup
+ ./nix-update
./neomutt-sync
./screen-recording
./system-monitor
diff --git a/modules/scripts/nix-update/default.nix b/modules/scripts/nix-update/default.nix
new file mode 100644
index 0000000..787265d
--- /dev/null
+++ b/modules/scripts/nix-update/default.nix
@@ -0,0 +1,25 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ inherit ((import ../lib.nix { inherit lib pkgs; })) mkScriptModule;
+ base = mkScriptModule {
+ name = "nix-update";
+ path = ./script.sh;
+ description = "Update NixOS and/or Home Manager flake configuration\nRuns nix flake update and rebuilds the system";
+ deps = [
+ pkgs.git
+ pkgs.nix
+ config.programs.home-manager.package
+ pkgs.bash
+ ];
+ inherit config;
+ };
+in
+{
+ options = base.options;
+ config = base.moduleConfig;
+}
diff --git a/modules/scripts/nix-update/script.sh b/modules/scripts/nix-update/script.sh
new file mode 100644
index 0000000..7f2b6d0
--- /dev/null
+++ b/modules/scripts/nix-update/script.sh
@@ -0,0 +1,110 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+HM_DIR="$HOME/.config/home-manager"
+NIXOS_DIR="/etc/nixos"
+FLAKE_ONLY=false
+TARGET=""
+
+usage() {
+ echo "Usage: nix-update <home-manager|nixos|both> [--flake-only]"
+ echo ""
+ echo "Options:"
+ echo " home-manager Update and switch home-manager configuration"
+ echo " nixos Update and switch NixOS configuration"
+ echo " both Update and switch both configurations"
+ echo ""
+ echo "Flags:"
+ echo " --flake-only Only run nix flake update, skip switch commands"
+ exit 1
+}
+
+parse_args() {
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ home-manager | nixos | both)
+ if [[ -n "$TARGET" ]]; then
+ echo "Error: only one target allowed"
+ usage
+ fi
+ TARGET="$1"
+ shift
+ ;;
+ --flake-only)
+ FLAKE_ONLY=true
+ shift
+ ;;
+ -h | --help)
+ usage
+ ;;
+ *)
+ echo "Error: unknown option '$1'"
+ usage
+ ;;
+ esac
+ done
+
+ if [[ -z "$TARGET" ]]; then
+ echo "Error: no target specified"
+ usage
+ fi
+}
+
+update_home_manager() {
+ echo "==> Updating home-manager..."
+ cd "$HM_DIR"
+
+ echo " Staging modules/private..."
+ git add modules/private -f
+
+ echo " Running nix flake update..."
+ nix flake update
+
+ if [[ "$FLAKE_ONLY" == 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
+
+ echo "==> home-manager update complete"
+}
+
+update_nixos() {
+ echo "==> Updating NixOS..."
+ sudo -v
+ cd "$NIXOS_DIR"
+
+ echo " Staging hardware-configuration.nix..."
+ git add hardware-configuration.nix -f
+
+ echo " Running nix flake update..."
+ nix flake update
+
+ if [[ "$FLAKE_ONLY" == false ]]; then
+ echo " Running nixos-rebuild switch..."
+ sudo nixos-rebuild switch
+ fi
+
+ echo " Unstaging hardware-configuration.nix..."
+ git rm --cached hardware-configuration.nix
+
+ echo "==> NixOS update complete"
+}
+
+parse_args "$@"
+
+case "$TARGET" in
+ home-manager)
+ update_home_manager
+ ;;
+ nixos)
+ update_nixos
+ ;;
+ both)
+ update_nixos
+ update_home_manager
+ ;;
+esac
diff --git a/modules/terminal/fzf/default.nix b/modules/terminal/fzf/default.nix
index c59e039..a4820b8 100644
--- a/modules/terminal/fzf/default.nix
+++ b/modules/terminal/fzf/default.nix
@@ -29,10 +29,10 @@
defaultOptions = [
"--height 100%"
"--layout=reverse"
- ''--pointer=\" \"''
- ''--header=\" \"''
- ''--prompt=\" \"''
- ''--marker=\"✓ \"''
+ "--pointer=\"󰠁 \""
+ "--header=\" \""
+ "--prompt=\"󰎕 \""
+ "--marker=\"✓ \""
"--border=none"
"--cycle"
"--no-info"