Set package settings in overlay

Is there a way to set package settings with my overlay? I have tried setting the settings I want into my overlay but it doesn’t seem to apply it to the theme I am installing. I would like to get rid of the big chunk in my packages containing the config if possible. Here is what I am currently doing, is there a way to combine what I am doing in my home.nix into my overlays.nix?

snippet from overlays.nix

final: prev: {
    colloid-gtk-theme = prev.colloid-gtk-theme.overrideAttrs (old: rec {
        patches = [ ./patches/colloid-gtk-theme-no-radius.diff ];
    });
}

snippet from home.nix

home.packages = with pkgs; [
    (colloid-gtk-theme.override {
        themeVariants = [ "purple" ];
        colorVariants = [ "light" ];
        sizeVariants = [ "compact" ];
        tweaks = [ "nord" ];
    })
];

It should totally possible to apply this override in the overlay as well, as much as I dislike that an overlay is used without need to manipulate a leaf package…

I think you should be able to make both customizations either in the overlay or in home.packages by chaining overrideAttrs and override.

final: prev: {
  colloid-gtk-theme =
    (prev.colloid-gtk-theme.overrideAttrs (old: {
      patches = [ ./patches/colloid-gtk-theme-no-radius.diff ];
    })).override
      {
        themeVariants = [ "purple" ];
        colorVariants = [ "light" ];
        sizeVariants = [ "compact" ];
        tweaks = [ "nord" ];
      };
}

Does that not work?

But you don’t need to put this in your overlay to get that code out of that home.packages list. You could assign the customized package to a variable, and list the variable in home.packages:

{ pkgs, ... }:

let 
    gtk-theme = colloid-gtk-theme.override {
        themeVariants = [ "purple" ];
        colorVariants = [ "light" ];
        sizeVariants = [ "compact" ];
        tweaks = [ "nord" ];
    };
in
{
    home.packages = with pkgs; {
        gtk-theme
    };
}

Or you could move the theme customization to another module to get the clutter out of your main config file:

# my-machine.nix
{ pkgs, ... }:
{
    imports = [ ./theme.nix ];
    home.packages = with pkgs; {
        # other packages
    };
}

# theme.nix
{ pkgs, ... }:
{
    home.packages = with pkgs; [
        (colloid-gtk-theme.override {
            themeVariants = [ "purple" ];
            colorVariants = [ "light" ];
            sizeVariants = [ "compact" ];
            tweaks = [ "nord" ];
        })
    ];
}
2 Likes

Thank you sir! I ended up just using the first option, but if I do end up with a bit more themeing I may just add it as a part of a module.