nixos-rebuild: Use old-style nix command when building flake on a remote host
This commit is contained in:
parent
456aa2db49
commit
fa827f3f62
@ -247,9 +247,7 @@ nixFlakeBuild() {
|
|||||||
local drv="$(nix "${flakeFlags[@]}" eval --raw "${attr}.drvPath" "${evalArgs[@]}" "${extraBuildArgs[@]}")"
|
local drv="$(nix "${flakeFlags[@]}" eval --raw "${attr}.drvPath" "${evalArgs[@]}" "${extraBuildArgs[@]}")"
|
||||||
if [ -a "$drv" ]; then
|
if [ -a "$drv" ]; then
|
||||||
NIX_SSHOPTS=$SSHOPTS nix "${flakeFlags[@]}" copy --derivation --to "ssh://$buildHost" "$drv"
|
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-store -r "$drv" "${buildArgs[@]}"
|
||||||
buildHostCmd nix --experimental-features "'nix-command flakes'" build "${buildArgs[@]}" --out-link "${tmpDir}/result" "$drv"
|
|
||||||
buildHostCmd readlink -f "${tmpDir}/result"
|
|
||||||
else
|
else
|
||||||
echo "nix eval failed"
|
echo "nix eval failed"
|
||||||
exit 1
|
exit 1
|
||||||
@ -358,14 +356,8 @@ fi
|
|||||||
|
|
||||||
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
|
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
|
||||||
SSHOPTS="$NIX_SSHOPTS -o ControlMaster=auto -o ControlPath=$tmpDir/ssh-%n -o ControlPersist=60"
|
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() {
|
cleanup() {
|
||||||
if [ -n "$buildHost" -a -n "$flake" ]; then
|
|
||||||
buildHostCmd rm -rf "$tmpDir"
|
|
||||||
fi
|
|
||||||
for ctrl in "$tmpDir"/ssh-*; do
|
for ctrl in "$tmpDir"/ssh-*; do
|
||||||
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true
|
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user