43 lines
1.4 KiB
Bash
Executable File
43 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# NixOS rebuild script for flake-based configuration
|
|
# Usage: ./rebuild.sh [switch|build|test]
|
|
|
|
set -e
|
|
|
|
# Check if experimental features are enabled
|
|
if ! nix --version | grep -q "experimental-features"; then
|
|
echo "Warning: Nix experimental features may not be enabled."
|
|
echo "Consider adding 'experimental-features = nix-command flakes' to /etc/nix/nix.conf"
|
|
fi
|
|
|
|
ACTION=${1:-switch}
|
|
|
|
case $ACTION in
|
|
switch)
|
|
echo "Building and switching to new configuration..."
|
|
sudo nixos-rebuild switch --flake .#xps-nixos
|
|
;;
|
|
build)
|
|
echo "Building configuration without switching..."
|
|
sudo nixos-rebuild build --flake .#xps-nixos
|
|
;;
|
|
test)
|
|
echo "Building configuration for testing..."
|
|
sudo nixos-rebuild build --flake .#xps-nixos
|
|
echo "Configuration built successfully. Run 'sudo nixos-rebuild switch' to apply it."
|
|
;;
|
|
update)
|
|
echo "Updating flake inputs..."
|
|
nix flake update --extra-experimental-features nix-command --extra-experimental-features flakes
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [switch|build|test|update]"
|
|
echo " switch: Build and switch to new configuration (default)"
|
|
echo " build: Build configuration without switching"
|
|
echo " test: Build configuration for testing"
|
|
echo " update: Update flake inputs"
|
|
exit 1
|
|
;;
|
|
esac
|