Passing in a specialisation option to select the right hardware configuration?

In my configuration.nix I have the following option:

    machineVariants = lib.options.mkOption {
      type = lib.types.listOf lib.types.str;
      example = ''[ "d" "l" ]'';
      default = [ "d" "l" ];
      description = lib.mdDoc
        "The machines for which system configurations can be generated by this configuration.";
    };

In my hardware-configuration.nix-like, I have the following option:

    machineLabel = lib.options.mkOption {
      type = lib.types.nullOr (lib.types.enum config.machineVariants);
      example = "d";
      default = null;
      description = lib.mdDoc "Host machine selection.";
    };

In my root.nix (the nix file which routes to configuration.nix after doing some initial setup), I have the following specialisations defined:

  config = let
    genSpecialization = machineLabel: {
      inheritParentConfig = true;
      configuration = { config = { inherit machineLabel; }; };
    };
  in {
    specialisation =
      lib.attrsets.genAttrs config.machineVariants genSpecialization;
...

and ultimately all of this comes together to be used in my hardware-configuration.nix-like file:

  config = let
    machineSpecificSettings = {
      d = {
        availableKernelModules =
          [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ];
        kernelModules = [ "kvm-intel" ];
        homeFs = "3T";
        lidSwitch = { };
        cpuFreqGovernor = "performance";
        firmwareFamily = "intel";
      };
      l = {
        availableKernelModules =
          [ "nvme" "xhci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
        kernelModules = [ "kvm-amd" ];
        homeFs = "FS";
        lidSwitch = { lidSwitch = "hibernate"; };
        cpuFreqGovernor = "ondemand";
        firmwareFamily = "amd";
      };
    };
    thisMachineSettings = if (builtins.isNull config.machineLabel) then
      builtins.throw "config.machineLabel is NULL!"
    else
      machineSpecificSettings."${config.machineLabel}";
in
...

However, running my setup triggers the the throw in the last code snippet, which is activated when builtins.isNull config.machineLabel is true. I am evaluating+activating the system using effectively the following command:

sudo nixos-rebuild switch --show-trace --specialisations d

Any ideas on why the specialisation flag does not trigger the machineLabel to be set correctly?

I use grub and then create another name to selected config, so just load on boot with grub.