diff --git a/docs/release-notes/rl-2111.adoc b/docs/release-notes/rl-2111.adoc index 14216eff8..3430fc987 100644 --- a/docs/release-notes/rl-2111.adoc +++ b/docs/release-notes/rl-2111.adoc @@ -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 <>. 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 diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 38ef04ceb..e19f96047 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -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. + ''; + } ]; }; } diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index 2c06aae44..2091090c6 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -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 programs.rofi.theme 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 { diff --git a/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix b/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix deleted file mode 100644 index a62faf734..000000000 --- a/tests/modules/programs/rofi/assert-on-both-theme-and-colors.nix +++ /dev/null @@ -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. - '']; - }; -} diff --git a/tests/modules/programs/rofi/default.nix b/tests/modules/programs/rofi/default.nix index 057ef0039..f0aed0952 100644 --- a/tests/modules/programs/rofi/default.nix +++ b/tests/modules/programs/rofi/default.nix @@ -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; } diff --git a/tests/modules/programs/rofi/valid-config-expected.rasi b/tests/modules/programs/rofi/valid-config-expected.rasi index 23cf24606..d9d4aa0be 100644 --- a/tests/modules/programs/rofi/valid-config-expected.rasi +++ b/tests/modules/programs/rofi/valid-config-expected.rasi @@ -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; } diff --git a/tests/modules/programs/rofi/valid-config.nix b/tests/modules/programs/rofi/valid-config.nix index 84c741521..c581c0efd 100644 --- a/tests/modules/programs/rofi/valid-config.nix +++ b/tests/modules/programs/rofi/valid-config.nix @@ -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";