1{ lib
2, fetchFromGitHub
3, python3Packages
4, glibcLocales
5, coreutils
6, git
7}:
8
9python3Packages.buildPythonApplication rec {
10 pname = "xonsh";
11 version = "0.13.0";
12
13 # fetch from github because the pypi package ships incomplete tests
14 src = fetchFromGitHub {
15 owner = "xonsh";
16 repo = "xonsh";
17 rev = version;
18 sha256 = "sha256-8X/+mQrwJ0yaUHRKdoY3G0P8kq22hYfRK+7WRl/zamc=";
19 };
20
21 LC_ALL = "en_US.UTF-8";
22
23 postPatch = ''
24 sed -ie "s|/bin/ls|${coreutils}/bin/ls|" tests/test_execer.py
25 sed -ie "s|SHELL=xonsh|SHELL=$out/bin/xonsh|" tests/test_integrations.py
26
27 sed -ie 's|/usr/bin/env|${coreutils}/bin/env|' tests/test_integrations.py
28 sed -ie 's|/usr/bin/env|${coreutils}/bin/env|' scripts/xon.sh
29 find scripts -name 'xonsh*' -exec sed -i -e "s|env -S|env|" {} \;
30 find -name "*.xsh" | xargs sed -ie 's|/usr/bin/env|${coreutils}/bin/env|'
31 patchShebangs .
32
33 substituteInPlace scripts/xon.sh \
34 --replace 'python' "${python3Packages.python}/bin/python"
35
36 '';
37
38 makeWrapperArgs = [
39 "--prefix PYTHONPATH : ${placeholder "out"}/lib/${python3Packages.python.libPrefix}/site-packages"
40 ];
41
42 postInstall = ''
43 wrapProgram $out/bin/xonsh \
44 $makeWrapperArgs
45 '';
46
47 disabledTests = [
48 # fails on sandbox
49 "test_colorize_file"
50 "test_loading_correctly"
51 "test_no_command_path_completion"
52 "test_bsd_man_page_completions"
53 "test_xonsh_activator"
54 # fails on non-interactive shells
55 "test_capture_always"
56 "test_casting"
57 "test_command_pipeline_capture"
58 "test_dirty_working_directory"
59 "test_man_completion"
60 "test_vc_get_branch"
61 "test_bash_and_is_alias_is_only_functional_alias"
62 ];
63
64 disabledTestPaths = [
65 # fails on sandbox
66 "tests/completers/test_command_completers.py"
67 "tests/test_ptk_highlight.py"
68 "tests/test_ptk_shell.py"
69 # fails on non-interactive shells
70 "tests/prompt/test_gitstatus.py"
71 "tests/completers/test_bash_completer.py"
72 ];
73
74 preCheck = ''
75 HOME=$TMPDIR
76 '';
77
78 checkInputs = [ glibcLocales git ] ++
79 (with python3Packages; [ pyte pytestCheckHook pytest-mock pytest-subprocess ]);
80
81 propagatedBuildInputs = with python3Packages; [ ply prompt-toolkit pygments ];
82
83 meta = with lib; {
84 description = "A Python-ish, BASHwards-compatible shell";
85 homepage = "https://xon.sh/";
86 changelog = "https://github.com/xonsh/xonsh/raw/${version}/CHANGELOG.rst";
87 license = licenses.bsd3;
88 maintainers = with maintainers; [ spwhitt vrthra ];
89 };
90
91 passthru = {
92 shellPath = "/bin/xonsh";
93 };
94}