`mkShell` and current dir - Nix

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Magnus Therning

I'm trying to find a way of setting an envvar to $PWD/foobar in mkShell like this:

mkShell {
  buildInputs = [ ... ];

  FOO = ./. + "/foobar";

but then I get

error: while evaluating the attribute 'FOO' of the derivation 'nix-shell' at /nix/store/fb31dnfdl5s9kxgmn4dfbkas9zbr6gcr-source/pkgs/build-support/mkshell/default.nix:28:3:
getting attributes of path '/home/magnus/my-proj/foobar': No such file or directory

How do I get around thing?

The tools I'll use in the shell will create the folder when needed, so it doesn't _have_ to exist.

Will I have to make Nix create the folder? (How???)

Is there some way to put the $PWD into an envar that doesn't trigger a check for existence of the path?

Torsten Schmits

using ./. creates a store path, copying the contents of ./foobar there. you have to use strings

Torsten Schmits

I'd say it depends on what you want to do with the directory, if you call toString ./., you will at least have a string representation of the path