nixpkgs/pkgs/shells/xonsh/wrapper.nix
adisbladis 0fab94a844 xonsh: Add wrapper
It is currently not obvious how to install/use xonsh with dependencies and python packages.

This PR implements a wrapper that allows you to construct a custom xonsh environment by using:
``` nix
xonsh.override { extraPackages = ps: [ ps.requests ]; }
```
2023-06-30 19:39:53 +12:00

25 lines
465 B
Nix

{ runCommand
, xonsh-unwrapped
, lib
, extraPackages ? (ps: [ ])
}:
let
xonsh = xonsh-unwrapped;
inherit (xonsh.passthru) python;
pythonEnv = python.withPackages (ps: [
(ps.toPythonModule xonsh)
] ++ extraPackages ps);
in
runCommand "${xonsh.pname}-${xonsh.version}"
{
inherit (xonsh) pname version meta passthru;
} ''
mkdir -p $out/bin
for bin in ${lib.getBin xonsh}/bin/*; do
ln -s ${pythonEnv}/bin/$(basename "$bin") $out/bin/
done
''