{ lib, ... }:
let inherit (lib) mkOption types;
in {
  options = {
    valhalla = mkOption {
      type = types.submodule (
        { extendModules, ... }:
        let
          osVariant = extendModules {
            modules = [
              ({ config, ... }: {
                options = {
                  config = mkOption {
                    type = types.attrs;
                    description = "The configuration of the Operating System.";
                    default = builtins.removeAttrs config [ "_module" "config" "linux" "windows" ];
                    visible = false;
                  };
                };
              })
            ];
          };

          linuxVariant = osVariant.extendModules {
            modules = [
              ({ ... }: {
                options = {
                  secureBoot = mkOption {
                    type = types.bool;
                    description = "A value indicating whether the system supports Secure Boot.";
                    default = false;
                  };
                };
              })
            ];
          };

          windowsVariant = osVariant.extendModules { };
        in
        {
          options = {
            linux = mkOption {
              inherit (linuxVariant) type;
              description = "The options for setting up Linux.";
              default = { };
              visible = "shallow";
            };

            windows = mkOption {
              inherit (windowsVariant) type;
              description = "The options for setting up Windows.";
              default = { };
              visible = "shallow";
            };
          };
        }
      );

      description = "Configuration for PortValhalla.";
      default = { };
    };
  };
}