Setting background image in homepage-dashboard service

I’m trying to setup Homepage dashboard using the relatively recently created services.homepage-dashboard. It’s working pretty well but there is one issue:

To set a background image you set background: "/path/to/file" in the settings, which you can do with services.homepage-dashboard.settings. Unfortunately this doesn’t work. According to the homepage documentation (Settings - Homepage), the path is relative to /app/public/images. Since it’s designed to be run in a docker container, you can just mount any directory at that location.

Unfortunately, the nix package doesn’t have the same directory structure. I don’t think that location exists, and if it did it would be in the nix store so putting images in there wouldn’t work anyway.

Has anyone had any experience with this type of thing? Am I missing something obvious? Is this something that should be brought up on the github issues for the package?

Hey, I just searched for the same issue to see whether there’s a better solution. Here’s my solution.

let
  background = pkgs.fetchurl {
    name = "homepage-background.jpeg";
    # background image in the official documentation
    url = "https://images.unsplash.com/photo-1502790671504-542ad42d5189?auto=format&fm=jpg&fit=crop&w=2560&q=80";
    hash = "sha256-ixg2MEbI/0tvJXAQ9V2JB9yyiUrOPgIE5QNtpahIIQE=";
  };
  package = pkgs.homepage-dashboard.overrideAttrs (oldAttrs: {
    postInstall = ''
      mkdir -p $out/share/homepage/public/images
      ln -s ${background} $out/share/homepage/public/images/background.jpeg
    '';
  });
in
{
  services.homepage-dashboard = {
    enable = true;
    package = package;
    settings = {
      background = "/images/background.jpeg";
    };
  };
};

Oh that’s a nice solution, I’m not very familiar with overrides or how to use them.