nixos-rebuild: Use old-style nix command when building flake on a remote host

This commit is contained in:
Charlotte Van Petegem 2021-04-16 12:42:26 +02:00
parent 456aa2db49
commit fa827f3f62
No known key found for this signature in database
GPG Key ID: 019E764B7184435A
1 changed files with 1 additions and 9 deletions

View File

@ -247,9 +247,7 @@ nixFlakeBuild() {
local drv="$(nix "${flakeFlags[@]}" eval --raw "${attr}.drvPath" "${evalArgs[@]}" "${extraBuildArgs[@]}")"
if [ -a "$drv" ]; then
NIX_SSHOPTS=$SSHOPTS nix "${flakeFlags[@]}" copy --derivation --to "ssh://$buildHost" "$drv"
# The 'nix-command flakes' part in "${flakeFlags[@]}" is seen as two separate args over SSH
buildHostCmd nix --experimental-features "'nix-command flakes'" build "${buildArgs[@]}" --out-link "${tmpDir}/result" "$drv"
buildHostCmd readlink -f "${tmpDir}/result"
buildHostCmd nix-store -r "$drv" "${buildArgs[@]}"
else
echo "nix eval failed"
exit 1
@ -358,14 +356,8 @@ fi
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
SSHOPTS="$NIX_SSHOPTS -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60"
if [ -n "$buildHost" -a -n "$flake" ]; then
buildHostCmd mkdir -p "$tmpDir"
fi
cleanup() {
if [ -n "$buildHost" -a -n "$flake" ]; then
buildHostCmd rm -rf "$tmpDir"
fi
for ctrl in "$tmpDir"/ssh-*; do
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true
done