Import / refer to default config

Is there a way to import or refer to a default config? I want to access some properties of the root user in a custom user option, but I’m running into an infinite recursion error while using disko that I can’t parse. I’m thinking I could instead access the default root user’s attributes. Should I just create a small config using nixpkgs.lib.nixosSystem and use that?

Could you share your code? This is likely an XY problem.

Oh, it’s 100% an XY problem. This is what I had initially:

{
  config,
  options,
  lib,
  ...
}:
let
  cfg = config.users;
  userType = options.users.users.type.nestedTypes.elemType;
  levels = [
    "primary"
    "secondary"
  ];
in
with lib;
{
  options = {
    users = (genAttrs levels (level: mkOption {
      type = types.nullOr (types.submodule ({ config, ... }: {
        imports = options.users.users.type.getSubModules;
        inherit level;
        name = mkOrder 999 (builtins.replaceStrings [ "." ] [ "" ] config.domain);
      }));
    })) // {
      loginUsers = mkOption {
        inherit (options.users.users) type;
        default = {};
      };
      allLoginUsers = mkOption {
        inherit (options.users.loginUsers) type;
        readOnly = true;
      };
      users = mkOption {
        type =
          with types;
          attrsOf (
            submodule (
              { name, config, ... }:
              {
                options = {
                  level = mkOption {
                    type = nullOr (enum levels);
                    default = null;
                  };
                  domain = mkOption {
                    type = str;
                    default = "syvl.org";
                  };
                };
              }
            )
          );
      };
    };
  };
  config = {
    assertions = map (level: {
      assertion = (count (user: user.level == level) (builtins.attrValues cfg.users)) == 1;
      message = "there must be one and only one ${level} user";
    }) levels;
    users = {
      loginUsers = genAttrs' levels (level: let
        user = cfg.${level};
        inherit (if (user == null) then (throw "there must be a ${level} user") else user) name;
      in nameValuePair (if (name == level) then (warn ''the ${level} user's name is still "${level}"'' name) else name) user);
      users = cfg.loginUsers;
      allLoginUsers = loginUsers // { inherit (cfg.users) root; };
    };
  };
}

allLoginUsers was triggering the error, and mkMerge did not seem to help.

And yes, yes, I know about not using root as a normal user, but I like to have my config available when I need to work as a root user for a little while.