From 65fd0080a8db921d35657534206d6e467c3465bd Mon Sep 17 00:00:00 2001 From: Tom Prince <tom.prince@private.storage> Date: Tue, 7 Sep 2021 03:52:28 -0600 Subject: [PATCH] Set `NIX_PATH` in `shellHook` of `shell.nix`. If `nix-shell` is run interactively on NixOS, in way that has loaded `/etc/profile` (for example `docker exec <container> nix-shell`), then `/etc/profile` will be sourced in the shell that nix-shell starts. That overwrites the `NIX_PATH` set by `shell.nix`. If we instead set `NIX_PATH` in the the `shellHook`, that always takes precedence. --- shell.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index f3d2750e..af006f75 100644 --- a/shell.nix +++ b/shell.nix @@ -3,7 +3,9 @@ let in { pkgs ? release2105 }: pkgs.mkShell { - NIX_PATH = "nixpkgs=${pkgs.path}"; + shellHook = '' + export NIX_PATH="nixpkgs=${pkgs.path}"; + ''; buildInputs = [ pkgs.morph pkgs.vagrant -- GitLab