alqueva/hosts/shared/xonsh.nix

36 lines
767 B
Nix
Raw Normal View History

2024-10-29 15:37:11 +00:00
{
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")
]);
2024-10-29 15:37:11 +00:00
in {
options.alqueva.xonsh = {
enable = lib.mkEnableOption "xonsh";
package = lib.mkPackageOption pkgs "xonsh" {};
2024-10-29 15:37:11 +00:00
};
config = lib.mkIf cfg.enable {
programs = {
xonsh = {
config =
"from xonsh.xontribs import get_xontribs\n"
+ attrsToPyDict config.environment.shellAliases
2024-10-29 15:37:11 +00:00
+ ''
2024-11-02 17:48:54 +00:00
for xontrib in get_xontribs():
xontrib load @(xontrib)
2024-10-29 15:37:11 +00:00
'';
inherit (cfg) package;
2024-10-29 15:37:11 +00:00
enable = true;
};
};
};
}