Remove hardcoded dependency of SBT on JDK8?

Okay, I’m probably making a very noob mistake (and I should probably have posted this thread in the “Learn” section, sorry), but I can’t get the following to work:

{ pkgs, ... }:
{
  imports = [
    ./vim.nix
  ];

  home.packages = with pkgs; [
    fortune
    xclip
    graphviz
    jdk11
    sbt.override { jre = pkgs.jdk11; }
  ];
}

This file is then imported in my main home.nix. This gives me an error:

error: The option value `home.packages.[definition 1-entry 5]' in `~/commandLine.nix' is not of type `package'.
(use '--show-trace' to show detailed location information)

It looks like the sbt.override line is the problem. I thought .override returned a package, but it looks like I don’t get it after all. Maybe the .override pattern is meant for overlays, but that sounds like a heavyweight example for “just” changing one dependency (maybe I’m underestimating if that’s a big deal or not). Do I need to start using overlays or am I misunderstanding .override?

I also tried referring directly to sbt in <nixpkgs> so I could pass in the arguments for the package manually but I couldn’t get the path right…

EDIT:

I searched and read a bit more about overlays and came up with the following:

{ config, pkgs, ... }:
let sbtOverlay = self: super:
{
  sbt = super.sbt.override { jre = super.jdk11; };
};
in
{
  nixpkgs.overlays = [ sbtOverlay ];
  // rest of config
}

And then in my sub .nix files I just refer to SBT. Not sure what to do now if I want to have differently versioned SBT’s (probably tweak JAVA_HOME), but this works fine for now. If there’s a shorter/more elegant way I’m still very curious to hear.