refactor(flake): wrap xonsh as a package

This commit is contained in:
Artur Manuel 2025-01-18 12:34:41 +00:00
commit d84ed13e0f
11 changed files with 287 additions and 135 deletions

View file

@ -18,7 +18,10 @@
};
alqueva = {
xonsh.enable = true;
xonsh = {
enable = true;
package = pkgs.amadaluzian-xonsh;
};
libvirt.enable = true;
direnv.enable = true;
git.enable = true;

View file

@ -38,6 +38,7 @@
qutebrowser
dunst
;
inherit (inputs.hetch.packages.${pkgs.system}) hetch;
};
groups = [
"wheel"

View file

@ -42,8 +42,7 @@ in {
description = user;
isNormalUser = true;
extraGroups = ucfg.groups;
inherit (ucfg) packages;
shell = ucfg.shell;
inherit (ucfg) packages shell;
initialPassword = "password";
})
cfg;

View file

@ -5,10 +5,16 @@
...
}: let
cfg = config.alqueva.xonsh;
inherit (pkgs) fetchFromGitHub;
attrsToPyDict = attrs: (lib.pipe attrs [
(builtins.mapAttrs (n: v: "aliases['${n}'] = '${v}'"))
builtins.attrValues
(lib.concatStringsSep "\n")
(s: s + "\n")
]);
in {
options.alqueva.xonsh = {
enable = lib.mkEnableOption "xonsh";
package = lib.mkPackageOption pkgs "xonsh" {};
};
config = lib.mkIf cfg.enable {
@ -16,83 +22,14 @@ in {
xonsh = {
config =
"from xonsh.xontribs import get_xontribs\n"
+ lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (n: v: "aliases['${n}'] = '${v}'\n") config.environment.shellAliases))
+ attrsToPyDict config.environment.shellAliases
+ ''
for xontrib in get_xontribs():
xontrib load @(xontrib)
execx($(zoxide init xonsh --cmd j), 'exec', __xonsh__.ctx, filename='zoxide')
'';
package = pkgs.xonsh.override {
extraPackages = ps: [
(let
pname = "xontrib-fish-completer";
version = "0.0.1";
in
ps.buildPythonPackage {
inherit pname version;
src = fetchFromGitHub {
owner = "xonsh";
repo = pname;
rev = version;
hash = "sha256-PhhdZ3iLPDEIG9uDeR5ctJ9zz2+YORHBhbsiLrJckyA=";
};
})
(let
pname = "xontrib-prompt-starship";
version = "0.3.6";
in
ps.buildPythonPackage {
inherit pname version;
src = fetchFromGitHub {
owner = "anki-code";
repo = pname;
tag = version;
hash = "sha256-CLOvMa3L4XnH53H/k6/1W9URrPakPjbX1T1U43+eSR0=";
};
})
(let
pname = "xontrib-init-ssh-agent";
version = "1.0.1";
in
ps.buildPythonPackage {
inherit pname version;
pyproject = true;
build-system = [
ps.setuptools
ps.wheel
];
dependencies = [
ps.xonsh
];
src = fetchFromGitHub {
owner = "amadaluzia";
repo = pname;
rev = "cac9cfec70ec15b0ed4f1c8a18154ea9b4f8fb47";
hash = "sha256-UkRPdaZFNP8qv7lMwsTUalnre3k2UMfqMzmiTveLiBM=";
};
})
(let
pname = "xonsh-direnv";
version = "1.6.5";
in
ps.buildPythonPackage {
inherit pname version;
src = fetchFromGitHub {
owner = "74th";
repo = pname;
tag = version;
hash = "sha256-huBJ7WknVCk+WgZaXHlL+Y1sqsn6TYqMP29/fsUPSyU=";
};
})
];
};
inherit (cfg) package;
enable = true;
};
};
environment.systemPackages = [
pkgs.zoxide
pkgs.amadaluzian-starship
];
};
}