alqueva/hosts/shared/xonsh.nix
2025-01-18 12:34:41 +00:00

35 lines
767 B
Nix

{
config,
pkgs,
lib,
...
}: let
cfg = config.alqueva.xonsh;
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 {
programs = {
xonsh = {
config =
"from xonsh.xontribs import get_xontribs\n"
+ attrsToPyDict config.environment.shellAliases
+ ''
for xontrib in get_xontribs():
xontrib load @(xontrib)
'';
inherit (cfg) package;
enable = true;
};
};
};
}