#!/usr/bin/env bash REAL_BASE_DIR=$( dirname $( realpath "$0" ) ) # Wrapper for nixos-rebuild operations, which act locally. # Takes the following arguments supplied as environment variables. # HOST: The host as defined in nixosConfigurations. # OPERATION: The nixos-rebuild operation to execute. Can be one of: # build, build-vm, build-vm-with-bootloader # All operations are as defined in the nixos-rebuild man page. if [ -z $HOST ]; then $REAL_BASE_DIR/../helper/msg_error.sh "\ Internal Error: No host given. A host needs to be provided via the HOST environment variable." exit 1 fi if [ -z $OPERATION ]; then $REAL_BASE_DIR/../helper/msg_error.sh "\ Internal Error: No operation given. An operation needs to be provided via the OPERATION environment variable." exit 1 fi case $OPERATION in build|build-vm|build-vm-with-bootloader) ;; *) $REAL_BASE_DIR/../helper/msg_error.sh "\ Internal Error: No valid operation given. The operation provided via the OPERATION environment variable needs to be one of: build, build-vm, build-vm-with-bootloader." exit 1 ;; esac set -e $REAL_BASE_DIR/../helper/msg_info.sh "\ Running nixos-rebuild $OPERATION for $HOST..." nixos-rebuild "$OPERATION" --flake ".#$HOST"