diff --git a/modules/programs/rofi.nix b/modules/programs/rofi.nix index bf11201ba..a5489f90e 100644 --- a/modules/programs/rofi.nix +++ b/modules/programs/rofi.nix @@ -99,6 +99,10 @@ let else cfg.theme; + modes = + map (mode: if isString mode then mode else "${mode.name}:${mode.path}") + cfg.modes; + in { options.programs.rofi = { enable = mkEnableOption @@ -222,11 +226,34 @@ in { description = "Path where to put generated configuration file."; }; + modes = mkOption { + default = null; + example = literalExpression '' + [ + "drun" + "emoji" + "ssh" + { + name = "whatnot"; + path = lib.getExe pkgs.rofi-whatnot; + } + ] + ''; + type = with types; + nullOr (listOf (either string (submodule { + options = { + name = mkOption { type = string; }; + path = mkOption { type = string; }; + }; + }))); + description = "Modes to enable. For custom modes see `man 5 rofi-script`."; + }; + extraConfig = mkOption { default = { }; example = literalExpression '' { - modi = "drun,emoji,ssh"; + show-icons = true; kb-primary-paste = "Control+V,Shift+Insert"; kb-secondary-paste = "Control+v,Insert"; } @@ -274,6 +301,7 @@ in { home.file."${cfg.configPath}".text = toRasi { configuration = ({ + inherit modes; font = cfg.font; terminal = cfg.terminal; cycle = cfg.cycle; diff --git a/tests/modules/programs/rofi/valid-config-expected.rasi b/tests/modules/programs/rofi/valid-config-expected.rasi index d9d4aa0be..b2c6b80a5 100644 --- a/tests/modules/programs/rofi/valid-config-expected.rasi +++ b/tests/modules/programs/rofi/valid-config-expected.rasi @@ -4,7 +4,7 @@ font: "Droid Sans Mono 14"; kb-primary-paste: "Control+V,Shift+Insert"; kb-secondary-paste: "Control+v,Insert"; location: 0; -modi: "drun,emoji,ssh"; +modes: [ "drun","emoji","ssh","foo:bar" ]; terminal: "/some/path"; xoffset: 0; yoffset: 0; diff --git a/tests/modules/programs/rofi/valid-config.nix b/tests/modules/programs/rofi/valid-config.nix index c581c0efd..a196f70de 100644 --- a/tests/modules/programs/rofi/valid-config.nix +++ b/tests/modules/programs/rofi/valid-config.nix @@ -9,13 +9,21 @@ with lib; font = "Droid Sans Mono 14"; terminal = "/some/path"; cycle = false; + modes = [ + "drun" + "emoji" + "ssh" + { + name = "foo"; + path = "bar"; + } + ]; window = { background = "background"; border = "border"; separator = "separator"; }; extraConfig = { - modi = "drun,emoji,ssh"; kb-primary-paste = "Control+V,Shift+Insert"; kb-secondary-paste = "Control+v,Insert"; };