diff --git a/flake.nix b/flake.nix index b3872f7..3183270 100644 --- a/flake.nix +++ b/flake.nix @@ -29,7 +29,12 @@ mkPackages = pkgs: { hello-world = pkgs.callPackage ./packages/hello-world.nix { }; - xonsh = pkgs.callPackage ./packages/xonsh.nix { }; + xonsh = pkgs.callPackage ./packages/xonsh.nix { + xonsh-unwrapped = import ./packages/xonsh-unwrapped.nix { + inherit (pkgs) lib; + inherit (pkgs) python3Packages; + }; + }; }; # Native builds diff --git a/packages/xonsh-unwrapped.nix b/packages/xonsh-unwrapped.nix new file mode 100644 index 0000000..2a4a9be --- /dev/null +++ b/packages/xonsh-unwrapped.nix @@ -0,0 +1,29 @@ +{ lib, python3Packages }: + +python3Packages.buildPythonPackage rec { + pname = "xonsh"; + version = "0.22.7"; + + src = python3Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-gPApjBEctw1eLWN5gtz0ArJXPOcSqwyBNJBHdFMdRwk="; + }; + + # xonsh uses pyproject.toml setuptools + format = "pyproject"; + build-system = [ python3Packages.setuptools ]; + + propagatedBuildInputs = with python3Packages; [ + ply + prompt-toolkit + pygments + ]; + + doCheck = false; + + meta = with lib; { + description = "Python-powered shell that combines Python with shell features"; + homepage = "https://xon.sh"; + license = licenses.bsd3; + }; +} diff --git a/packages/xonsh.nix b/packages/xonsh.nix index 2a4a9be..b1b18bf 100644 --- a/packages/xonsh.nix +++ b/packages/xonsh.nix @@ -1,29 +1,28 @@ -{ lib, python3Packages }: +{ + lib, + python3, + runCommand, + xonsh-unwrapped, + extraPackages ? (ps: [ ]), +}: -python3Packages.buildPythonPackage rec { - pname = "xonsh"; - version = "0.22.7"; - - src = python3Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-gPApjBEctw1eLWN5gtz0ArJXPOcSqwyBNJBHdFMdRwk="; - }; - - # xonsh uses pyproject.toml setuptools - format = "pyproject"; - build-system = [ python3Packages.setuptools ]; - - propagatedBuildInputs = with python3Packages; [ - ply - prompt-toolkit - pygments - ]; - - doCheck = false; - - meta = with lib; { - description = "Python-powered shell that combines Python with shell features"; - homepage = "https://xon.sh"; - license = licenses.bsd3; - }; -} +let + pythonEnv = python3.withPackages (ps: [ xonsh-unwrapped ] ++ extraPackages ps); +in +runCommand "xonsh-${xonsh-unwrapped.version}" + { + inherit (xonsh-unwrapped) + pname + version + meta + ; + passthru = { + unwrapped = xonsh-unwrapped; + }; + } + '' + mkdir -p $out/bin + for bin in ${lib.getBin xonsh-unwrapped}/bin/*; do + ln -s ${pythonEnv}/bin/$(basename "$bin") $out/bin/ + done + ''