35 lines
729 B
Bash
Executable File
35 lines
729 B
Bash
Executable File
#!/usr/bin/env bash
|
||
|
||
set -euo pipefail
|
||
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m'
|
||
|
||
print_info() {
|
||
echo -e "${BLUE}ℹ ${NC} $1"
|
||
}
|
||
|
||
print_success() {
|
||
echo -e "${GREEN}✓${NC} $1"
|
||
}
|
||
|
||
HOSTNAME="${1:-$(scutil --get LocalHostName 2>/dev/null || hostname -s)}"
|
||
|
||
print_info "Building and switching configuration for $HOSTNAME"
|
||
|
||
# Build
|
||
print_info "Building configuration..."
|
||
nix build ".#darwinConfigurations.$HOSTNAME.system" --show-trace "${@:2}"
|
||
|
||
# Switch
|
||
print_info "Switching to new configuration..."
|
||
./result/sw/bin/darwin-rebuild switch --flake ".#$HOSTNAME" "${@:2}"
|
||
|
||
if [[ -L ./result ]]; then
|
||
unlink ./result
|
||
fi
|
||
|
||
print_success "Build and switch completed successfully" |