You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
739 B
JavaScript
28 lines
739 B
JavaScript
#!/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 <nixpkgs> {}; 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"
|
|
});
|