{ inputs, lib, ... }:
let
  systemsDir = ../../../systems;
  systemNames = lib.attrNames (lib.filterAttrs 
    (name: type: type == "directory" && builtins.pathExists (systemsDir + "/${name}/cfg.nix")) 
    (builtins.readDir systemsDir));


in with lib; {
  options.usercfg = import ./user.nix  {inherit lib;};
  options.syscfg = {
    hostname = mkOption { type = types.str; };
    type = mkOption {
      type = types.enum [ "nixos" "macos" "home" ];
      default = "nixos";
    };
    defaultUser = mkOption { type = types.str; };
    make = import ./make.nix {inherit lib;};
    net = import ./net.nix {inherit lib;};
    users = mkOption {
      type = types.listOf (types.submodule { options = import ./user.nix  {inherit lib;}; });
      default = [ ];
    };
    peers = mkOption {
      default = map (name: import (systemsDir + "/${name}/cfg.nix")) systemNames;
    };
    server = mkOption {
      type = types.oneOf [ types.bool (types.submodule { options = import ./server.nix {inherit lib;}; }) ];
      default = false;
    };
    monitoring = mkOption {
      type = types.submodule { options = import ./monitoring.nix { inherit lib; }; };
      default = { };
    };
    media = mkOption {
      type = types.submodule { options = import ./media.nix { inherit lib; }; };
      default = {};
    };
    extra = import ./extra.nix {inherit lib;};
  };
}
