init
init
This commit is contained in:
@@ -5,19 +5,37 @@ YELLOW='\033[1;33m'
|
||||
RED='\033[1;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
SYSTEM_TYPE="aarch64-darwin"
|
||||
FLAKE_SYSTEM="darwinConfigurations.${SYSTEM_TYPE}.system"
|
||||
# Determine machine name from first argument or hostname
|
||||
if [ $# -gt 0 ]; then
|
||||
MACHINE_NAME="$1"
|
||||
shift # Remove machine name from arguments
|
||||
else
|
||||
MACHINE_NAME=$(hostname | cut -d'.' -f1)
|
||||
fi
|
||||
|
||||
# Validate machine name
|
||||
if [ ! -d "hosts/darwin/$MACHINE_NAME" ]; then
|
||||
echo "${RED}Error: Machine configuration '$MACHINE_NAME' not found in hosts/darwin/${NC}"
|
||||
echo "${YELLOW}Available machines:${NC}"
|
||||
ls -1 hosts/darwin/ | grep -v "default.nix\|shared.nix" || echo " No machine configurations found"
|
||||
echo ""
|
||||
echo "${YELLOW}Usage: $0 [machine-name] [additional-nix-args]${NC}"
|
||||
echo " If no machine name is provided, uses current hostname: $(hostname | cut -d'.' -f1)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FLAKE_SYSTEM="darwinConfigurations.${MACHINE_NAME}.system"
|
||||
|
||||
export NIXPKGS_ALLOW_UNFREE=1
|
||||
|
||||
echo "${YELLOW}Starting build...${NC}"
|
||||
nix --extra-experimental-features 'nix-command flakes' build .#$FLAKE_SYSTEM $@
|
||||
echo "${YELLOW}Building configuration for machine: ${MACHINE_NAME}${NC}"
|
||||
nix --extra-experimental-features 'nix-command flakes' build .#$FLAKE_SYSTEM "$@"
|
||||
|
||||
echo "${YELLOW}Switching to new generation...${NC}"
|
||||
# See https://github.com/nix-darwin/nix-darwin/issues/1457 on why we need sudo
|
||||
sudo ./result/sw/bin/darwin-rebuild switch --flake .#${SYSTEM_TYPE} $@
|
||||
sudo ./result/sw/bin/darwin-rebuild switch --flake .#${MACHINE_NAME}
|
||||
|
||||
echo "${YELLOW}Cleaning up...${NC}"
|
||||
unlink ./result
|
||||
|
||||
echo "${GREEN}Switch to new generation complete!${NC}"
|
||||
echo "${GREEN}Switch to new generation complete for ${MACHINE_NAME}!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user