1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

rofi: support top-level clauses in rasi (#1788)

See https://github.com/nix-community/home-manager/pull/1748#issuecomment-774995577
for details.

Related documentation:
920de75c4b (splitting-configuration-over-multiple-files)
This commit is contained in:
Thiago Kenji Okada 2021-02-09 11:59:29 -03:00 committed by GitHub
parent e6f2687a83
commit 87e2ec341b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 16 deletions

View file

@ -117,23 +117,27 @@ let
else else
abort "Unhandled value type ${builtins.typeOf value}"; abort "Unhandled value type ${builtins.typeOf value}";
mkKeyValue = name: value: "${name}: ${mkValueString value};"; mkKeyValue = { sep ? ": ", end ? ";" }:
name: value:
"${name}${sep}${mkValueString value}${end}";
mkRasiSection = section: config: mkRasiSection = name: value:
let if isAttrs value then
toRasiKeyValue = generators.toKeyValue { inherit mkKeyValue; }; let
# Remove null values so the resulting config does not have empty lines toRasiKeyValue = generators.toKeyValue { mkKeyValue = mkKeyValue { }; };
configStr = toRasiKeyValue (filterAttrs (_: v: v != null) config); # Remove null values so the resulting config does not have empty lines
in '' configStr = toRasiKeyValue (filterAttrs (_: v: v != null) value);
${section} { in ''
${configStr}} ${name} {
''; ${configStr}}
''
else
mkKeyValue {
sep = " ";
end = "";
} name value;
toRasi = attrsOfAttrs: toRasi = attrs: concatStringsSep "\n" (mapAttrsToList mkRasiSection attrs);
let
mkSection = mkRasiSection;
sections = mapAttrsToList mkSection attrsOfAttrs;
in concatStringsSep "\n" sections;
locationsMap = { locationsMap = {
center = 0; center = 0;
@ -149,7 +153,9 @@ let
primitive = with types; (oneOf [ str int bool rasiLiteral ]); primitive = with types; (oneOf [ str int bool rasiLiteral ]);
configType = with types; attrsOf (either primitive (listOf primitive)); # Either a `section { foo: "bar"; }` or a `@import/@theme "some-text"`
configType = with types;
(either (attrsOf (either primitive (listOf primitive))) str);
rasiLiteral = types.submodule { rasiLiteral = types.submodule {
options = { options = {

View file

@ -9,6 +9,8 @@ with lib;
theme = let inherit (config.lib.formats.rasi) mkLiteral; theme = let inherit (config.lib.formats.rasi) mkLiteral;
in { in {
"@import" = "~/.cache/wal/colors-rofi-dark";
"*" = { "*" = {
background-color = mkLiteral "#000000"; background-color = mkLiteral "#000000";
foreground-color = mkLiteral "rgba ( 250, 251, 252, 100 % )"; foreground-color = mkLiteral "rgba ( 250, 251, 252, 100 % )";

View file

@ -15,3 +15,5 @@ border-color: #FFFFFF;
foreground-color: rgba ( 250, 251, 252, 100 % ); foreground-color: rgba ( 250, 251, 252, 100 % );
width: 512; width: 512;
} }
@import "~/.cache/wal/colors-rofi-dark"