Created
December 26, 2017 14:56
-
-
Save grahamc/aed128bbb5450c29fc6a29b793eb0886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
set -o pipefail | |
buildHost=root@yourremotebuilder | |
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX) | |
SSHOPTS="${NIX_SSHOPTS:-} -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60" | |
cleanup() { | |
for ctrl in "$tmpDir"/ssh-*; do | |
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true | |
done | |
rm -rf "$tmpDir" | |
} | |
trap cleanup EXIT | |
set -eux | |
drv=$(nix-instantiate ./your-thing-to-build.nix -A foobar) | |
NIX_SSHOPTS=$SSHOPTS nix-copy-closure --to "$buildHost" "$drv" | |
out=$(ssh $SSHOPTS "$buildHost" "NIX_REMOTE=daemon nix-store -r '$drv' -j 5") | |
nix-copy-closure --from "$buildHost" "$out" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment