Move TMPDIR next to NIXREDO_ROOT
parent
870493c34b
commit
52f6a2badf
12
lib.nix
12
lib.nix
|
@ -1,16 +1,14 @@
|
|||
{ lib ? import <nixpkgs/lib> }:
|
||||
let
|
||||
inherit (builtins) length genList pathExists;
|
||||
inherit (builtins) baseNameOf dirOf length genList pathExists;
|
||||
inherit (lib) take splitString concatStringsSep last foldl foldr head
|
||||
tail singleton removePrefix hasSuffix removeSuffix flatten crossLists reverseList;
|
||||
butlast = list: take (length list - 1) list;
|
||||
dirname = path: let _p = (butlast (splitString "/" path)); in if _p != [] then concatStringsSep "/" _p else "./";
|
||||
basename = path: (last (splitString "/" path));
|
||||
|
||||
doFileSuffix = "do";
|
||||
|
||||
genPatterns = path: let
|
||||
fn = basename path;
|
||||
fn = baseNameOf path;
|
||||
in (map (x: "default." + x)
|
||||
(foldr (a: b: let x = (head b); in [ (a + "." + x) ] ++ b)
|
||||
[ doFileSuffix ]
|
||||
|
@ -37,18 +35,18 @@ let
|
|||
in foldl (res: p: if res == "" then if pathExists p then p else res else res) "" pathlist;
|
||||
|
||||
d1 = path: pat: let
|
||||
dir = (dirname pat) + "/";
|
||||
dir = (dirOf pat) + "/";
|
||||
in removePrefix dir path;
|
||||
|
||||
d2 = path: pat: let
|
||||
dir = (dirname pat) + "/";
|
||||
dir = (dirOf pat) + "/";
|
||||
_path = removePrefix dir path;
|
||||
_pat = removeSuffix ".${doFileSuffix}" (removePrefix "${dir}default" pat);
|
||||
_out = removeSuffix _pat _path;
|
||||
in if _out == "" then _path else _out;
|
||||
|
||||
self = {
|
||||
inherit dirname basename searchPath cwd path doFileSuffix whichdo d1 d2;
|
||||
inherit searchPath cwd path doFileSuffix whichdo d1 d2;
|
||||
};
|
||||
|
||||
in self
|
||||
|
|
15
nixredo
15
nixredo
|
@ -4,6 +4,11 @@ exec >&2
|
|||
[ "${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 [ -n "${NIXREDO_ROOT}" ]; then
|
||||
export TMPDIR="${NIXREDO_ROOT}/tmp"
|
||||
mkdir -p "$TMPDIR"
|
||||
fi
|
||||
|
||||
S=$(realpath -s "$S")
|
||||
|
||||
if [ "${NIXREDO_ROOT#$S}" != "${NIXREDO_ROOT}" ]; then
|
||||
|
@ -15,15 +20,15 @@ fi
|
|||
set -e
|
||||
set -- "$1" "$1" "$1.redo.tmp"
|
||||
f=$(realpath -s "$1")
|
||||
rm -f -- "$3"
|
||||
# Work around broken local store support. out-links are not correctly resolved.
|
||||
# We solve gcroots in nixredo-gc
|
||||
out=$(nix -vL --show-trace build ${NIXREDO_ROOT:+--store "$NIXREDO_ROOT"} \
|
||||
--option auto-optimise-store true --option substituters daemon \
|
||||
--option keep-failed true --option keep-outputs true \
|
||||
--impure --json --no-link \
|
||||
--expr " import @buildernix@ { lib = import @libnix@ {}; root =\"$S\"; filter = [ \"$filter\" ]; } \"$f\"" |
|
||||
--expr " import @buildernix@ { lib = import @libnix@ {}; root =\"$S\"; filter = [ \"$filter\" \"$f\" ]; } \"$f\"" |
|
||||
@jq@ -r '.[0].outputs.out')
|
||||
[ -n "$out" ] || exit 127
|
||||
rm -rf "$3"
|
||||
ln -s "${NIXREDO_ROOT+$NIXREDO_ROOT}$out" "$3"
|
||||
# ln "${NIXREDO_ROOT+$NIXREDO_ROOT/}$out" "$3"
|
||||
# chmod +w "$3"
|
||||
# touch "$3"
|
||||
mv "$3" "$1"
|
||||
|
|
Loading…
Reference in New Issue