about summary refs log tree commit diff
path: root/users/aspen/system/home/modules/lib/zshFunctions.nix
diff options
context:
space:
mode:
Diffstat (limited to 'users/aspen/system/home/modules/lib/zshFunctions.nix')
-rw-r--r--users/aspen/system/home/modules/lib/zshFunctions.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/users/aspen/system/home/modules/lib/zshFunctions.nix b/users/aspen/system/home/modules/lib/zshFunctions.nix
new file mode 100644
index 0000000000..228dc6379f
--- /dev/null
+++ b/users/aspen/system/home/modules/lib/zshFunctions.nix
@@ -0,0 +1,23 @@
+{ 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
+  );
+}