From 210b57b9924363852687e7aae3ec0f3864a4742a Mon Sep 17 00:00:00 2001 From: pagedmov Date: Tue, 3 Mar 2026 23:44:16 -0500 Subject: [PATCH] Added a 'functions' option to the home manager module --- nix/hm-module.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nix/hm-module.nix b/nix/hm-module.nix index 3a3becd..d12ba9f 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -5,6 +5,11 @@ let boolToString = b: if b then "true" else "false"; + mkFunctionDef = name: body: '' +${name}() { +${body} +}''; + mkKeymapCmd = cfg: let flags = "-${lib.concatStrings cfg.modes}"; keys = "'${cfg.keys}'"; @@ -44,7 +49,13 @@ in aliases = lib.mkOption { type = lib.types.attrsOf lib.types.str; default = {}; - description = "Aliases to set when shed starts (e.g. ls='ls --color=auto')"; + description = "Aliases to set when shed starts"; + }; + + functions = lib.mkOption { + type = lib.types.attrsOf lib.types.str; + default = {}; + description = "Shell functions to set when shed starts"; }; keymaps = lib.mkOption { @@ -231,6 +242,7 @@ in let completeLines = lib.concatLines (lib.mapAttrsToList mkCompleteCmd cfg.extraCompletion); keymapLines = lib.concatLines (map mkKeymapCmd cfg.keymaps); + functionLines = lib.concatLines (lib.mapAttrsToList mkFunctionDef cfg.functions); in lib.mkIf cfg.enable { home.packages = [ cfg.package ]; @@ -254,6 +266,7 @@ in "shopt prompt.comp_limit=${toString cfg.settings.completionLimit}" "shopt prompt.highlight=${boolToString cfg.settings.syntaxHighlighting}" "shopt prompt.linebreak_on_incomplete=${boolToString cfg.settings.linebreakOnIncomplete}" + functionLines completeLines keymapLines ])