diff --git a/pkgs/shells/fish/wrapper.nix b/pkgs/shells/fish/wrapper.nix new file mode 100644 index 00000000000..053568bc6b9 --- /dev/null +++ b/pkgs/shells/fish/wrapper.nix @@ -0,0 +1,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 + " "$@" +'') diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d4ca2d6f741..2e6911c6939 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8843,6 +8843,8 @@ in fish = callPackage ../shells/fish { }; + wrapFish = callPackage ../shells/fish/wrapper.nix { }; + fishPlugins = recurseIntoAttrs (callPackage ../shells/fish/plugins { }); ion = callPackage ../shells/ion {