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 ]; }
```
This commit is contained in:
@@ -28,7 +28,7 @@ in
|
|||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.xonsh;
|
default = pkgs.xonsh;
|
||||||
defaultText = literalExpression "pkgs.xonsh";
|
defaultText = literalExpression "pkgs.xonsh";
|
||||||
example = literalExpression "pkgs.xonsh.override { configFile = \"/path/to/xonshrc\"; }";
|
example = literalExpression "pkgs.xonsh.override { extraPackages = ps: [ ps.requests ]; }";
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
xonsh package to use.
|
xonsh package to use.
|
||||||
'';
|
'';
|
||||||
@@ -83,4 +83,3 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, python3Packages
|
, python3
|
||||||
, glibcLocales
|
, glibcLocales
|
||||||
, coreutils
|
, coreutils
|
||||||
, git
|
, git
|
||||||
}:
|
}:
|
||||||
|
|
||||||
python3Packages.buildPythonApplication rec {
|
python3.pkgs.buildPythonApplication rec {
|
||||||
pname = "xonsh";
|
pname = "xonsh";
|
||||||
version = "0.14.0";
|
version = "0.14.0";
|
||||||
|
|
||||||
@@ -29,16 +29,8 @@ python3Packages.buildPythonApplication rec {
|
|||||||
find scripts -name 'xonsh*' -exec sed -i -e "s|env -S|env|" {} \;
|
find scripts -name 'xonsh*' -exec sed -i -e "s|env -S|env|" {} \;
|
||||||
find -name "*.xsh" | xargs sed -ie 's|/usr/bin/env|${coreutils}/bin/env|'
|
find -name "*.xsh" | xargs sed -ie 's|/usr/bin/env|${coreutils}/bin/env|'
|
||||||
patchShebangs .
|
patchShebangs .
|
||||||
|
|
||||||
substituteInPlace scripts/xon.sh \
|
|
||||||
--replace 'python' "${python3Packages.python}/bin/python"
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
makeWrapperArgs = [
|
|
||||||
"--prefix PYTHONPATH : ${placeholder "out"}/lib/${python3Packages.python.libPrefix}/site-packages"
|
|
||||||
];
|
|
||||||
|
|
||||||
disabledTests = [
|
disabledTests = [
|
||||||
# fails on sandbox
|
# fails on sandbox
|
||||||
"test_colorize_file"
|
"test_colorize_file"
|
||||||
@@ -71,9 +63,9 @@ python3Packages.buildPythonApplication rec {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
nativeCheckInputs = [ glibcLocales git ] ++
|
nativeCheckInputs = [ glibcLocales git ] ++
|
||||||
(with python3Packages; [ pyte pytestCheckHook pytest-mock pytest-subprocess ]);
|
(with python3.pkgs; [ pyte pytestCheckHook pytest-mock pytest-subprocess ]);
|
||||||
|
|
||||||
propagatedBuildInputs = with python3Packages; [ ply prompt-toolkit pygments ];
|
propagatedBuildInputs = with python3.pkgs; [ ply prompt-toolkit pygments ];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A Python-ish, BASHwards-compatible shell";
|
description = "A Python-ish, BASHwards-compatible shell";
|
||||||
@@ -85,5 +77,6 @@ python3Packages.buildPythonApplication rec {
|
|||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
shellPath = "/bin/xonsh";
|
shellPath = "/bin/xonsh";
|
||||||
|
python = python3;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
24
pkgs/shells/xonsh/wrapper.nix
Normal file
24
pkgs/shells/xonsh/wrapper.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{ 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
|
||||||
|
''
|
||||||
@@ -14751,7 +14751,8 @@ with pkgs;
|
|||||||
|
|
||||||
rush = callPackage ../shells/rush { };
|
rush = callPackage ../shells/rush { };
|
||||||
|
|
||||||
xonsh = callPackage ../shells/xonsh { };
|
xonsh = callPackage ../shells/xonsh/wrapper.nix { };
|
||||||
|
xonsh-unwrapped = callPackage ../shells/xonsh { };
|
||||||
|
|
||||||
zsh = callPackage ../shells/zsh { };
|
zsh = callPackage ../shells/zsh { };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user