about summary refs log tree commit diff
path: root/home/modules/lib/zshFunctions.nix
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2020-06-08T14·19-0400
committerGriffin Smith <root@gws.fyi>2020-06-08T14·19-0400
commit77f3860a651ee7f35c8e65747c0c45fb001cfb0b (patch)
tree155c88c635600f507bbb7fd3b217843157b15fa2 /home/modules/lib/zshFunctions.nix
parentd59b69e6a39249e4834202e00cf9a78c24e33ca7 (diff)
add zshFunctions config option
Diffstat (limited to 'home/modules/lib/zshFunctions.nix')
-rw-r--r--home/modules/lib/zshFunctions.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/home/modules/lib/zshFunctions.nix b/home/modules/lib/zshFunctions.nix
new file mode 100644
index 000000000000..7c39b3478cfd
--- /dev/null
+++ b/home/modules/lib/zshFunctions.nix
@@ -0,0 +1,21 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+  options = {
+    programs.zsh.functions = mkOption {
+      description = "An attribute set that maps function names to their source";
+      default = {};
+      type = with types; attrsOf (either str path);
+    };
+  };
+
+  config.programs.zsh.initExtra = concatStringsSep "\n" (
+    mapAttrsToList (name: funSrc: ''
+      function ${name}() {
+        ${funSrc}
+      }
+    '') config.programs.zsh.functions
+  );
+}