Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xonsh.xontribs.xontrib-*: init at various #354733

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
38 changes: 35 additions & 3 deletions nixos/modules/programs/xonsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let

cfg = config.programs.xonsh;

package = cfg.package.override { extraPackages = (ps: cfg.xontribs ++ (cfg.extraPackages ps)); };
in

{
Expand All @@ -32,6 +32,38 @@ in
type = lib.types.lines;
};

xontribs = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.package;
description = ''
Add the listed xontribs to the package options. Available xontribs are
under xonsh.xontribs.

Take care in using this option along with manually defining the package
option above, as the two can result in conflicting sets of build dependencies.
This option assumes that the package option has an overridable argument
called `extraPackages`, so if you override the package option but also
intend to use this option, be sure that your resulting package still honors
the necessary option.
'';
example = "xontribs = with pkgs.xonsh.xontribs; [ xontrib-vox xontrib-abbrevs ];";
};

extraPackages = lib.mkOption {
default = (ps: [ ]);
type = lib.types.functionTo (lib.types.listOf lib.types.package);
description = ''
Add the specified extra packages to the xonsh package.
Preferred over using `programs.xonsh.package` as it composes with `programs.xonsh.xontribs`.

Take care in using this option along with manually defining the package
option above, as the two can result in conflicting sets of build dependencies.
This option assumes that the package option has an overridable argument
called `extraPackages`, so if you override the package option but also
intend to use this option, be sure that your resulting package still honors
the necessary option.
'';
};
Comment on lines +35 to +66
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to separate xontribs from other python packages? I think they can be both in one option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was addressed in the review of my original PR. Xontribs are intentionally hobbled code and do not need to exclusively be written in Python (they can also be written in Xonsh syntax itself). Rather than using the established methods for Python plugin detection, Xonsh requires that its plugins all drop their entry point into the same folder and leave out the __init__.py file. Xonsh itself provides that init file and then looks for the xontribs in that directory. As such, xontribs are not truly valid Python packages and really shouldn't be handled as such.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was addressed in the review of my original PR. Xontribs are intentionally hobbled code and do not need to exclusively be written in Python (they can also be written in Xonsh syntax itself). Rather than using the established methods for Python plugin detection, Xonsh requires that its plugins all drop their entry point into the same folder and leave out the __init__.py file. Xonsh itself provides that init file and then looks for the xontribs in that directory. As such, xontribs are not truly valid Python packages and really shouldn't be handled as such.

Xontribs and Python packages are both added to the wrapper's parameter extraPackages now and works fine so far for me, so I don't understand why there are two options to override extraPackages. Do you mean the wrapper needs rework?

};

};
Expand Down Expand Up @@ -64,11 +96,11 @@ in
${cfg.config}
'';

environment.systemPackages = [ cfg.package ];
environment.systemPackages = [ package ];

environment.shells = [
"/run/current-system/sw/bin/xonsh"
"${lib.getExe cfg.package}"
"${lib.getExe package}"
];
};
}
13 changes: 8 additions & 5 deletions pkgs/by-name/xo/xonsh/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
}:

let
pythonEnv = python3.withPackages
(ps: [ ps.xonsh ] ++ extraPackages ps);
pythonEnv = python3.withPackages (ps: [ ps.xonsh ] ++ extraPackages ps);
xonsh = python3.pkgs.xonsh;
in
runCommand
"xonsh-${xonsh.version}"
runCommand "xonsh-${xonsh.version}"
{
inherit (xonsh) pname version meta passthru;
inherit (xonsh)
pname
version
meta
passthru
;
}
''
mkdir -p $out/bin
Expand Down
1 change: 1 addition & 0 deletions pkgs/by-name/xo/xonsh/unwrapped.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ let
python = pythonPackages.python; # To the wrapper
wrapper = throw "The top-level xonsh package is now wrapped. Use it directly.";
updateScript = gitUpdater { };
xontribs = import ./xontribs { inherit pythonPackages; };
};

meta = {
Expand Down
18 changes: 18 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
pythonPackages,
}:
let
inherit (pythonPackages) callPackage;
in
{
xonsh-direnv = callPackage ./xonsh-direnv { };
xontrib-abbrevs = callPackage ./xontrib-abbrevs { };
xontrib-bashisms = callPackage ./xontrib-bashisms { };
xontrib-debug-tools = callPackage ./xontrib-debug-tools { };
xontrib-distributed = callPackage ./xontrib-distributed { };
xontrib-fish-completer = callPackage ./xontrib-fish-completer { };
xontrib-jedi = callPackage ./xontrib-jedi { };
xontrib-jupyter = callPackage ./xontrib-jupyter { };
xontrib-vox = callPackage ./xontrib-vox { };
xontrib-whole-word-jumping = callPackage ./xontrib-whole-word-jumping { };
}
35 changes: 35 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xonsh-direnv/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

direnv,
setuptools,
}:

buildPythonPackage rec {
pname = "xonsh-direnv";
version = "1.6.5";

src = fetchFromGitHub {
owner = "74th";
repo = pname;
rev = version;
hash = "sha256-huBJ7WknVCk+WgZaXHlL+Y1sqsn6TYqMP29/fsUPSyU=";
};

propagatedBuildInputs = [
direnv
];

nativeBuildInputs = [
setuptools
];

meta = with lib; {
description = "Direnv support for Xonsh";
homepage = "https://github.com/74th/xonsh-direnv/";
license = licenses.mit;
maintainers = with maintainers; [ greg ];
};
}
56 changes: 56 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xontrib-abbrevs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

