fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . ne ; 8 9autoPrefFiles = let 10autoprefs = cfg . automaticPreferences 11// optionalAttrs ( cfg . defaultPreferences != "" ) { 12".default" = cfg . defaultPreferences ; 13}; 14 15gen = fileExtension :configText : 16nameValuePair ".ne/ ${ fileExtension } #ap" { 17text = configText ; 18}; # Generates [path].text format expected by home.file. 19in mapAttrs' gen autoprefs ; 20 21in { 22meta . maintainers = [ hm . maintainers . cwyc ]; 23 24options . programs . ne = { 25enable = mkEnableOption "ne" ; 26 27keybindings = mkOption { 28type = types . lines ; 29default = "" ; 30example = '' 31KEY 7f BS 32SEQ "\x1b[1;5D" 7f 33'' ; 34description = '' 35Keybinding file for ne. 36'' ; 37}; 38 39defaultPreferences = mkOption { 40type = types . lines ; 41default = "" ; 42description = '' 43Default preferences for ne. 44 45Equivalent to `programs.ne.automaticPreferences.".default"`. 46'' ; 47}; 48 49automaticPreferences = mkOption { 50type = types . attrsOf types . lines ; 51default = { }; 52example = literalExpression '' 53{ 54nix = ''' 55TAB 0 56TS 2 57'''; 58js = ''' 59TS 4 60'''; 61} 62'' ; 63description = '' 64Automatic preferences files for ne. 65'' ; 66}; 67 68menus = mkOption { 69type = types . lines ; 70default = "" ; 71description = "Menu configuration file for ne." ; 72}; 73 74virtualExtensions = mkOption { 75type = types . lines ; 76default = "" ; 77example = '' 78sh 1 ^#!\s*/.*\b(bash|sh|ksh|zsh)\s* 79csh 1 ^#!\s*/.*\b(csh|tcsh)\s* 80'' ; 81description = "Virtual extensions configuration file for ne." ; 82}; 83}; 84 85config = mkIf cfg . enable { 86home . packages = [ pkgs . ne ]; 87 88home . file = { 89".ne/.keys" = mkIf ( cfg . keybindings != "" ) { text = cfg . keybindings ; }; 90".ne/.extensions" = 91mkIf ( cfg . virtualExtensions != "" ) { text = cfg . virtualExtensions ; }; 92".ne/.menus" = mkIf ( cfg . menus != "" ) { text = cfg . menus ; }; 93} // autoPrefFiles ; 94}; 95}