1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/ne.nix
Austin Horstman cba2f9ce95 treewide: reformat nixfmt-rfc-style
Reformat repository using new nixfmt-rfc-style.
2025-04-08 08:50:05 -07:00

104 lines
2.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf mkOption types;
cfg = config.programs.ne;
autoPrefFiles =
let
autoprefs =
cfg.automaticPreferences
// lib.optionalAttrs (cfg.defaultPreferences != "") {
".default" = cfg.defaultPreferences;
};
gen =
fileExtension: configText:
lib.nameValuePair ".ne/${fileExtension}#ap" {
text = configText;
}; # Generates [path].text format expected by home.file.
in
lib.mapAttrs' gen autoprefs;
in
{
meta.maintainers = [ lib.hm.maintainers.cwyc ];
options.programs.ne = {
enable = lib.mkEnableOption "ne";
package = lib.mkPackageOption pkgs "ne" { nullable = true; };
keybindings = mkOption {
type = types.lines;
default = "";
example = ''
KEY 7f BS
SEQ "\x1b[1;5D" 7f
'';
description = ''
Keybinding file for ne.
'';
};
defaultPreferences = mkOption {
type = types.lines;
default = "";
description = ''
Default preferences for ne.
Equivalent to `programs.ne.automaticPreferences.".default"`.
'';
};
automaticPreferences = mkOption {
type = types.attrsOf types.lines;
default = { };
example = lib.literalExpression ''
{
nix = '''
TAB 0
TS 2
''';
js = '''
TS 4
''';
}
'';
description = ''
Automatic preferences files for ne.
'';
};
menus = mkOption {
type = types.lines;
default = "";
description = "Menu configuration file for ne.";
};
virtualExtensions = mkOption {
type = types.lines;
default = "";
example = ''
sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s*
csh 1 ^#!\s*/.*\b(csh|tcsh)\s*
'';
description = "Virtual extensions configuration file for ne.";
};
};
config = mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file = {
".ne/.keys" = mkIf (cfg.keybindings != "") { text = cfg.keybindings; };
".ne/.extensions" = mkIf (cfg.virtualExtensions != "") { text = cfg.virtualExtensions; };
".ne/.menus" = mkIf (cfg.menus != "") { text = cfg.menus; };
} // autoPrefFiles;
};
}