about summary refs log tree commit diff
path: root/users/aspen/system/home/modules/lib/zshFunctions.nix
blob: 228dc6379fd6024f846d463f34e44b85a246573f (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
{ 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
  );
}