nixfiles/switch

39 lines
No EOL
806 B
Bash
Executable file

#!/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
if [ "$(uname)" == "Darwin" ]; then
git add -f hosts/teidesu-osx/arc-setup.nix
function restore {
git restore --staged hosts/teidesu-osx/arc-setup.nix
}
trap restore EXIT
if command -v darwin-rebuild &> /dev/null; then
darwin-rebuild switch --flake . $args $@
else
nix --extra-experimental-features nix-command --extra-experimental-features flakes run nix-darwin -- switch --flake . $args $@
fi
else
sudo nixos-rebuild $cmd --flake . $args $@
fi