diff options
author | Michael Raskin <7c6f434c@mail.ru> | 2008-02-27T21·26+0000 |
---|---|---|
committer | Michael Raskin <7c6f434c@mail.ru> | 2008-02-27T21·26+0000 |
commit | 11d512e7a812e750deccf616b461876fb0a342c2 (patch) | |
tree | 4ae3cf7008df48569ff597e6fbe177b118f0669d /scripts | |
parent | 0a84137c4512e0a31802e94de7795e04f8ee2198 (diff) |
Added nix-reduce-build. You point it to some path you want to build and it fetches whatever it can from specified computers via nix-copy-closure. NOTE: You do want to set up RSA keys or ssh-agent or something... You really do want it. It will run separate ssh instances insane number of times.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.am | 5 | ||||
-rw-r--r-- | scripts/nix-reduce-build.in | 68 |
2 files changed, 71 insertions, 2 deletions
diff --git a/scripts/Makefile.am b/scripts/Makefile.am index e79db31b7c22..50975ab274b1 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -2,7 +2,7 @@ bin_SCRIPTS = nix-collect-garbage \ nix-pull nix-push nix-prefetch-url \ nix-install-package nix-channel nix-build \ nix-pack-closure nix-unpack-closure \ - nix-copy-closure + nix-copy-closure nix-reduce-build noinst_SCRIPTS = nix-profile.sh generate-patches.pl \ find-runtime-roots.pl build-remote.pl @@ -35,4 +35,5 @@ EXTRA_DIST = nix-collect-garbage.in \ nix-pack-closure.in nix-unpack-closure.in \ nix-copy-closure.in \ find-runtime-roots.pl.in \ - build-remote.pl.in + build-remote.pl.in \ + nix-reduce-build.in diff --git a/scripts/nix-reduce-build.in b/scripts/nix-reduce-build.in new file mode 100644 index 000000000000..6d7f8bdd7f63 --- /dev/null +++ b/scripts/nix-reduce-build.in @@ -0,0 +1,68 @@ +#! @shell@ + +WORKING_DIRECTORY=$(mktemp -d "${TMPDIR:-/tmp}"/nix-reduce-build-XXXXXX); +cd "$WORKING_DIRECTORY"; + +if test -z "$1" ; then + echo 'nix-reduce-build (paths or Nix expressions) -- (logins at remote computers)' >&2 + echo As in: >&2 + echo nix-reduce-build /etc/nixos/nixos -- user@somewhere.nowhere.example.org >&2 + exit; +fi; + +while ! test "$1" = "--" || test "$1" = "" ; do + echo "$1" >> initial; >&2 + shift; +done +shift; +echo Will work on $(cat initial | wc -l) targets. >&2 + +while read ; do + case "$REPLY" in + ${NIX_STORE_PATH:-/nix/store}/*) + echo "$REPLY" >> paths; >&2 + ;; + *) + nix-instantiate "$REPLY" >> paths; + ;; + esac; +done < initial; +echo Proceeding $(cat paths | wc -l) paths. >&2 + +while read; do + case "$REPLY" in + *.drv) + echo "$REPLY" >> derivers; >&2 + ;; + *) + nix-store --query --deriver "$REPLY" >>derivers; + ;; + esac; +done < paths; +echo Found $(cat derivers | wc -l) derivers. >&2 + +cat derivers | xargs nix-store --query -R > derivers-closure; +echo Proceeding at most $(cat derivers-closure | wc -l) derivers. >&2 + +cat derivers-closure | egrep '[.]drv$' | xargs nix-store --query --outputs > wanted-paths; +cat derivers-closure | egrep -v '[.]drv$' >> wanted-paths; +echo Prepared $(cat wanted-paths | wc -l) paths to get. >&2 + +cat wanted-paths | xargs nix-store --check-validity --print-invalid > needed-paths; +echo We need $(cat needed-paths | wc -l) paths. >&2 + +if test -z "$1" ; then + cat needed-paths; +fi; + +for i in "$@"; do + cat needed-paths | while read; do + nix-copy-closure --from "$i" --gzip "$REPLY" </dev/null || true; + done; + mv needed-paths wanted-paths; + cat wanted-paths | xargs nix-store --check-validity --print-invalid > needed-paths; + echo We still need $(cat needed-paths | wc -l) paths. >&2 +done; + +cd / +rm -r "$WORKING_DIRECTORY" |