Compare commits

...

3 Commits

Author SHA1 Message Date
6fb279eca0 Allow calling direnv-cache from subdirectories of $DIRENV_DIR 2020-02-03 11:33:25 +01:00
0c8db23a3b Prefer local nix build 2020-01-23 09:54:42 +01:00
14526f5419 Make term-test dependency optional
checkPhase still requires term-test

Closes #1
2019-12-29 10:55:04 +01:00
2 changed files with 23 additions and 3 deletions

View File

@@ -1,4 +1,9 @@
{ stdenv, direnv, term-test }: { stdenv
, direnv
, term-test ? null
, doCheck ? true
}:
assert doCheck -> term-test != null;
stdenv.mkDerivation { stdenv.mkDerivation {
name = "direnv-cache"; name = "direnv-cache";
@@ -8,6 +13,7 @@ stdenv.mkDerivation {
make install PREFIX=$out make install PREFIX=$out
''; '';
checkInputs = [ term-test ]; checkInputs = [ term-test ];
doCheck = true; inherit doCheck;
passthru = { direnvrc = ./direnvrc; }; passthru = { direnvrc = ./direnvrc; };
preferLocalBuild = true;
} }

View File

@@ -70,9 +70,23 @@ getCacheFilePath() {
echo "${cacheDir}/$(pwd | sha1sum | tr -d ' -')" echo "${cacheDir}/$(pwd | sha1sum | tr -d ' -')"
} }
switchToDirenvDir() {
# Find directory that contains the current .envrc. Allows direnv-cache to
# be called from subdirectories.
wd="$(pwd)"
if [[ -n $DIRENV_DIR ]]; then
wd="${DIRENV_DIR#-}"
fi
cd "$wd"
}
cmd="$1" cmd="$1"
if ! [[ -e .envrc ]]; then switchToDirenvDir
if ! [[ -e ".envrc" ]]; then
echo "Error, no .envrc found in current directory" echo "Error, no .envrc found in current directory"
exit 1 exit 1
fi fi