From 3f2f7f8efa57cb820d947b07a5a513764a45b462 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 3 Feb 2021 20:48:34 -0300 Subject: [PATCH] rofi: add support for lists in rasi (#1768) This is now supported without the need of using to represent them: https://github.com/davatorium/rofi-themes/blob/9a843caa86d15038fda5455b7fb951569dbd227a/Official%20Themes/solarized.rasi#L134 --- modules/programs/rofi.nix | 15 ++++++++++++--- tests/modules/programs/rofi/custom-theme.nix | 5 ++++- tests/modules/programs/rofi/custom-theme.rasi | 4 ++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index e59e14d42..8167c8af3 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -112,6 +112,8 @@ let value.value else if isString value then ''"${value}"'' + else if isList value then + "[ ${strings.concatStringsSep "," (map mkValueString value)} ]" else abort "Unhandled value type ${builtins.typeOf value}"; @@ -145,7 +147,9 @@ let left = 8; }; - configType = with types; attrsOf (oneOf [ str int bool rasiLiteral ]); + primitive = with types; (oneOf [ str int bool rasiLiteral ]); + + configType = with types; attrsOf (either primitive (listOf primitive)); rasiLiteral = types.submodule { options = { @@ -331,15 +335,20 @@ in { default = null; type = with types; nullOr (oneOf [ str path themeType ]); example = literalExample '' - with config.lib.formats.rasi; { + let + inherit (config.lib.formats.rasi) mkLiteral; + in { "*" = { - # config.lib.formats.rasi.mkLiteral unquotes the value background-color = mkLiteral "#000000"; foreground-color = mkLiteral "rgba ( 250, 251, 252, 100 % )"; border-color = mkLiteral "#FFFFFF"; width = 512; }; + "#inputbar" = { + children = map mkLiteral [ "prompt" "entry" ]; + }; + "#textbox-prompt-colon" = { expand = false; str = ":"; diff --git a/tests/modules/programs/rofi/custom-theme.nix b/tests/modules/programs/rofi/custom-theme.nix index 7c1ef81da..c787242d8 100644 --- a/tests/modules/programs/rofi/custom-theme.nix +++ b/tests/modules/programs/rofi/custom-theme.nix @@ -7,7 +7,8 @@ with lib; programs.rofi = { enable = true; - theme = with config.lib.formats.rasi; { + theme = let inherit (config.lib.formats.rasi) mkLiteral; + in { "*" = { background-color = mkLiteral "#000000"; foreground-color = mkLiteral "rgba ( 250, 251, 252, 100 % )"; @@ -15,6 +16,8 @@ with lib; width = 512; }; + "#inputbar" = { children = map mkLiteral [ "prompt" "entry" ]; }; + "#textbox-prompt-colon" = { expand = false; str = ":"; diff --git a/tests/modules/programs/rofi/custom-theme.rasi b/tests/modules/programs/rofi/custom-theme.rasi index 870659c77..bf9bb9cc6 100644 --- a/tests/modules/programs/rofi/custom-theme.rasi +++ b/tests/modules/programs/rofi/custom-theme.rasi @@ -1,3 +1,7 @@ +#inputbar { +children: [ prompt,entry ]; +} + #textbox-prompt-colon { expand: false; margin: 0px 0.3em 0em 0em;