1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

rofi: remove options removed from upstream in v1.7.0

This commit is contained in:
Thiago Kenji Okada 2021-10-08 13:45:22 -03:00 committed by Robert Helgesson
parent 82c92a18ba
commit 32285d8fe6
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 44 additions and 283 deletions

View file

@ -33,6 +33,10 @@ Ultimately, the benefits of loading all modules won and the behavior
has now changed. For associated discussion see
https://github.com/nix-community/home-manager/issues/1906[issue #1906].
* Rofi version 1.7.0 removed many options that were used by the module and replaced them with custom themes, which are more flexible and powerful.
+
You can replicate your old configuration by moving those options to <<opt-programs.rofi.theme>>. Keep in mind that the syntax is different so you may need to do some changes.
[[sec-release-21.11-state-version-changes]]
=== State Version Changes

View file

@ -536,23 +536,6 @@ in
'';
}
{
time = "2018-02-09T21:14:42+00:00";
condition = with config.programs.rofi; enable && colors != null;
message = ''
The new and preferred way to configure the rofi theme is
using rasi themes through the 'programs.rofi.theme' option.
This option can take as value either the name of a
pre-installed theme or the path to a theme file.
A rasi theme can be generated from an Xresources config
using 'rofi -dump-theme'.
The option 'programs.rofi.colors' is still supported but may
become deprecated and removed in the future.
'';
}
{
time = "2018-02-19T21:45:26+00:00";
message = ''
@ -2228,6 +2211,20 @@ in
A new module is available: 'programs.nnn'.
'';
}
{
time = "2021-10-08T22:16:50+00:00";
condition = hostPlatform.isLinux && config.programs.rofi.enable;
message = ''
Rofi version '1.7.0' removed many options that were used by the module
and replaced them with custom themes, which are more flexible and
powerful.
You can replicate your old configuration by moving those options to
'programs.rofi.theme'. Keep in mind that the syntax is different so
you may need to do some changes.
'';
}
];
};
}

View file

