Skip to content

Instantly share code, notes, and snippets.

@zimbatm
Created December 22, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zimbatm/217bc9326c0da37ae8089cc1b797f557 to your computer and use it in GitHub Desktop.
Save zimbatm/217bc9326c0da37ae8089cc1b797f557 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
targetHost=$(basename "$(dirname "$(readlink -f "$0")")")
hostname=$(< /proc/sys/kernel/hostname)
args=(
--flake ".#$targetHost"
--use-remote-sudo
)
if [[ "$hostname" != "$targetHost" ]]; then
args+=(
--build-host localhost
--target-host "${targetHost}.zt"
)
fi
export SUDO_USER=1
exec nixos-rebuild "${args[@]}" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment