Home-manager specializations for light and dark themes

Has anyone here successfully used home-manager specializations (rather than NixOS specialisations) to switch between themes or light/dark modes during runtime with an activation script?

I found this post and looked through rycee’s config to replicate it for myself.

However, I use home-manager as a module in my NixOS flake rather than standalone, which might be conflicting somehow with specializations.

For example, I have options like this:

  options = {
    theme = {
      colors = lib.mkOption {
        type = lib.types.attrs;
        description = "Base16 color scheme.";
        default = (import ../modules/colorscheme/gruvbox).dark;
      dark = lib.mkOption {
        type = lib.types.bool;
        description = "Enable dark mode.";
        default = true;

And config like this:

  config = {
    home-manager.users.${config.user}.specialization.light.configuration = {
      theme = {
        colors = (import ../modules/colorscheme/gruvbox).light;
        dark = false;

But I get errors when rebuilding:

error: The option `home-manager.users.noah.specialization.light.configuration.theme' does not exist.