fork/home-manager
git clone https://git.julia.blue/fork/home-manager
a4817894
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . z-lua ; 8 9aliases = { 10zz = "z -c" ; # restrict matches to subdirs of $PWD 11zi = "z -i" ; # cd with interactive selection 12zf = "z -I" ; # use fzf to select in multiple matches 13zb = "z -b" ; # quickly cd to the parent directory 14zh = "z -I -t ." ; # fzf 15}; 16 17in { 18meta . maintainers = [ ]; 19 20options . programs . z-lua = { 21enable = mkEnableOption "z.lua" ; 22 23options = mkOption { 24type = types . listOf types . str ; 25default = [ ]; 26example = [ "enhanced" "once" "fzf" ]; 27description = '' 28List of options to pass to z.lua. 29'' ; 30}; 31 32enableBashIntegration = mkOption { 33default = true ; 34type = types . bool ; 35description = '' 36Whether to enable Bash integration. 37'' ; 38}; 39 40enableZshIntegration = mkOption { 41default = true ; 42type = types . bool ; 43description = '' 44Whether to enable Zsh integration. 45'' ; 46}; 47 48enableFishIntegration = mkOption { 49default = true ; 50type = types . bool ; 51description = '' 52Whether to enable Fish integration. 53'' ; 54}; 55 56enableAliases = mkOption { 57default = false ; 58type = types . bool ; 59description = '' 60Whether to enable recommended z.lua aliases. 61'' ; 62}; 63}; 64 65config = mkIf cfg . enable { 66home . packages = [ pkgs . z-lua ]; 67 68programs . bash . initExtra = mkIf cfg . enableBashIntegration '' 69eval "$( ${ pkgs . z-lua } /bin/z --init bash ${ 70concatStringsSep " " cfg . options 71} )" 72'' ; 73 74programs . zsh . initExtra = mkIf cfg . enableZshIntegration '' 75eval "$( ${ pkgs . z-lua } /bin/z --init zsh ${ 76concatStringsSep " " cfg . options 77} )" 78'' ; 79 80programs . fish . shellInit = mkIf cfg . enableFishIntegration '' 81source ( ${ pkgs . z-lua } /bin/z --init fish ${ 82concatStringsSep " " cfg . options 83} | psub) 84'' ; 85 86programs . bash . shellAliases = mkIf cfg . enableAliases aliases ; 87 88programs . zsh . shellAliases = mkIf cfg . enableAliases aliases ; 89 90programs . fish . shellAliases = mkIf cfg . enableAliases aliases ; 91}; 92}