#!/usr/bin/env bash args="" cmd="switch" if [ "$1" == "debug" ]; then args="--show-trace -v -L" shift fi if [ "$1" == "build" ]; then cmd="build" shift fi if [ "$1" == "dry-activate" ]; then cmd="dry-activate" shift fi if [ "$1" == "boot" ]; then cmd="boot" shift fi flake="." if [ ! -z ${NIX_HOSTNAME+x} ]; then flake=".#$NIX_HOSTNAME" fi if [ "$(uname)" == "Darwin" ]; then if [ $(hostname) == "teidesu-osx" ]; then git add -f hosts/teidesu-osx/arc-setup.nix function restore { git restore --staged hosts/teidesu-osx/arc-setup.nix } trap restore EXIT fi if command -v darwin-rebuild &> /dev/null; then darwin-rebuild switch --flake $flake $args $@ else nix --extra-experimental-features nix-command --extra-experimental-features flakes run nix-darwin -- switch --flake $flake $args $@ fi else sudo nixos-rebuild $cmd --flake $flake $args $@ fi