2020-06-16 01:47:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.ne;
|
|
|
|
|
|
|
|
autoPrefFiles = let
|
|
|
|
autoprefs = cfg.automaticPreferences
|
|
|
|
// optionalAttrs (cfg.defaultPreferences != "") {
|
|
|
|
".default" = cfg.defaultPreferences;
|
|
|
|
};
|
|
|
|
|
|
|
|
gen = fileExtension: configText:
|
|
|
|
nameValuePair ".ne/${fileExtension}#ap" {
|
|
|
|
text = configText;
|
|
|
|
}; # Generates [path].text format expected by home.file.
|
|
|
|
in mapAttrs' gen autoprefs;
|
|
|
|
|
|
|
|
in {
|
|
|
|
meta.maintainers = [ hm.maintainers.cwyc ];
|
|
|
|
|
|
|
|
options.programs.ne = {
|
2023-07-01 23:45:18 +00:00
|
|
|
enable = mkEnableOption "ne";
|
2020-06-16 01:47:58 +00:00
|
|
|
|
|
|
|
keybindings = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
KEY 7f BS
|
|
|
|
SEQ "\x1b[1;5D" 7f
|
|
|
|
'';
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-06-16 01:47:58 +00:00
|
|
|
Keybinding file for ne.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
defaultPreferences = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-06-16 01:47:58 +00:00
|
|
|
Default preferences for ne.
|
2023-06-30 23:30:13 +00:00
|
|
|
|
|
|
|
Equivalent to `programs.ne.automaticPreferences.".default"`.
|
2020-06-16 01:47:58 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
automaticPreferences = mkOption {
|
|
|
|
type = types.attrsOf types.lines;
|
|
|
|
default = { };
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2020-06-16 01:47:58 +00:00
|
|
|
{
|
|
|
|
nix = '''
|
|
|
|
TAB 0
|
|
|
|
TS 2
|
|
|
|
''';
|
|
|
|
js = '''
|
|
|
|
TS 4
|
|
|
|
''';
|
|
|
|
}
|
|
|
|
'';
|
2023-07-01 23:45:18 +00:00
|
|
|
description = ''
|
2020-06-16 01:47:58 +00:00
|
|
|
Automatic preferences files for ne.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
menus = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Menu configuration file for ne.";
|
2020-06-16 01:47:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virtualExtensions = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s*
|
|
|
|
csh 1 ^#!\s*/.*\b(csh|tcsh)\s*
|
|
|
|
'';
|
2023-07-01 23:45:18 +00:00
|
|
|
description = "Virtual extensions configuration file for ne.";
|
2020-06-16 01:47:58 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ pkgs.ne ];
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
}
|