nixfiles/switch

39 lines
806 B
Text
Raw Normal View History

2024-01-08 07:49:51 +03:00
#!/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
2024-03-03 06:32:03 +03:00
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
2024-03-03 06:32:03 +03:00
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