about summary refs log tree commit diff
path: root/pkgs/shells/fish
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2022-09-17 18:12:16 +0200
committerPol Dellaiera <pol.dellaiera@protonmail.com>2022-09-22 09:46:21 +0200
commitee0a5955040f3c145f67bd3afc2a293223a7b7ea (patch)
treef3f6ad20401afd92d007a150961c2adcc7e23f3b /pkgs/shells/fish
parent1066f0ef92a2f869709eb0515694a1139f23065c (diff)
wrapFish: Add `localConfig` and `shellAliases` parameters.
Diffstat (limited to 'pkgs/shells/fish')
-rw-r--r--pkgs/shells/fish/wrapper.nix40
1 files changed, 31 insertions, 9 deletions
diff --git a/pkgs/shells/fish/wrapper.nix b/pkgs/shells/fish/wrapper.nix
index f978f2bdfa4d1..c5c55bb71103d 100644
--- a/pkgs/shells/fish/wrapper.nix
+++ b/pkgs/shells/fish/wrapper.nix
@@ -1,25 +1,47 @@
-{ lib, writeShellScriptBin, fish }:
+{ lib, writeShellScriptBin, fish, writeTextFile }:
 
-with lib;
-
-makeOverridable ({
+lib.makeOverridable ({
   completionDirs ? [],
   functionDirs ? [],
   confDirs ? [],
-  pluginPkgs ? []
+  pluginPkgs ? [],
+  localConfig ? "",
+  shellAliases ? {}
 }:
 
 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;
+  confPath = confDirs
+    ++ (map (vendorDir "conf") pluginPkgs)
+    ++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]);
 
 in writeShellScriptBin "fish" ''
   ${fish}/bin/fish --init-command "
-    set --prepend fish_complete_path ${escapeShellArgs complPath}
-    set --prepend fish_function_path ${escapeShellArgs funcPath}
-    set --local fish_conf_source_path ${escapeShellArgs confPath}
+    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
   " "$@"
 '')