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 . skim ; 8 9in { 10options . programs . skim = { 11enable = mkEnableOption "skim - a command-line fuzzy finder" ; 12 13package = mkOption { 14type = types . package ; 15default = pkgs . skim ; 16defaultText = literalExpression "pkgs.skim" ; 17description = "Package providing the {command}`skim` tool." ; 18}; 19 20defaultCommand = mkOption { 21type = types . nullOr types . str ; 22default = null ; 23example = "fd --type f" ; 24description = '' 25The command that gets executed as the default source for skim 26when running. 27'' ; 28}; 29 30defaultOptions = mkOption { 31type = types . listOf types . str ; 32default = [ ]; 33example = [ "--height 40%" "--prompt ⟫" ]; 34description = '' 35Extra command line options given to skim by default. 36'' ; 37}; 38 39fileWidgetCommand = mkOption { 40type = types . nullOr types . str ; 41default = null ; 42example = "fd --type f" ; 43description = '' 44The command that gets executed as the source for skim for the 45CTRL-T keybinding. 46'' ; 47}; 48 49fileWidgetOptions = mkOption { 50type = types . listOf types . str ; 51default = [ ]; 52example = [ "--preview 'head {}'" ]; 53description = '' 54Command line options for the CTRL-T keybinding. 55'' ; 56}; 57 58changeDirWidgetCommand = mkOption { 59type = types . nullOr types . str ; 60default = null ; 61example = "fd --type d" ; 62description = '' 63The command that gets executed as the source for skim for the 64ALT-C keybinding. 65'' ; 66}; 67 68changeDirWidgetOptions = mkOption { 69type = types . listOf types . str ; 70default = [ ]; 71example = [ "--preview 'tree -C {} | head -200'" ]; 72description = '' 73Command line options for the ALT-C keybinding. 74'' ; 75}; 76 77historyWidgetOptions = mkOption { 78type = types . listOf types . str ; 79default = [ ]; 80example = [ "--tac" "--exact" ]; 81description = '' 82Command line options for the CTRL-R keybinding. 83'' ; 84}; 85 86enableBashIntegration = mkOption { 87default = true ; 88type = types . bool ; 89description = '' 90Whether to enable Bash integration. 91'' ; 92}; 93 94enableZshIntegration = mkOption { 95default = true ; 96type = types . bool ; 97description = '' 98Whether to enable Zsh integration. 99'' ; 100}; 101 102enableFishIntegration = mkOption { 103default = true ; 104type = types . bool ; 105description = '' 106Whether to enable Fish integration. 107'' ; 108}; 109}; 110 111config = mkIf cfg . enable { 112home . packages = [ cfg . package ]; 113 114home . sessionVariables = mapAttrs ( n :v :toString v ) 115( filterAttrs ( n :v :v != [ ] && v != null ) { 116SKIM_ALT_C_COMMAND = cfg . changeDirWidgetCommand ; 117SKIM_ALT_C_OPTS = cfg . changeDirWidgetOptions ; 118SKIM_CTRL_R_OPTS = cfg . historyWidgetOptions ; 119SKIM_CTRL_T_COMMAND = cfg . fileWidgetCommand ; 120SKIM_CTRL_T_OPTS = cfg . fileWidgetOptions ; 121SKIM_DEFAULT_COMMAND = cfg . defaultCommand ; 122SKIM_DEFAULT_OPTIONS = cfg . defaultOptions ; 123}); 124 125programs . bash . initExtra = mkIf cfg . enableBashIntegration '' 126if [[ :$SHELLOPTS: =~ :(vi|emacs): ]]; then 127. ${ cfg . package } /share/skim/completion.bash 128. ${ cfg . package } /share/skim/key-bindings.bash 129fi 130'' ; 131 132programs . zsh . initExtra = mkIf cfg . enableZshIntegration '' 133if [[ $options[zle] = on ]]; then 134. ${ cfg . package } /share/skim/completion.zsh 135. ${ cfg . package } /share/skim/key-bindings.zsh 136fi 137'' ; 138 139programs . fish . shellInit = mkIf cfg . enableFishIntegration '' 140source ${ cfg . package } /share/skim/key-bindings.fish && skim_key_bindings 141'' ; 142}; 143}