blob: 75213809821f25c84a617c0edc961a5a96fa9d8d (
plain) (
blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
{ lib, writeShellApplication, fish, writeTextFile }:
lib.makeOverridable ({
completionDirs ? [],
functionDirs ? [],
confDirs ? [],
pluginPkgs ? [],
localConfig ? "",
shellAliases ? {},
runtimeInputs ? []
}:
let
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 = ''
status --is-interactive; and begin
# Aliases
${aliasesStr}
end
'';
};
localFishConfig = writeTextFile {
name = "wrapfish.local.fish";
destination = "/share/fish/vendor_conf.d/config.local.fish";
text = localConfig;
};
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)
++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]);
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
" "$@"
'';
})
|