at master 1.7 kB view raw
1{ 2 lib, 3 writeShellApplication, 4 fish, 5 writeTextFile, 6}: 7 8lib.makeOverridable ( 9 { 10 completionDirs ? [ ], 11 functionDirs ? [ ], 12 confDirs ? [ ], 13 pluginPkgs ? [ ], 14 localConfig ? "", 15 shellAliases ? { }, 16 runtimeInputs ? [ ], 17 }: 18 19 let 20 aliasesStr = builtins.concatStringsSep "\n" ( 21 lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases 22 ); 23 24 shellAliasesFishConfig = writeTextFile { 25 name = "wrapfish.aliases.fish"; 26 destination = "/share/fish/vendor_conf.d/aliases.fish"; 27 text = '' 28 status is-interactive; and begin 29 # Aliases 30 ${aliasesStr} 31 end 32 ''; 33 }; 34 35 localFishConfig = writeTextFile { 36 name = "wrapfish.local.fish"; 37 destination = "/share/fish/vendor_conf.d/config.local.fish"; 38 text = localConfig; 39 }; 40 41 vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d"; 42 complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs; 43 funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs; 44 confPath = 45 confDirs 46 ++ (map (vendorDir "conf") pluginPkgs) 47 ++ (map (vendorDir "conf") [ 48 localFishConfig 49 shellAliasesFishConfig 50 ]); 51 52 in 53 writeShellApplication { 54 inherit runtimeInputs; 55 name = "fish"; 56 text = '' 57 ${fish}/bin/fish --init-command " 58 set --prepend fish_complete_path ${lib.escapeShellArgs complPath} 59 set --prepend fish_function_path ${lib.escapeShellArgs funcPath} 60 set --local fish_conf_source_path ${lib.escapeShellArgs confPath} 61 for c in \$fish_conf_source_path/*; source \$c; end 62 " "$@" 63 ''; 64 } 65)