add min-copy-closure, a minimal nix-copy-closure substitute
This commit is contained in:
parent
67768004ee
commit
30153a2d4e
5 changed files with 65 additions and 0 deletions
|
@ -45,5 +45,6 @@
|
||||||
|
|
||||||
openwrt = callPackage ./openwrt {};
|
openwrt = callPackage ./openwrt {};
|
||||||
|
|
||||||
|
min-copy-closure = callPackage ./min-copy-closure {};
|
||||||
hi = callPackage ./hi {};
|
hi = callPackage ./hi {};
|
||||||
}
|
}
|
||||||
|
|
13
pkgs/min-copy-closure/default.nix
Normal file
13
pkgs/min-copy-closure/default.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
stdenv
|
||||||
|
, nix
|
||||||
|
, cpio
|
||||||
|
}: stdenv.mkDerivation {
|
||||||
|
name = "min-copy-closure";
|
||||||
|
buildInputs = [ nix cpio ];
|
||||||
|
src = ./.;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp min-copy-closure.sh $out/bin/nix-copy-closure
|
||||||
|
'';
|
||||||
|
}
|
2
pkgs/min-copy-closure/min-copy-closure.fnl
Normal file
2
pkgs/min-copy-closure/min-copy-closure.fnl
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
(local ssh (io.popen "
|
40
pkgs/min-copy-closure/min-copy-closure.sh
Executable file
40
pkgs/min-copy-closure/min-copy-closure.sh
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
target_host=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
paths=$(nix-store -q --requisites "$@")
|
||||||
|
needed=""
|
||||||
|
|
||||||
|
coproc remote {
|
||||||
|
ssh -C ${target_host}
|
||||||
|
}
|
||||||
|
|
||||||
|
exec 10>&${remote[1]}
|
||||||
|
|
||||||
|
for p in $paths; do
|
||||||
|
echo "test -e $p && echo skip || echo $p" >&10
|
||||||
|
read n <&${remote[0]}
|
||||||
|
case $n in
|
||||||
|
skip)
|
||||||
|
:
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
needed="${needed} $n"
|
||||||
|
echo Will copy $n
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z "$needed" ; then
|
||||||
|
echo Nothing to copy
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "cd / && cpio -v -i >/dev/console" >&10
|
||||||
|
|
||||||
|
find $needed | cpio -H newc -o >&10
|
||||||
|
|
||||||
|
echo "date" >&10
|
||||||
|
read n <&${remote[0]}
|
||||||
|
echo $n
|
9
pkgs/min-copy-closure/receive.sh
Normal file
9
pkgs/min-copy-closure/receive.sh
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
cd /nix/store
|
||||||
|
while read f ; do
|
||||||
|
test "$f" = "end" && break
|
||||||
|
test -e $f || echo -n $f " "
|
||||||
|
done
|
||||||
|
mkdir -p /tmp/store
|
||||||
|
cd /tmp/store
|
||||||
|
cpio -i
|
Loading…
Reference in a new issue