mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 23:19:47 +01:00
65 lines
1.8 KiB
Nix
65 lines
1.8 KiB
Nix
|
{ 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;
|
||
|
};
|
||
|
};
|
||
|
}
|