From cf1e565a0a955bc40a66da82e6cdae481371b8cd Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 15 Jun 2026 13:35:42 -0400 Subject: [PATCH] devshell: Fix usage with nix-shell Since d0190cff6f2314cc1c727ff113aea20e086f4bcc, the `justfile` uses `$out` from the environment as an argument to `--prefix` in its `meson` invocation. The `$out` variable is... A bit spicy to use since its semantics change depending on whether `nix develop` or `nix-shell` is used. In a `nix develop` shell, a directory *relative to PWD* (and not relative to the Nix expression) is exported. In a `nix-shell`, the `$out` used comes from the derivation. The alternative to this change is to make the `justfile` use a variable name that would not conflict with a `nix-shell` and `nix develop` shell. Since it wants to use that value for the `outdir` variable, this would be the name I would pick first. I chose to instead work around the issue within the `nix-shell` since this would be breaking the existing interface. As tenuous as it is. Change-Id: I64cd5fd85345457e14880cb133e9ddafd55a25da --- package.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.nix b/package.nix index 13251096f..f8865f8b1 100644 --- a/package.nix +++ b/package.nix @@ -906,6 +906,12 @@ stdenv.mkDerivation (finalAttrs: { ++ finalAttrs.checkInputs; shellHook = '' + # Make `nix-shell` use a PWD-relative dir for `out`, emulating `nix develop`. + # The original `out` path is never going to be relevant, and breaks assumptions for the justfile. + if [[ "$out" =~ ^${builtins.storeDir}/ ]]; then + export out="$PWD/outputs/out" + fi + # don't re-run the hook in (other) nested nix-shells function lixShellHook() { # n.b. how the heck does this become -env-env? well, `nix develop` does it: