Restructure Nix options to nest shopts under line/core/prompt submodules matching shopt key paths
This commit is contained in:
@@ -49,38 +49,38 @@ ${indented}
|
||||
autocmdLines = lib.concatLines (map mkAutoCmd cfg.autocmds);
|
||||
in
|
||||
lib.concatLines [
|
||||
cfg.settings.extraPreConfig
|
||||
cfg.extraPreConfig
|
||||
(lib.concatLines (lib.mapAttrsToList (name: value: "export ${name}=\"${value}\"") cfg.environmentVars))
|
||||
(lib.concatLines (lib.mapAttrsToList (name: value: "alias ${name}=\"${value}\"") cfg.aliases))
|
||||
(lib.concatLines [
|
||||
"shopt line.viewport_height=${toString cfg.settings.viewportHeight}"
|
||||
"shopt line.scroll_offset=${toString cfg.settings.scrollOffset}"
|
||||
"shopt line.viewport_height=${toString cfg.shopts.line.viewport_height}"
|
||||
"shopt line.scroll_offset=${toString cfg.shopts.line.scroll_offset}"
|
||||
|
||||
"shopt core.dotglob=${boolToString cfg.settings.dotGlob}"
|
||||
"shopt core.autocd=${boolToString cfg.settings.autocd}"
|
||||
"shopt core.hist_ignore_dupes=${boolToString cfg.settings.historyIgnoresDupes}"
|
||||
"shopt core.max_hist=${toString cfg.settings.maxHistoryEntries}"
|
||||
"shopt core.interactive_comments=${boolToString cfg.settings.interactiveComments}"
|
||||
"shopt core.auto_hist=${boolToString cfg.settings.autoHistory}"
|
||||
"shopt core.bell_enabled=${boolToString cfg.settings.bellEnabled}"
|
||||
"shopt core.max_recurse_depth=${toString cfg.settings.maxRecurseDepth}"
|
||||
"shopt core.xpg_echo=${boolToString cfg.settings.echoExpandsEscapes}"
|
||||
"shopt core.noclobber=${boolToString cfg.settings.noClobber}"
|
||||
"shopt core.dotglob=${boolToString cfg.shopts.core.dotglob}"
|
||||
"shopt core.autocd=${boolToString cfg.shopts.core.autocd}"
|
||||
"shopt core.hist_ignore_dupes=${boolToString cfg.shopts.core.hist_ignore_dupes}"
|
||||
"shopt core.max_hist=${toString cfg.shopts.core.max_hist}"
|
||||
"shopt core.interactive_comments=${boolToString cfg.shopts.core.interactive_comments}"
|
||||
"shopt core.auto_hist=${boolToString cfg.shopts.core.auto_hist}"
|
||||
"shopt core.bell_enabled=${boolToString cfg.shopts.core.bell_enabled}"
|
||||
"shopt core.max_recurse_depth=${toString cfg.shopts.core.max_recurse_depth}"
|
||||
"shopt core.xpg_echo=${boolToString cfg.shopts.core.xpg_echo}"
|
||||
"shopt core.noclobber=${boolToString cfg.shopts.core.noclobber}"
|
||||
|
||||
"shopt prompt.leader='${cfg.settings.leaderKey}'"
|
||||
"shopt prompt.trunc_prompt_path=${toString cfg.settings.promptPathSegments}"
|
||||
"shopt prompt.comp_limit=${toString cfg.settings.completionLimit}"
|
||||
"shopt prompt.highlight=${boolToString cfg.settings.syntaxHighlighting}"
|
||||
"shopt prompt.linebreak_on_incomplete=${boolToString cfg.settings.linebreakOnIncomplete}"
|
||||
"shopt prompt.line_numbers=${boolToString cfg.settings.lineNumbers}"
|
||||
"shopt prompt.screensaver_idle_time=${toString cfg.settings.screensaverIdleTime}"
|
||||
"shopt prompt.screensaver_cmd='${cfg.settings.screensaverCmd}'"
|
||||
"shopt prompt.completion_ignore_case=${boolToString cfg.settings.completionIgnoreCase}"
|
||||
"shopt prompt.auto_indent=${boolToString cfg.settings.autoIndent}"
|
||||
"shopt prompt.leader='${cfg.shopts.prompt.leader}'"
|
||||
"shopt prompt.trunc_prompt_path=${toString cfg.shopts.prompt.trunc_prompt_path}"
|
||||
"shopt prompt.comp_limit=${toString cfg.shopts.prompt.comp_limit}"
|
||||
"shopt prompt.highlight=${boolToString cfg.shopts.prompt.highlight}"
|
||||
"shopt prompt.linebreak_on_incomplete=${boolToString cfg.shopts.prompt.linebreak_on_incomplete}"
|
||||
"shopt prompt.line_numbers=${boolToString cfg.shopts.prompt.line_numbers}"
|
||||
"shopt prompt.screensaver_idle_time=${toString cfg.shopts.prompt.screensaver_idle_time}"
|
||||
"shopt prompt.screensaver_cmd='${cfg.shopts.prompt.screensaver_cmd}'"
|
||||
"shopt prompt.completion_ignore_case=${boolToString cfg.shopts.prompt.completion_ignore_case}"
|
||||
"shopt prompt.auto_indent=${boolToString cfg.shopts.prompt.auto_indent}"
|
||||
functionLines
|
||||
completeLines
|
||||
keymapLines
|
||||
autocmdLines
|
||||
])
|
||||
cfg.settings.extraPostConfig
|
||||
cfg.extraPostConfig
|
||||
]
|
||||
|
||||
@@ -155,26 +155,37 @@
|
||||
description = "Additional completion scripts to source when shed starts (e.g. for custom tools or functions)";
|
||||
};
|
||||
|
||||
viewportHeight = {
|
||||
type = lib.types.either lib.types.int lib.types.str;
|
||||
default = "50%";
|
||||
description = "Maximum viewport height for the line editor buffer";
|
||||
};
|
||||
|
||||
scrollOffset = {
|
||||
type = lib.types.int;
|
||||
default = "1";
|
||||
description = "The minimum number of lines to keep visible above and below the cursor when scrolling (i.e. the 'scrolloff' option in vim)";
|
||||
};
|
||||
|
||||
environmentVars = lib.mkOption {
|
||||
type = lib.types.attrsOf lib.types.str;
|
||||
default = {};
|
||||
description = "Environment variables to set when shed starts";
|
||||
};
|
||||
|
||||
settings = {
|
||||
dotGlob = lib.mkOption {
|
||||
shopts = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
line = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
viewport_height = lib.mkOption {
|
||||
type = lib.types.either lib.types.int lib.types.str;
|
||||
default = "50%";
|
||||
description = "Maximum viewport height for the line editor buffer";
|
||||
};
|
||||
scroll_offset = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 1;
|
||||
description = "The minimum number of lines to keep visible above and below the cursor when scrolling (i.e. the 'scrolloff' option in vim)";
|
||||
};
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = "Settings related to the line editor (i.e. the 'shopt line.*' options)";
|
||||
};
|
||||
core = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
dotglob = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to include hidden files in glob patterns";
|
||||
@@ -184,98 +195,113 @@
|
||||
default = false;
|
||||
description = "Whether to automatically change into directories when they are entered as commands";
|
||||
};
|
||||
historyIgnoresDupes = lib.mkOption {
|
||||
hist_ignore_dupes = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to ignore duplicate entries in the command history";
|
||||
};
|
||||
maxHistoryEntries = lib.mkOption {
|
||||
max_hist = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 10000;
|
||||
description = "The maximum number of entries to keep in the command history";
|
||||
};
|
||||
interactiveComments = lib.mkOption {
|
||||
interactive_comments = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to allow comments in interactive mode";
|
||||
};
|
||||
autoHistory = lib.mkOption {
|
||||
auto_hist = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to automatically add commands to the history as they are executed";
|
||||
};
|
||||
bellEnabled = lib.mkOption {
|
||||
bell_enabled = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to allow shed to ring the terminal bell on certain events (e.g. command completion, errors, etc.)";
|
||||
};
|
||||
maxRecurseDepth = lib.mkOption {
|
||||
max_recurse_depth = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 1000;
|
||||
description = "The maximum depth to allow when recursively executing shell functions";
|
||||
};
|
||||
echoExpandsEscapes = lib.mkOption {
|
||||
xpg_echo = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to have the 'echo' builtin expand escape sequences like \\n and \\t (if false, it will print them verbatim)";
|
||||
};
|
||||
noClobber = lib.mkOption {
|
||||
noclobber = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to prevent redirection from overwriting existing files by default (i.e. behave as if 'set -o noclobber' is always in effect)";
|
||||
};
|
||||
|
||||
leaderKey = lib.mkOption {
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = "Core settings (i.e. the 'shopt core.*' options)";
|
||||
};
|
||||
prompt = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
options = {
|
||||
leader = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "\\\\";
|
||||
description = "The leader key to use for custom keymaps (e.g. if set to '\\\\', then a keymap with keys='x' would be triggered by '\\x')";
|
||||
};
|
||||
promptPathSegments = lib.mkOption {
|
||||
trunc_prompt_path = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 4;
|
||||
description = "The maximum number of path segments to show in the prompt";
|
||||
};
|
||||
completionLimit = lib.mkOption {
|
||||
comp_limit = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 1000;
|
||||
description = "The maximum number of completion candidates to show before truncating the list";
|
||||
};
|
||||
syntaxHighlighting = lib.mkOption {
|
||||
highlight = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to enable syntax highlighting in the shell";
|
||||
};
|
||||
linebreakOnIncomplete = lib.mkOption {
|
||||
linebreak_on_incomplete = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to automatically insert a newline when the input is incomplete";
|
||||
};
|
||||
lineNumbers = lib.mkOption {
|
||||
line_numbers = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to show line numbers in the prompt";
|
||||
};
|
||||
screensaverCmd = lib.mkOption {
|
||||
screensaver_cmd = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "";
|
||||
description = "A shell command to execute after a period of inactivity (i.e. a custom screensaver)";
|
||||
};
|
||||
screensaverIdleTime = lib.mkOption {
|
||||
screensaver_idle_time = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 0;
|
||||
description = "The amount of inactivity time in seconds before the screensaver command is executed";
|
||||
};
|
||||
completionIgnoreCase = lib.mkOption {
|
||||
completion_ignore_case = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to ignore case when completing commands and file names";
|
||||
};
|
||||
autoIndent = lib.mkOption {
|
||||
auto_indent = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to automatically indent new lines based on the previous line";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = "Settings related to the prompt (i.e. the 'shopt prompt.*' options)";
|
||||
};
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
|
||||
extraPostConfig = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@@ -287,5 +313,4 @@
|
||||
default = "";
|
||||
description = "Additional configuration to prepend to the shed configuration file";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user