#!/usr/bin/env node const tmp = require("tmp"); const fs = require("fs"); const childProcess = require("child_process"); const chalk = require("chalk"); let packages = process.argv.slice(2); let expression = ` with import {}; stdenv.mkDerivation rec { name = "devshell"; buildInputs = [${packages.join(" ")}]; LD_LIBRARY_PATH = "\${stdenv.lib.makeLibraryPath buildInputs}:${process.env.LD_LIBRARY_PATH}"; } `; let temporaryFile = tmp.fileSync(); fs.writeSync(temporaryFile.fd, expression); fs.closeSync(temporaryFile.fd); console.log(chalk.green.bold(`Spawning shell with packages [${packages.join(", ")}] in the LD_LIBRARY_PATH...`)); childProcess.spawn("nix-shell", [temporaryFile.name], { stdio: "inherit" });