Added a 'functions' option to the home manager module
This commit is contained in:
@@ -5,6 +5,11 @@ let
|
|||||||
boolToString = b:
|
boolToString = b:
|
||||||
if b then "true" else "false";
|
if b then "true" else "false";
|
||||||
|
|
||||||
|
mkFunctionDef = name: body: ''
|
||||||
|
${name}() {
|
||||||
|
${body}
|
||||||
|
}'';
|
||||||
|
|
||||||
mkKeymapCmd = cfg: let
|
mkKeymapCmd = cfg: let
|
||||||
flags = "-${lib.concatStrings cfg.modes}";
|
flags = "-${lib.concatStrings cfg.modes}";
|
||||||
keys = "'${cfg.keys}'";
|
keys = "'${cfg.keys}'";
|
||||||
@@ -44,7 +49,13 @@ in
|
|||||||
aliases = lib.mkOption {
|
aliases = lib.mkOption {
|
||||||
type = lib.types.attrsOf lib.types.str;
|
type = lib.types.attrsOf lib.types.str;
|
||||||
default = {};
|
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 {
|
keymaps = lib.mkOption {
|
||||||
@@ -231,6 +242,7 @@ in
|
|||||||
let
|
let
|
||||||
completeLines = lib.concatLines (lib.mapAttrsToList mkCompleteCmd cfg.extraCompletion);
|
completeLines = lib.concatLines (lib.mapAttrsToList mkCompleteCmd cfg.extraCompletion);
|
||||||
keymapLines = lib.concatLines (map mkKeymapCmd cfg.keymaps);
|
keymapLines = lib.concatLines (map mkKeymapCmd cfg.keymaps);
|
||||||
|
functionLines = lib.concatLines (lib.mapAttrsToList mkFunctionDef cfg.functions);
|
||||||
in
|
in
|
||||||
lib.mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
@@ -254,6 +266,7 @@ in
|
|||||||
"shopt prompt.comp_limit=${toString cfg.settings.completionLimit}"
|
"shopt prompt.comp_limit=${toString cfg.settings.completionLimit}"
|
||||||
"shopt prompt.highlight=${boolToString cfg.settings.syntaxHighlighting}"
|
"shopt prompt.highlight=${boolToString cfg.settings.syntaxHighlighting}"
|
||||||
"shopt prompt.linebreak_on_incomplete=${boolToString cfg.settings.linebreakOnIncomplete}"
|
"shopt prompt.linebreak_on_incomplete=${boolToString cfg.settings.linebreakOnIncomplete}"
|
||||||
|
functionLines
|
||||||
completeLines
|
completeLines
|
||||||
keymapLines
|
keymapLines
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user