3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/misc/direnv/default.nix

62 lines
1.7 KiB
Nix
Raw Normal View History

2020-08-10 23:27:38 +01:00
{ stdenv, fetchFromGitHub, buildGoModule, bash, fish, zsh }:
2013-11-17 14:00:12 +00:00
buildGoModule rec {
pname = "direnv";
2020-12-11 15:19:04 +00:00
version = "2.25.1";
vendorSha256 = null;
2016-03-27 15:37:07 +01:00
2016-07-03 16:55:51 +01:00
src = fetchFromGitHub {
owner = "direnv";
repo = "direnv";
rev = "v${version}";
2020-12-11 15:19:04 +00:00
sha256 = "0bwr7zdzjm5p6bjyzafc2n57y83f0pv2bmj99rhi8f94hhfydlsf";
2013-11-17 14:00:12 +00:00
};
2018-11-22 21:25:05 +00:00
# we have no bash at the moment for windows
BASH_PATH =
stdenv.lib.optionalString (!stdenv.hostPlatform.isWindows)
"${bash}/bin/bash";
2020-10-29 21:42:14 +00:00
# fix hardcoded GOFLAGS in makefile. remove once https://github.com/direnv/direnv/issues/718 is closed.
postPatch = ''
substituteInPlace GNUmakefile --replace "export GOFLAGS=-mod=vendor" ""
'';
# replace the build phase to use the GNUMakefile instead
buildPhase = ''
make BASH_PATH=$BASH_PATH
'';
2013-11-17 14:00:12 +00:00
2016-07-03 16:55:51 +01:00
installPhase = ''
make install DESTDIR=$out
mkdir -p $out/share/fish/vendor_conf.d
echo "eval ($out/bin/direnv hook fish)" > $out/share/fish/vendor_conf.d/direnv.fish
2016-07-03 16:55:51 +01:00
'';
2020-08-10 23:27:38 +01:00
checkInputs = [ fish zsh ];
checkPhase = ''
export HOME=$(mktemp -d)
make test-go test-bash test-fish test-zsh
'';
2016-07-03 16:55:51 +01:00
meta = with stdenv.lib; {
description = "A shell extension that manages your environment";
2013-11-17 14:00:12 +00:00
longDescription = ''
Once hooked into your shell direnv is looking for an .envrc file in your
current directory before every prompt.
If found it will load the exported environment variables from that bash
script into your current environment, and unload them if the .envrc is
not reachable from the current path anymore.
In short, this little tool allows you to have project-specific
environment variables.
'';
homepage = "https://direnv.net";
2016-07-03 16:55:51 +01:00
license = licenses.mit;
maintainers = with maintainers; [ zimbatm ];
2013-11-17 14:00:12 +00:00
};
}