mirror of
https://github.com/Death916/nixconfig.git
synced 2026-04-10 02:54:39 -07:00
nh script update
This commit is contained in:
parent
945b913d83
commit
cee54def46
3 changed files with 23 additions and 11 deletions
|
|
@ -22,4 +22,8 @@
|
||||||
systemctl-tui
|
systemctl-tui
|
||||||
gemini-cli
|
gemini-cli
|
||||||
];
|
];
|
||||||
|
|
||||||
|
programs.bash.shellAliases = {
|
||||||
|
nh-push = "/home/death916/nixconfig/scripts/nh-push";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,7 @@ in
|
||||||
homelab = "tailscale ssh homelab";
|
homelab = "tailscale ssh homelab";
|
||||||
urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
|
urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
|
||||||
urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
|
urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
|
||||||
|
nh-push = "/home/death916/Documents/nix-config/scripts/nh-push";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,27 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#!/usr/bin/env bash
|
# A wrapper for 'nh' that runs 'git pull' and 'git push' on success.
|
||||||
|
|
||||||
# A wrapper for 'nh' that runs 'git push' on success.
|
|
||||||
|
|
||||||
# Exit immediately if a command exits with a non-zero status.
|
# Exit immediately if a command exits with a non-zero status.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Run the 'nh' command with all arguments passed to the script.
|
# Determine the absolute path of the directory containing this script.
|
||||||
# The flake path is hardcoded for convenience.
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
nh os switch "/home/death916/nixconfig#$@"
|
# The repository root is one level above the scripts directory.
|
||||||
|
REPO_ROOT="$SCRIPT_DIR/.."
|
||||||
|
|
||||||
# If the above command was successful, proceed to the next lines.
|
# --- Git Operations ---
|
||||||
|
echo "Pulling latest changes from git..."
|
||||||
|
# Use -C to specify the repository path for git operations.
|
||||||
|
git -C "$REPO_ROOT" pull
|
||||||
|
|
||||||
|
# --- NixOS Build ---
|
||||||
|
echo "Building NixOS configuration..."
|
||||||
|
# Use --flake to specify the flake path.
|
||||||
|
nh os switch --flake "$REPO_ROOT#nixosConfigurations.$@"
|
||||||
|
|
||||||
|
# --- Git Push on Success ---
|
||||||
echo "NixOS rebuild successful. Pushing to remote..."
|
echo "NixOS rebuild successful. Pushing to remote..."
|
||||||
|
git -C "$REPO_ROOT" push
|
||||||
|
|
||||||
# Push the configuration to the git remote.
|
echo "Push complete."
|
||||||
git -C /home/death916/nixconfig push
|
|
||||||
|
|
||||||
echo "Push complete."
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue