From 234de0270a3540be5661cbcc3d957a4952e02823 Mon Sep 17 00:00:00 2001 From: malte-v <34393802+malte-v@users.noreply.github.com> Date: Sun, 8 Nov 2020 18:37:58 +0100 Subject: [PATCH] broot: improve configuration The `invocation` is an optional attribute, so it doesn't make sense to use it as the key in an attribute set. See https://dystroy.org/broot/documentation/configuration/#verb-definition-attributes Actually, `invocation` should not be defined when one wants to rebind a built-in verb to a different key. Also added documentation for the `key` attribute. --- doc/release-notes/rl-2103.adoc | 23 +++++++++++++- modules/misc/news.nix | 23 ++++++++++++++ modules/programs/broot.nix | 58 ++++++++++++++++++++++------------ 3 files changed, 83 insertions(+), 21 deletions(-) diff --git a/doc/release-notes/rl-2103.adoc b/doc/release-notes/rl-2103.adoc index 212fa58b6..7d5b55d49 100644 --- a/doc/release-notes/rl-2103.adoc +++ b/doc/release-notes/rl-2103.adoc @@ -9,7 +9,28 @@ section is therefore not final. This release has the following notable changes: -* Nothing has happened. +* The <> option is now a list rather than an +attribute set. To migrate, move the keys of the attrset into the list +items' `invocation` keys. For example, ++ +[source,nix] +---- +programs.broot.verbs = { + "p" = { execution = ":parent"; }; +}; +---- ++ +becomes ++ +[source,nix] +---- +programs.broot.verbs = [ + { + invocation = "p"; + execution = ":parent"; + } +]; +---- [[sec-release-21.03-state-version-changes]] === State Version Changes diff --git a/modules/misc/news.nix b/modules/misc/news.nix index e42d0f6b6..689aa8f5e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1736,6 +1736,29 @@ in A new module is available: 'programs.i3status-rust'. ''; } + + { + time = "2020-11-14T13:02:40+00:00"; + condition = config.programs.broot.enable; + message = '' + The 'programs.broot.verbs' option is now a list rather than an + attribute set. To migrate, move the keys of the attrset into the + list items' 'invocation' keys. For example, + + programs.broot.verbs = { + "p" = { execution = ":parent"; }; + }; + + becomes + + programs.broot.verbs = [ + { + invocation = "p"; + execution = ":parent"; + } + ]; + ''; + } ]; }; } diff --git a/modules/programs/broot.nix b/modules/programs/broot.nix index 6951e035d..e711e8ae2 100644 --- a/modules/programs/broot.nix +++ b/modules/programs/broot.nix @@ -18,8 +18,7 @@ let ''; brootConf = { - verbs = - mapAttrsToList (name: value: value // { invocation = name; }) cfg.verbs; + verbs = cfg.verbs; skin = cfg.skin; }; @@ -54,41 +53,60 @@ in { }; verbs = mkOption { - type = with types; attrsOf (attrsOf (either bool str)); - default = { - "p" = { execution = ":parent"; }; - "edit" = { + type = with types; listOf (attrsOf (either bool str)); + default = [ + { + invocation = "p"; + execution = ":parent"; + } + { + invocation = "edit"; shortcut = "e"; execution = "$EDITOR {file}"; - }; - "create {subpath}" = { execution = "$EDITOR {directory}/{subpath}"; }; - "view" = { execution = "less {file}"; }; - }; - example = literalExample '' + } { - "p" = { execution = ":parent"; }; - "edit" = { shortcut = "e"; execution = "$EDITOR {file}" ; }; - "create {subpath}" = { execution = "$EDITOR {directory}/{subpath}"; }; - "view" = { execution = "less {file}"; }; - "blop {name}\\.{type}" = { + invocation = "create {subpath}"; + execution = "$EDITOR {directory}/{subpath}"; + } + { + invocation = "view"; + execution = "less {file}"; + } + ]; + example = literalExample '' + [ + { invocation = "p"; execution = ":parent"; } + { invocation = "edit"; shortcut = "e"; execution = "$EDITOR {file}" ; } + { invocation = "create {subpath}"; execution = "$EDITOR {directory}/{subpath}"; } + { invocation = "view"; execution = "less {file}"; } + { + invocation = "blop {name}\\.{type}"; execution = "/bin/mkdir {parent}/{type} && /usr/bin/nvim {parent}/{type}/{name}.{type}"; from_shell = true; - }; - } + } + ] ''; description = '' - Define new verbs. The attribute name indicates how the verb is - called by the user, with placeholders for arguments. + Define new verbs. For more information, see + . The possible attributes are: + + invocation (optional) + how the verb is called by the user, with placeholders for arguments + execution (mandatory) how the verb is executed + + key (optional) + a keyboard key triggering execution + shortcut (optional) an alternate way to call the verb (without