numtide / devshell

Per project developer environments
https://numtide.github.io/devshell/
MIT License
1.22k stars 87 forks source link

Incorrect quoting for LD_LIBRARY_PATH, C_INCLUDE_PATH, PKG_CONFIG_PATH when using extras/language/c.nix (possibly others as well) #258

Closed pschyska closed 1 year ago

pschyska commented 1 year ago

Describe the bug

Since https://github.com/numtide/devshell/commit/a773f912ea85cdfa04a13070431abfc0c19ce79f, the "prefix" envs are incorrectly quoted.

escapeShellArg single-quotes its arguments, but extras/language/c.nix (e.g.) wants to substitute $DEVSHELL_DIR. It's probably broken in other places in here as well, and for anyone that tries to substitute prefixes in their downstream flakes.

To Reproduce

{
  description = "repro";

  inputs.devshell.url = "github:numtide/devshell";

  outputs =
    { self, devshell }:
    {
      devShell.x86_64-linux = devshell.legacyPackages.x86_64-linux.mkShell {
        motd = "";
        env = [
          {
            name = "TESTIK";
            prefix = "$PWD/testik";
          }
        ];
        devshell.startup.test.text = ''
          if ! [[ $TESTIK = "$PWD/testik" ]]; then
            printf "\$TESTIK is wrong, want %s, got %s\n" "$PWD/testik" "$TESTIK"
          fi
        '';
      };
    };
}

Steps to reproduce the behavior:

  1. nix develop with the given flake.nix

Expected behavior No output like $TESTIK is wrong, want /tmp/tmp.U8txOCv4Dz/testik, got /tmp/tmp.U8txOCv4Dz/$PWD/testik.

pschyska commented 1 year ago

Thank you, it seemed to have worked