2022-10-21 18:38:19 +00:00
|
|
|
{ lib, writeShellApplication, fish, writeTextFile }:
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
lib.makeOverridable ({
|
2021-01-15 22:18:51 +00:00
|
|
|
completionDirs ? [],
|
|
|
|
functionDirs ? [],
|
|
|
|
confDirs ? [],
|
2022-09-30 11:47:45 +00:00
|
|
|
pluginPkgs ? [],
|
|
|
|
localConfig ? "",
|
2022-10-21 18:38:19 +00:00
|
|
|
shellAliases ? {},
|
|
|
|
runtimeInputs ? []
|
2021-01-15 22:18:51 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-09-30 11:47:45 +00:00
|
|
|
aliasesStr = builtins.concatStringsSep "\n"
|
|
|
|
(lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases);
|
|
|
|
|
|
|
|
shellAliasesFishConfig = writeTextFile {
|
|
|
|
name = "wrapfish.aliases.fish";
|
|
|
|
destination = "/share/fish/vendor_conf.d/aliases.fish";
|
|
|
|
text = ''
|
2023-11-16 04:20:00 +00:00
|
|
|
status is-interactive; and begin
|
2022-09-30 11:47:45 +00:00
|
|
|
# Aliases
|
|
|
|
${aliasesStr}
|
|
|
|
end
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
localFishConfig = writeTextFile {
|
|
|
|
name = "wrapfish.local.fish";
|
|
|
|
destination = "/share/fish/vendor_conf.d/config.local.fish";
|
|
|
|
text = localConfig;
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
|
|
|
|
complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
|
|
|
|
funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
|
2022-09-30 11:47:45 +00:00
|
|
|
confPath = confDirs
|
|
|
|
++ (map (vendorDir "conf") pluginPkgs)
|
|
|
|
++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]);
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
in writeShellApplication {
|
|
|
|
inherit runtimeInputs;
|
|
|
|
name = "fish";
|
|
|
|
text = ''
|
|
|
|
${fish}/bin/fish --init-command "
|
|
|
|
set --prepend fish_complete_path ${lib.escapeShellArgs complPath}
|
|
|
|
set --prepend fish_function_path ${lib.escapeShellArgs funcPath}
|
|
|
|
set --local fish_conf_source_path ${lib.escapeShellArgs confPath}
|
|
|
|
for c in \$fish_conf_source_path/*; source \$c; end
|
|
|
|
" "$@"
|
|
|
|
'';
|
|
|
|
})
|