1
0
Fork 0

Add filtered src tree to non-nix redo targets

master
Michael Raitza 2021-02-17 10:43:26 +01:00
parent 2e6ec04d74
commit bc0989e0b7
2 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
buildArgs@{ lib ? import ./lib.nix {}, nixpkgs ? <nixpkgs>, pkgs ? import nixpkgs {} }: buildArgs@{ lib ? import ./lib.nix {}, nixpkgs ? <nixpkgs>, pkgs ? import nixpkgs {}, root, filter ? [] }:
let let
inherit (lib) searchPath whichdo d1 d2; inherit (lib) searchPath whichdo d1 d2;
@ -22,6 +22,9 @@ let
in if imported.success in if imported.success
then imported.value then imported.value
else { else {
src = filterSource
(path: type: type != "directory" || (baseNameOf path != ".git" && (all (x: trace x path != x) filter)))
(/. + root);
builder = '' builder = ''
#!/bin/sh #!/bin/sh
set -e set -e

12
nixredo
View File

@ -1,14 +1,24 @@
#!/bin/sh #!/bin/sh
exec >&2 exec >&2
[ "${S+x}" = x ] || { printf "Set S to the root location of your source tree\n"; exit 127; }
[ "${NIXREDO_ROOT-x}" != x ] || { printf "Set NIXREDO_ROOT. Set empty to use global nix store\n"; exit 127; } [ "${NIXREDO_ROOT-x}" != x ] || { printf "Set NIXREDO_ROOT. Set empty to use global nix store\n"; exit 127; }
if [ $# -eq 0 ]; then set -- all; fi if [ $# -eq 0 ]; then set -- all; fi
S=$(realpath -s "$S")
if [ "${NIXREDO_ROOT#$S}" != "${NIXREDO_ROOT}" ]; then
filter=$(realpath -s "${NIXREDO_ROOT}")
else
filter=
fi
set -e set -e
set -- "$1" "$1" "$1.redo.tmp" set -- "$1" "$1" "$1.redo.tmp"
f=$(realpath -s "$1") f=$(realpath -s "$1")
out=$(nix -vL --show-trace build ${NIXREDO_ROOT:+--store "$NIXREDO_ROOT"} \ out=$(nix -vL --show-trace build ${NIXREDO_ROOT:+--store "$NIXREDO_ROOT"} \
--option auto-optimise-store true --option substituters daemon \ --option auto-optimise-store true --option substituters daemon \
--impure --json --no-link \ --impure --json --no-link \
--expr " import @buildernix@ { lib = import @libnix@ {}; } \"$f\"" | --expr " import @buildernix@ { lib = import @libnix@ {}; root =\"$S\"; filter = [ \"$filter\" ]; } \"$f\"" |
@jq@ -r '.[0].outputs.out') @jq@ -r '.[0].outputs.out')
[ -n "$out" ] || exit 127 [ -n "$out" ] || exit 127
rm -rf "$3" rm -rf "$3"