1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 21:49:48 +01:00

xonsh:init

This commit is contained in:
paki23 2024-05-30 23:36:22 +02:00
parent 2598861031
commit 2080291ee6
No known key found for this signature in database
GPG key ID: 13160FFB4CEB03F2
2 changed files with 65 additions and 0 deletions

View file

@ -254,6 +254,7 @@ let
./programs/wpaperd.nix
./programs/xmobar.nix
./programs/xplr.nix
./programs/xonsh.nix
./programs/yambar.nix
./programs/yazi.nix
./programs/yt-dlp.nix

View file

@ -0,0 +1,64 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xonsh;
inherit (lib) types mkOption;
in {
options.programs.xonsh = {
enable = lib.mkEnableOption "xonsh";
package = lib.mkPackageOption pkgs "xonsh" { };
finalPackage = lib.mkOption {
type = types.package;
internal = true;
description = "Package that will actually get installed";
};
xonshrc = mkOption {
type = types.lines;
default = "";
description = ''
The contents of .xonshrc
'';
};
pythonPackages = mkOption {
type = types.raw;
default = pkgs.pythonPackages;
defaultText = "pkgs.pythonPackages";
description = ''
The pythonPackages set extraPackages are taken from
'';
};
shellAliases = mkOption {
type = with types; attrsOf (listOf str);
default = { };
example = { ll = [ "ls" "-l" ]; };
description = ''
An attribute set that maps aliases (the top level attribute names in
this option) to commands
'';
};
extraPackages = mkOption {
type = with types; functionTo (listOf package);
default = _: [ ];
defaultText = "_: []";
description = ''
List of python packages and xontrib to make avaiable
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.finalPackage ];
programs.xonsh = {
xonshrc = lib.mkMerge
(lib.mapAttrsToList (n: v: "aliases['${n}']=${builtins.toJSON v}")
cfg.shellAliases);
shellAliases = lib.mapAttrs (n: v: lib.mkDefault (lib.splitString " " v))
config.home.shellAliases;
finalPackage =
(cfg.package.override (old: { inherit (cfg) extraPackages; }));
};
xdg.configFile."xonsh/rc.xsh" = {
enable = cfg.xonshrc != "";
text = cfg.xonshrc;
};
};
}