Closed mmlb closed 5 years ago
What does your shell.nix
look like?
lorri does not run shellHook
s at the moment, see #7.
~/code/src/github.com/packethost/tinkerbell master? *24 0.00 20:31:27
❯ tail -n+1 .envrc shell.nix
==> .envrc <==
#OLDGOPATH=$GOPATH
eval "$(lorri direnv)"
#GOPATH=$OLDGOPATH:$GOPATH
#unset OLDGOPATH
==> shell.nix <==
let
_pkgs = import <nixpkgs> {};
in
{ pkgs ? import (_pkgs.fetchFromGitHub { owner = "NixOS";
repo = "nixpkgs";
rev = "18.09";
sha256 = "1ib96has10v5nr6bzf7v8kw7yzww8zanxgw2qi1ll1sbv6kj6zpd";
}) {}
}:
with pkgs;
stdenv.mkDerivation rec {
name = "tinkerbell";
env = buildEnv { name = name; paths = buildInputs; };
buildInputs = [
dep
gcc
git-lfs
gnumake
go
pkgsCross.aarch64-multiplatform.buildPackages.gcc
xz
];
}
~/code/src/github.com/packethost/tinkerbell master? *24 0.00 20:31:53
❯ env | grep GOPATH
GOPATH=/nix/store/l6747b8vkpmazcaxm89dd0amky0q35nn-go-1.11/share/go
Here is a minimal repro that reproduces the bug you see:
shell.nix
:
with import <nixpkgs> {};
stdenv.mkDerivation
{
name = "tmpshell";
buildInputs = [ go ];
}
.envrc
:
eval "$(lorri direnv)"
$ printenv GOPATH
/home/philip/.go
$ cd repro/
$ direnv allow
direnv: loading .envrc
direnv: export +AR +AS +CC +CONFIG[…snip]
$ printenv GOPATH
/nix/store/barxv95b8arrlh97s6axj8k7ljn7aky1-go-1.12/share/go
$ direnv deny
$ nix-shell
> nix-shell
[nix-shell]$ printenv GOPATH
/home/philip/.go:/nix/store/barxv95b8arrlh97s6axj8k7ljn7aky1-go-1.12/share/go
I think the go
derivation has a shellHook
(or a similar hook) that sets up the GOPATH
for nix-shell
. If so, this is a version of #7 indeed, making it a much more pressing feature to implement.
I've got GOPATH setup from my default shell, and using direnv's default
use_nix
my GOPATH is appended to in the resulting env, but with lorri it is replaced.I see that the generated output of
lorri direnv
handlesPATH
as a special variable, should the logic be updated for*PATH
or addGOPATH
to the list?