refactor(rebuild): make rebuild script look cleaner
This commit is contained in:
parent
2c3fe71750
commit
94f9496604
1 changed files with 8 additions and 12 deletions
|
@ -2,8 +2,12 @@
|
||||||
|
|
||||||
rebuild_remote() {
|
rebuild_remote() {
|
||||||
hostname=$1
|
hostname=$1
|
||||||
builder=localhost
|
builder="nemesis"
|
||||||
nixos-rebuild switch --flake .#"${hostname}" --target-host "$(whoami)"@"${hostname}" --build-host "${builder}" --use-remote-sudo
|
if [[ "${hostname}" == "${builder}" ]]; then
|
||||||
|
nh os switch .
|
||||||
|
else
|
||||||
|
nixos-rebuild switch --flake .#"${hostname}" --target-host "$(whoami)"@"${hostname}" --build-host "${builder}" --use-remote-sudo
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -11,23 +15,15 @@ main() {
|
||||||
echo "Only one argument is allowed. Pass in a hostname or all."
|
echo "Only one argument is allowed. Pass in a hostname or all."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ $# -lt 1 ]]; then
|
elif [[ $# -lt 1 ]]; then
|
||||||
nh os switch .
|
rebuild_remote "$HOSTNAME"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
nemesis)
|
|
||||||
if [[ $HOSTNAME == "nemesis" ]]; then
|
|
||||||
nh os switch .
|
|
||||||
else
|
|
||||||
rebuild_remote nemesis
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
all)
|
all)
|
||||||
nh os switch . &&
|
rebuild_remote nemesis &&
|
||||||
rebuild_remote apollo
|
rebuild_remote apollo
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue