Trouble configuring rofi theme in home.nix

I am trying to set up rofi following the example here:
programs.rofi.theme

All the other rofi settings I have set are working except for the theme. I don’t know if I have some syntax wrong, but nothing I try affects the theme.

Does anyone have a working example they could share so I could see where I am going wrong?

1 Like

Something similar occur to me with neovim last day, please update your nix channels with nix-channel --update and then rebuild your config to see if the configs take effect.

Thanks for the reply. I tried that and unfortunately it didn’t work.

I’m using home-manager.

Do you mind sharing your configuration file?

There is a PR on the home manager related to rofi theming. I don’t use rofi, so I don’t know if this is actually helpful, but still sharing this hoping it might be :slight_smile:

With 21.11 nixpkgs updated to a new Rofi version which deprecated some old theme syntax, which is why people like me (and presumably @noblman) are stuck having to figure out the new syntax :wink:

I’ve not yet gotten around to figuring it out yet, either, but I think there are multiple versions of the new syntax as well, and I’ve yet to find a proper definition of the one the current version takes.

This was fixed in home-manager recently, but the fix is only in master.

Ahh, that explains it, thanks! So the workaround for now is to pin home-manager to master, or to fix up the theme by hand.

I don’t think that helps my situation. I am not using an external theme but instead configuring it like the example given here:

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 {
  "*" = {
    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 = ":";
    margin = mkLiteral "0px 0.3em 0em 0em";
    text-color = mkLiteral "@foreground-color";
  };
}

I have done something similar to this, but the result is that all formatting has been removed from rofi. I just get black text on a white background.

I’m fairly sure this still applies. As long as your configuration is set up using nix and your home-manager isn’t on master (which presumably is the case if you’re building your theme with nix, though I guess you could do something weird like have a theme built with nix and then import it from a manually written config file?), the module will put the @theme in the wrong location, which will result in rofi not loading it properly.

Your theme is still “external” as far as rofi is concerned, the module just creates a theme named “custom” and tells rofi to load it using the same code path it loads “external” themes with.

The fix has been backported to release-21.11.

1 Like

Have you figured out how to configure programs.rofi.theme to get a custom theme working with home-manager?

This makes the background green for me after updating to the latest home-manager:

let
  inherit (config.lib.formats.rasi) mkLiteral;
  rofi-theme = {
    "*" = {
      background-color = mkLiteral "#00ff00";
    };
  };
in {
  programs.rofi = {
    enable = true;
    theme = rofi-theme;
  };
}

I’ll need to take a deep dive into the upstream themes before defining a proper one though (and am half considering just keeping the actual definition outside of nix).