Skip to content

passAsFile paths aren't available for nix develop #7265

@aameen-tulip

Description

@aameen-tulip

Describe the bug

Derivations that use passAsFile don't have access to those paths in nix-command nix develop mode.

Steps To Reproduce

$ mkdir -p /tmp/whoops;
$ cd /tmp/whoops;
$ git init;
$ cat <<'EOF' > flake.nix
{  
  outputs = { nixpkgs, ... }: let
    fes = fn: builtins.foldl' ( a: s: a // { ${s} = fn s; } ) {} [
      "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux"
    ];
  in {
    packages = fes ( system: {
      default = nixpkgs.legacyPackages.${system}.stdenv.mkDerivation {
        name = "whoops";
        data = builtins.concatStringsSep "" ( builtins.genList toString 1024 );
        passAsFile = ["data"];
        buildCommand = ''
          line="$( <"$dataPath"; )";
          echo "$line" > "$out";
        '';
      };
    } );
  };
}
EOF
$ git add ./flake.nix;
$ nix flake lock;
$ git add ./flake.lock;
$ nix build && cat ./result;  # Works
$ rm ./result;
$ nix develop;
$ genericBuild;
bash: /private/tmp/nix-build-whoops-env.drv-0/.attr-1dy8mlivplr3m6ln28k025l0w4ax5kfv4miq9z4qgb1r1xwv0vis: No such file or directory

Expected behavior

Temporary files should be created during devShell initialization.

nix-env --version output

nix-env (Nix) 2.10.3

Additional context

The trivial example above uses buildCommand with stdenv.mkDerivation, but the same issue occurs with (unpack|build|install|...)Phase definition, and even with a direct derivation { ... }.
Defining the installable as devShells = ... in the flake has the same behavior as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnix-shellnix-shell, nix develop, nix print-dev-env, etc
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions