aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/shells/fish/wrapper.nix
blob: 053568bc6b9bba16d78fa8f066dd587218448ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{ lib, writeShellScriptBin, fish }:

with lib;

makeOverridable ({
  completionDirs ? [],
  functionDirs ? [],
  confDirs ? [],
  pluginPkgs ? []
}:

let
  vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
  complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
  funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
  confPath = confDirs ++ map (vendorDir "conf") pluginPkgs;
  safeConfPath = map escapeShellArg confPath;

in writeShellScriptBin "fish" ''
  ${fish}/bin/fish --init-command "
    set --prepend fish_complete_path ${escapeShellArgs complPath}
    set --prepend fish_function_path ${escapeShellArgs funcPath}
    for c in {${concatStringsSep "," safeConfPath}}/*; source $c; end
  " "$@"
'')