Initial commit

master
Sven Slootweg 7 years ago
commit 19c9af003c

1
.gitignore vendored

@ -0,0 +1 @@
node_modules

@ -0,0 +1,30 @@
# devshell
A simple tool for spawning a `nix-shell` with certain packages in the `LD_LIBRARY_PATH`. Useful for experimenting with runtime-loaded dependencies.
## License
[WTFPL](http://www.wtfpl.net/txt/copying/) or [CC0](https://creativecommons.org/publicdomain/zero/1.0/), whichever you prefer. A donation and/or attribution are appreciated, but not required.
## Donate
Maintaining open-source projects takes a lot of time, and the more donations I receive, the more time I can dedicate to open-source. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)!
You can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else. Thank you!
## Installation
```
npm install -g nix-devshell
```
## Usage:
```
$ devshell xorg.libX11 xorg.libXcursor xorg.libXxf86vm xorg.libxcb xorg.libXi
Spawning shell with packages [xorg.libX11, xorg.libXcursor, xorg.libXxf86vm, xorg.libxcb, xorg.libXi] in the LD_LIBRARY_PATH...
$ echo $LD_LIBRARY_PATH
/nix/store/6ilsr4fz201drpwdxs8n7yv8fdnwhfb8-libX11-1.6.5/lib:/nix/store/cqsz57g4xlmnm2rlcwdg859qxfwqcfb9-libXcursor-1.1.14/lib:/nix/store/jlc87n7xkcgq7kp8lsn5bhrs86lhifbj-libXxf86vm-1.1.4/lib:/nix/store/02xfc39dvwiwsdq9gq2zv2119wmpnfmm-libxcb-1.12/lib:/nix/store/0wcsp7hcn0nwgmfd93dqxdn22f8vmfip-libXi-1.7.9/lib:/nix/store/083slkpsm9b56bg3p8jay7q2lwql45q7-dbus-1.10.16-lib/lib:/nix/store/wdk4s775vpz62q60qi1kwm2r8z538xp0-gtk+-2.24.31/lib:/nix/store/1lpizdxwhzkng0mii4mmwbq817zw7kw9-gconf-2.32.4/lib:/nix/store/zq0lf0fdc7n12zcdcs2qq3viz6mc87vr-python-2.7.13/lib:/nix/store/sa9hzl6qj8yxnv9nf6m0ffvdyqyfj6fq-libutempter-1.1.6/lib:/nix/store/62v6dvvspkxm2c8hx2lvz4kyyq8r2788-vte-0.28.2/lib:/nix/store/rawp1abvrzv3fi5lq0x616dz3rj0scmh-keybinder-0.3.0/lib:/nix/store/kf8izhdr8nkbslfl1423wlvzhlpfx4fz-gnome-common-3.18.0/lib:/run/opengl-driver/lib:/run/opengl-driver-32/lib
```
The new entries are prepended to the `LD_LIBRARY_PATH` in the environment from which you ran `devshell`, so it won't break things like OpenGL. You can use the resulting shell in the exact same way as you'd use `nix-shell`; simply exit it to return to your 'real' shell.

@ -0,0 +1,27 @@
#!/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"
});

@ -0,0 +1,23 @@
{
"name": "nix-devshell",
"version": "1.0.0",
"description": "A tool for spawning nix-shells with the dependencies exposed in the LD_LIBRARY_PATH",
"main": "index.js",
"bin": {
"devshell": "bin/devshell.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@git.cryto.net:joepie91/nix-devshell.git"
},
"keywords": [],
"author": "Sven Slootweg",
"license": "WTFPL",
"dependencies": {
"chalk": "^2.0.1",
"tmp": "0.0.31"
}
}
Loading…
Cancel
Save