fix(nixos): avoid redundant deploy closure transfers #51
@@ -34,20 +34,26 @@ if test (count $system_path) -ne 1
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set closure_paths (nix-store -qR $system_path)
|
||||||
|
or begin
|
||||||
|
echo "deploy-to: closure query failed for $host" >&2
|
||||||
|
return $status
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "deploy-to: checking which closure paths $host is missing" >&2
|
||||||
|
set missing_paths (printf '%s\n' $closure_paths | ssh $host 'xargs -r nix-store --check-validity --print-invalid')
|
||||||
|
or begin
|
||||||
|
echo "deploy-to: remote closure check failed for $host" >&2
|
||||||
|
return $status
|
||||||
|
end
|
||||||
|
|
||||||
|
if test (count $missing_paths) -gt 0
|
||||||
set nar_file (mktemp --suffix=.nar)
|
set nar_file (mktemp --suffix=.nar)
|
||||||
or return $status
|
or return $status
|
||||||
set remote_nar "/tmp/deploy-to-$host-"(date +%s)"-$fish_pid.nar"
|
set remote_nar "/tmp/deploy-to-$host-"(date +%s)"-$fish_pid.nar"
|
||||||
|
|
||||||
set closure_paths (nix-store -qR $system_path)
|
echo "deploy-to: exporting "(count $missing_paths)" missing closure paths for $system_path" >&2
|
||||||
or begin
|
nix-store --export $missing_paths >$nar_file
|
||||||
set query_status $status
|
|
||||||
rm -f $nar_file
|
|
||||||
echo "deploy-to: closure query failed for $host" >&2
|
|
||||||
return $query_status
|
|
||||||
end
|
|
||||||
|
|
||||||
echo "deploy-to: exporting closure for $system_path" >&2
|
|
||||||
nix-store --export $closure_paths >$nar_file
|
|
||||||
or begin
|
or begin
|
||||||
set export_status $status
|
set export_status $status
|
||||||
rm -f $nar_file
|
rm -f $nar_file
|
||||||
@@ -70,6 +76,9 @@ or begin
|
|||||||
echo "deploy-to: closure import failed for $host" >&2
|
echo "deploy-to: closure import failed for $host" >&2
|
||||||
return $status
|
return $status
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
echo "deploy-to: $host already has the full closure for $system_path" >&2
|
||||||
|
end
|
||||||
|
|
||||||
echo "deploy-to: activating $system_path on $host" >&2
|
echo "deploy-to: activating $system_path on $host" >&2
|
||||||
ssh -t $host sudo "$system_path/bin/switch-to-configuration" switch
|
ssh -t $host sudo "$system_path/bin/switch-to-configuration" switch
|
||||||
|
|||||||
Reference in New Issue
Block a user