@ -6,109 +6,12 @@ let
cfg = config.programs.rofi;
colorOption = description:
mkOption {
type = types.str;
description = description;
};
rowColorSubmodule = types.submodule {
options = {
background = colorOption "Background color";
foreground = colorOption "Foreground color";
backgroundAlt = colorOption "Alternative background color";
highlight = mkOption {
type = types.submodule {
options = {
background = colorOption "Highlight background color";
foreground = colorOption "Highlight foreground color";
};
};
description = "Color settings for highlighted row.";
};
};
};
windowColorSubmodule = types.submodule {
options = {
background = colorOption "Window background color";
border = colorOption "Window border color";
separator = colorOption "Separator color";
};
};
colorsSubmodule = types.submodule {
options = {
window = mkOption {
default = null;
type = windowColorSubmodule;
description = "Window color settings.";
};
rows = mkOption {
default = null;
type = types.submodule {
options = {
normal = mkOption {
default = null;
type = types.nullOr rowColorSubmodule;
description = "Normal row color settings.";
};
active = mkOption {
default = null;
type = types.nullOr rowColorSubmodule;
description = "Active row color settings.";
};
urgent = mkOption {
default = null;
type = types.nullOr rowColorSubmodule;
description = "Urgent row color settings.";
};
};
};
description = "Rows color settings.";
};
};
};
windowColorsToString = window:
concatStringsSep ", " (with window; [ background border separator ]);
rowColorsToString = row:
concatStringsSep ", " (with row; [
background
foreground
backgroundAlt
highlight.background
highlight.foreground
]);
mkColorScheme = colors:
if colors != null then
with colors; {
color-window =
if (window != null) then (windowColorsToString window) else null;
color-normal = if (rows != null && rows.normal != null) then
(rowColorsToString rows.normal)
else
null;
color-active = if (rows != null && rows.active != null) then
(rowColorsToString rows.active)
else
null;
color-urgent = if (rows != null && rows.active != null) then
(rowColorsToString rows.urgent)
else
null;
}
else
{ };
mkValueString = value:
if isBool value then
if value then "true" else "false"
else if isInt value then
toString value
else if value._type or "" == "literal" then
else if (value._type or "") == "literal" then
value.value
else if isString value then
''"${value}"''
@ -216,41 +119,6 @@ in {
example = literalExample "[ pkgs.rofi-calc ]";
};
width = mkOption {
default = null;
type = types.nullOr types.int;
description = "Window width";
example = 100;
};
lines = mkOption {
default = null;
type = types.nullOr types.int;
description = "Number of lines";
example = 10;
};
borderWidth = mkOption {
default = null;
type = types.nullOr types.int;
description = "Border width";
example = 1;
};
rowHeight = mkOption {
default = null;
type = types.nullOr types.int;
description = "Row height (in chars)";
example = 1;
};
padding = mkOption {
default = null;
type = types.nullOr types.int;
description = "Padding";
example = 400;
};
font = mkOption {
default = null;
type = types.nullOr types.str;
@ -258,12 +126,6 @@ in {
description = "Font to use.";
};
scrollbar = mkOption {
default = null;
type = types.nullOr types.bool;
description = "Whether to show a scrollbar.";
};
terminal = mkOption {
default = null;
type = types.nullOr types.str;
@ -273,25 +135,12 @@ in {
example = "\${pkgs.gnome.gnome_terminal}/bin/gnome-terminal";
};
separator = mkOption {
default = null;
type = types.nullOr (types.enum [ "none" "dash" "solid" ]);
description = "Separator style";
example = "solid";
};
cycle = mkOption {
default = null;
type = types.nullOr types.bool;
description = "Whether to cycle through the results list.";
};
fullscreen = mkOption {
default = null;
type = types.nullOr types.bool;
description = "Whether to run rofi fullscreen.";
};
location = mkOption {
default = "center";
type = types.enum (attrNames locationsMap);
@ -314,43 +163,17 @@ in {
'';
};
colors = mkOption {
default = null;
type = types.nullOr colorsSubmodule;
description = ''
Color scheme settings. Colors can be specified in CSS color
formats. This option may become deprecated in the future and
therefore the <varname>programs.rofi.theme</varname> option
should be used whenever possible.
'';
example = literalExample ''
colors = {
window = {
background = "argb:583a4c54";
border = "argb:582a373e";
separator = "#c3c6c8";
};
rows = {
normal = {
background = "argb:58455a64";
foreground = "#fafbfc";
backgroundAlt = "argb:58455a64";
highlight = {
background = "#00bcd4";
foreground = "#fafbfc";
};
};
};
};
'';
};
theme = mkOption {
default = null;
type = with types; nullOr (oneOf [ str path themeType ]);
example = literalExample ''
let
# Use `mkLiteral` for string-like values that should show without
# quotes, e.g.:
# {
# foo = "abc"; => foo: "abc";
# bar = mkLiteral "abc"; => bar: abc;
# };
inherit (config.lib.formats.rasi) mkLiteral;
in {
"*" = {
@ -401,16 +224,25 @@ in {
};
imports = let
mkRemovedOptionRofi = option:
(mkRemovedOptionModule [ "programs" "rofi" option ]
"Please use a Rofi theme instead.");
in map mkRemovedOptionRofi [
"width"
"lines"
"borderWidth"
"rowHeight"
"padding"
"separator"
"scrollbar"
"fullscreen"
"colors"
];
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.rofi" pkgs platforms.linux)
{
assertion = cfg.theme == null || cfg.colors == null;
message = ''
Cannot use the rofi options 'theme' and 'colors' simultaneously.
'';
}
];
assertions =
[ (hm.assertions.assertPlatform "programs.rofi" pkgs platforms.linux) ];
lib.formats.rasi.mkLiteral = value: {
_type = "literal";
@ -428,23 +260,14 @@ in {
home.file."${cfg.configPath}".text = toRasi {
configuration = ({
width = cfg.width;
lines = cfg.lines;
font = cfg.font;
bw = cfg.borderWidth;
eh = cfg.rowHeight;
padding = cfg.padding;
separator-style = cfg.separator;
hide-scrollbar =
if (cfg.scrollbar != null) then (!cfg.scrollbar) else null;
terminal = cfg.terminal;
cycle = cfg.cycle;
fullscreen = cfg.fullscreen;
location = (getAttr cfg.location locationsMap);
xoffset = cfg.xoffset;
yoffset = cfg.yoffset;
theme = themeName;
} // (mkColorScheme cfg.colors) // cfg.extraConfig);
} // cfg.extraConfig);
};
xdg.dataFile = mkIf (themePath != null) (if themePath == "custom" then {

View file

@ -1,26 +0,0 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.rofi = {
enable = true;
theme = "foo";
colors = {
window = {
background = "background";
border = "border";
separator = "separator";
};
rows = { };
};
};
test.stubs.rofi = { };
test.asserts.assertions.expected = [''
Cannot use the rofi options 'theme' and 'colors' simultaneously.
''];
};
}

View file

@ -1,5 +1,4 @@
{
rofi-valid-config = ./valid-config.nix;
rofi-custom-theme = ./custom-theme.nix;
rofi-assert-on-both-theme-and-colors = ./assert-on-both-theme-and-colors.nix;
}

View file

@ -1,20 +1,11 @@
configuration {
bw: 1;
color-normal: "argb:58455a64, #fafbfc, argb:58455a64, #00bcd4, #fafbfc";
color-window: "argb:583a4c54, argb:582a373e, #c3c6c8";
cycle: false;
eh: 1;
font: "Droid Sans Mono 14";
hide-scrollbar: false;
kb-primary-paste: "Control+V,Shift+Insert";
kb-secondary-paste: "Control+v,Insert";
lines: 10;
location: 0;
modi: "drun,emoji,ssh";
padding: 400;
separator-style: "solid";
terminal: "/some/path";
width: 100;
xoffset: 0;
yoffset: 0;
}

View file

@ -6,36 +6,9 @@ with lib;
config = {
programs.rofi = {
enable = true;
width = 100;
lines = 10;
borderWidth = 1;
rowHeight = 1;
padding = 400;
font = "Droid Sans Mono 14";
scrollbar = true;
terminal = "/some/path";
separator = "solid";
cycle = false;
fullscren = true;
colors = {
window = {
background = "argb:583a4c54";
border = "argb:582a373e";
separator = "#c3c6c8";
};
rows = {
normal = {
background = "argb:58455a64";
foreground = "#fafbfc";
backgroundAlt = "argb:58455a64";
highlight = {
background = "#00bcd4";
foreground = "#fafbfc";
};
};
};
};
window = {
background = "background";
border = "border";