How to refer to current directory in shell.nix?

Maybe it’s easier than I thought it was:

with import <nixpkgs> {};
(callPackage ./default.nix {}).overrideAttrs(o: rec {
  SWARM_BASE_PATH = "/tmp/services";
  PROJECT_ROOT = builtins.getEnv "PWD";
  LUA_PATH = "${PROJECT_ROOT}/lib/?.lua";
  nativeBuildInputs = [ pkgs.foreman ] ;
})

although it would be even better if I could find the path of the shell.nix file itself, then I can run nix-shell from other directories as well as .

3 Likes