-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·42 lines (33 loc) · 925 Bytes
/
deploy.sh
File metadata and controls
executable file
·42 lines (33 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -euo pipefail
# Variables
FLAKE_PATH="."
HOST="centaur"
# Check for required commands
command -v nixos-rebuild >/dev/null 2>&1 || { echo "nixos-rebuild not found."; exit 1; }
# Parse arguments
UPDATE=0
for arg in "$@"; do
if [[ "$arg" == "-up" ]]; then
UPDATE=1
fi
done
# Format Nix files
if command -v nix >/dev/null 2>&1; then
echo "Formatting Nix files with nix fmt..."
nix fmt "$FLAKE_PATH"
fi
# Update flake inputs if -up flag is passed
if [[ $UPDATE -eq 1 ]]; then
echo "Updating flake inputs..."
nix flake update --flake "$FLAKE_PATH"
fi
# Deploy the NixOS configuration
echo "Rebuilding and switching to new configuration..."
sudo nixos-rebuild switch --flake "$FLAKE_PATH#$HOST"
echo "Deployment complete."
# Reload Hyprland configuration
if command -v hyprctl >/dev/null 2>&1; then
echo "Reloading Hyprland configuration..."
hyprctl reload
fi