setuptools,
setuptools-scm,
poetry-core,
prompt-toolkit,
pytestCheckHook,
xonsh,
}:

buildPythonPackage rec {
pname = "xontrib-abbrevs";
version = "0.1.0";
format = "pyproject";

src = fetchFromGitHub {
owner = "xonsh";
repo = "xontrib-abbrevs";
rev = "v${version}";
hash = "sha256-JxH5b2ey99tvHXSUreU5r6fS8nko4RrS/1c8psNbJNc=";
};

prePatch = ''
substituteInPlace pyproject.toml \
--replace '"xonsh>=0.12.5", ' ""
'';

nativeBuildInputs = [
setuptools
setuptools-scm
poetry-core
];

propagatedBuildInputs = [
prompt-toolkit
];

preCheck = ''
export HOME=$TMPDIR
'';

checkInputs = [
pytestCheckHook
xonsh
];

meta = with lib; {
description = "Command abbreviations. This expands input words as you type.";
homepage = "https://github.com/xonsh/xontrib-abbrevs";
license = licenses.mit;
maintainers = [ maintainers.greg ];
};
}
47 changes: 47 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xontrib-bashisms/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

setuptools,
pytestCheckHook,
xonsh,
}:

buildPythonPackage rec {
pname = "xontrib-bashisms";
version = "0.0.5";
format = "pyproject";

src = fetchFromGitHub {
owner = "xonsh";
repo = "xontrib-bashisms";
rev = version;
hash = "sha256-R1DCGMrRCJLnz/QMk6QB8ai4nx88vvyPdaCKg3od5/I=";
};

prePatch = ''
substituteInPlace pyproject.toml \
--replace '"xonsh>=0.12.5"' ""
'';

preCheck = ''
export HOME=$TMPDIR
'';

nativeBuildInputs = [
setuptools
];

checkInputs = [
pytestCheckHook
xonsh
];

meta = with lib; {
description = "Bash-like interactive mode extensions for the xonsh shell. ";
homepage = "https://github.com/xonsh/xontrib-bashisms";
license = licenses.mit;
maintainers = [ maintainers.greg ];
};
}
41 changes: 41 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xontrib-debug-tools/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

pytestCheckHook,
xonsh,
}:

buildPythonPackage rec {
pname = "xontrib-debug-tools";
version = "0.0.1";

src = fetchFromGitHub {
owner = "xonsh";
repo = "xontrib-debug-tools";
rev = version;
hash = "sha256-Z8AXKk94NxmF5rO2OMZzNX0GIP/Vj+mOtYUaifRX1cw=";
};

prePatch = ''
substituteInPlace pyproject.toml \
--replace '"xonsh>=0.12.5"' ""
'';

preCheck = ''
export HOME=$TMPDIR
'';

checkInputs = [
pytestCheckHook
xonsh
];

meta = with lib; {
description = "Debug tools for xonsh shell.";
homepage = "https://github.com/xonsh/xontrib-debug-tools";
license = licenses.mit;
maintainers = [ maintainers.greg ];
};
}
51 changes: 51 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xontrib-distributed/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

distributed,
poetry-core,
pytestCheckHook,
xonsh,
}:

buildPythonPackage rec {
pname = "xontrib-distributed";
version = "0.0.4";
format = "pyproject";

src = fetchFromGitHub {
owner = "xonsh";
repo = "xontrib-distributed";
rev = "v${version}";
hash = "sha256-Hb7S3PqHi0w6zb9ki8ADMtgdYVv8O5WQZMgJzKF74qE=";
};

prePatch = ''
substituteInPlace pyproject.toml \
--replace 'xonsh = ">=0.12"' ""
'';

nativeBuildInputs = [
poetry-core
];

propagatedBuildInputs = [
distributed
];

# v0.0.4 has no tests associated with it
doCheck = false;

checkInputs = [
pytestCheckHook
xonsh
];

meta = with lib; {
description = "Dask Distributed integration for Xonsh";
homepage = "https://github.com/xonsh/xontrib-distributed";
license = licenses.mit;
maintainers = [ maintainers.greg ];
};
}
47 changes: 47 additions & 0 deletions pkgs/by-name/xo/xonsh/xontribs/xontrib-fish-completer/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
buildPythonPackage,
lib,
fetchFromGitHub,

pytestCheckHook,
pytest-subprocess,
xonsh,
}:

buildPythonPackage rec {
pname = "xontrib-fish-completer";
version = "0.0.1";

src = fetchFromGitHub {
owner = "xonsh";
repo = "xontrib-fish-completer";
rev = version;
hash = "sha256-PhhdZ3iLPDEIG9uDeR5ctJ9zz2+YORHBhbsiLrJckyA=";
};

prePatch = ''
substituteInPlace pyproject.toml \
--replace '"xonsh>=0.12.5"' ""
'';

preCheck = ''
export HOME=$TMPDIR
'';

disabledTests = [
"test_interpreter"
];

checkInputs = [
pytestCheckHook
pytest-subprocess
xonsh
];

meta = with lib; {
description = "Populate rich completions using fish and remove the default bash based completer";
homepage = "https://github.com/xonsh/xontrib-fish-completer";
license = licenses.mit;
maintainers = [ maintainers.greg ];
};
}
Loading
Loading