final: prev:
with prev.lib.nix-rice; let
  # theme = kitty-themes.parseTheme ./op.pal;
  theme = kitty-themes.parseTheme ./pal.conf;
  # theme = kitty-themes.getThemeByName "everforest_dark_hard";
in {
  rice = rec {
    palette =
      {
        normal = {
          black = theme.color0;
          red = theme.color1;
          green = theme.color2;
          yellow = theme.color3;
          blue = theme.color4;
          magenta = theme.color5;
          cyan = theme.color6;
          white = theme.color7;
        };
        bright = {
          black = theme.color8;
          red = theme.color9;
          green = theme.color10;
          yellow = theme.color11;
          blue = theme.color12;
          magenta = theme.color13;
          cyan = theme.color14;
          white = theme.color15;
        };
        util = {
          fg = theme.foreground;
          bg = theme.background;
          fg_sel = theme.selection_foreground;
          bg_sel = theme.selection_background;
          cursor = theme.cursor;
          # url = theme.url_color;
        };
      }
      // theme;

    fonts = rec {
      sans = {
        name = "Inria Sans";
        size = 12;
        package = final.inriafonts;
      };
      serif = {
        name = "Inria Serif";
        size = 12;
        package = final.inriafonts;
      };
      monospace = {
        name = "Fira Code";
        size = 10;
        package = final.fira-code;
      };
      emoji = {
        name = "Twitter Color Emoji";
        size = 12;
        package = final.twemoji-color-font;
      };
      pkgs = with final; [
        sans.package
        serif.package
        monospace.package
        emoji.package
        meslo-lgs-nf
      ];
    };

    icons = rec {
      name = "Papirus-Dark";
      package = final.papirus-icon-theme;
      pkgs = with final; [
        package
        # material-icons
        # material-design-icons
      ];
    };

    gtk-theme = {
      name = "nix-rice";
      package = prev.callPackage ./gtk-theme.nix {} {palette = palette.toRGBShortHex final.rice.palette;};
    };

    borders = {
      thickness = 6;
      rounding = 0;
      gaps_in = 16;
      gaps_out = 72;
    };

    bg = {
      image = prev.callPackage ./wallpaper.nix {} {
        palette = palette.toRGBShortHex final.rice.palette;
        wallpaper = builtins.path rec {
          name = "wallpaper.jpg";
          path = ../${name};
          sha256 = "2db3f9d0397fbd4746ada297bd14c0c7d3e22c7d4e894968fcfece90bbfb902a";
        };
      };
    };

    plymouth = {
      # no easy way to automate filename sadly - could try stripping "real" font name of spaces?
      font = "${fonts.sans.package}/share/fonts/truetype/InriaSans-Regular.ttf";
      theme = "colorful_loop";
      themePackages = [
        (prev.pkgs.adi1090x-plymouth-themes.override {selected_themes = ["colorful_loop"];})
      ];
    };
  }; # /rice
}
