Help typescript to find modules


I am trying to use pulumi (a deployement tool, doesn’t matter GitHub - pulumi/pulumi: Pulumi - Universal Infrastructure as Code. Your Cloud, Your Language, Your Way 🚀) with nix as much as possible. I have a working environment with plain javascript: I have packaged @pulumi/pulumi with node2nix, add it to NODE_PATH and it works fine. Now we have some typescript scripts (disclaimer: I am a javascript+typescript noob). I put tsc typescript compiler in PATH but pulumi still can’t find the javascript modules. Apparently typescript doesn’t care about NODE_PATH and the config is encoded in tsconfig.json.

My question is how do I tell typescript where to look for files in a nix-friendly way ? I dont want to generate the tsconfig.json to point to a path in the /nix/store because it’s inconvenient. Also I would like to let the people the possibility to still use npm/tsc and not nix. Seems like one can provide fallback paths to tsc but I was not able to make it work. What I do now is to pass a stable path “baseUrl” = “/tmp/node_modules_by_nix” that points to a node_modules folder in the nix store. The symlink /tmp/node_modules_by_nix when entering nix develop. It works, it is kinda good enough but it doesn’t feel right:

    "compilerOptions": {
        "baseUrl": "/tmp/node_modules_by_nix" ,
        "strict": true,
        "outDir": "bin",
        "target": "es2016",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "experimentalDecorators": true,
        "pretty": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "forceConsistentCasingInFileNames": true
    "files": [

Ideally I would like to export an environment variable similar to NODE_PATH, e.g., TSC_PATH to tell typescript where to look for modules. I am not sure what’s the best approach on nixos. There is no entry in the nixpkgs manual for typescript, could be worth adding.