From 904b8c5ec026dd0b24cfd7a9c08bd4e41a3c7313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Camille=20Favier?= Date: Sun, 25 Jan 2026 22:36:18 +0100 Subject: [PATCH] Set `inNixShell` `nix-shell` passes a `inNixShell = true` argument when evaluating a file, so we should replicate this behaviour. There is another mechanism for signaling that we are in a nix shell, namely the `IN_NIX_SHELL` environment variable (which both nix-shell and nix-direnv also set), but this is by nature not a good solution since it leaks into e.g. further `nix-build` invocations in nix shells. This only concerns non-flake setups, of course. --- direnvrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direnvrc b/direnvrc index 6f6eac88..a6c3ae20 100644 --- a/direnvrc +++ b/direnvrc @@ -525,7 +525,7 @@ use_nix() { if [[ -n $packages ]]; then extra_args+=("--expr" "with import {}; mkShell { buildInputs = [ $packages ]; }") else - extra_args+=("--file" "$nixfile") + extra_args+=("--file" "$nixfile" --arg inNixShell true) if [[ -n $attribute ]]; then extra_args+=("$attribute") fi