feat(home): shellAbbrs module

This commit is contained in:
punkfairie 2024-11-15 17:59:32 -08:00
parent 6ef9ec385a
commit 35c4b54705
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696

View file

@ -1,21 +1,20 @@
{ { config, lib, ... }:
config,
lib,
...
}:
with lib;
let let
inherit (lib)
types
mkOption
attrsets
literalExpression
mkIf
;
# https://github.com/nix-community/home-manager/blob/master/modules/programs/fish.nix # https://github.com/nix-community/home-manager/blob/master/modules/programs/fish.nix
abbrModule = types.submodule { abbrModule = types.submodule {
options = { options = {
expansion = mkOption { expansion = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = null; default = null;
description = '' description = "The command expanded by an abbreviation.";
The command expanded by an abbreviation.
'';
}; };
position = mkOption { position = mkOption {
@ -23,9 +22,9 @@ let
default = null; default = null;
example = "anywhere"; example = "anywhere";
description = '' description = ''
If the position is "command", the abbreviation expands only if If the position is "command", the abbreviation expands only if the
the position is a command. If it is "anywhere", the abbreviation position is a command. If it is "anywhere", the abbreviation expands
expands anywhere. anywhere.
''; '';
}; };
@ -50,9 +49,7 @@ let
function = mkOption { function = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = null; default = null;
description = '' description = "The fish function expanded instead of a literal string.";
The fish function expanded instead of a literal string.
'';
}; };
}; };
}; };
@ -82,9 +79,9 @@ in
} }
''; '';
description = '' description = ''
An attribute set that maps aliases (the top level attribute names An attribute set that maps aliases (the top level attribute names in
in this option) to abbreviations. Abbreviations are expanded with this option) to abbreviations. Abbreviations are expanded with the
the longer phrase after they are entered. longer phrase after they are entered.
''; '';
}; };
}; };
@ -92,7 +89,7 @@ in
config = config =
let let
fishCfg = config.programs.fish; fishCfg = config.programs.fish;
shellAbbrs = config.home.shellAbbrs; inherit (config.home) shellAbbrs;
in in
{ {
programs.fish.shellAbbrs = mkIf fishCfg.enable shellAbbrs; programs.fish.shellAbbrs = mkIf fishCfg.enable shellAbbrs;