{ inputs, ... }: {
  flake.nixosModules.desktopShellDmsOptions = { lib, ... }: {
    options.chiasson.desktop.shells.dms = {
      enableGpuTemp = lib.mkOption {
        type = lib.types.bool;
        default = true;
        description = "GPU temp in DMS bar.";
      };
      obsidianSnippetsDir = lib.mkOption {
        type = lib.types.nullOr lib.types.str;
        default = null;
        description = "Legacy single Obsidian snippets dir for matugen.";
      };
      obsidianConfigDirs = lib.mkOption {
        type = lib.types.listOf lib.types.str;
        default = [ ];
        description = "Vault `.obsidian/` paths for matugen.";
      };
      obsidianSnippetsDirs = lib.mkOption {
        type = lib.types.listOf lib.types.str;
        default = [ ];
        description = "Explicit `.obsidian/snippets` paths.";
      };
      extraRightBarWidgets = lib.mkOption {
        type = lib.types.listOf lib.types.attrs;
        default = [ ];
        description = "Extra right-bar widgets (prepended).";
      };
      enableWvkbdToggle = lib.mkEnableOption ''
        wvkbd DMS plugin + bar toggle (touch / uConsole).
      '';
      enableRbwLockToggle = lib.mkEnableOption ''
        rbw vault lock/unlock button in the DMS bar (Bitwarden CLI via rbw).
      '';
      rebuildCommand = lib.mkOption {
        type = lib.types.nullOr (lib.types.listOf lib.types.str);
        default = null;
        example = [ "sudo" "nixos-rebuild" "switch" "--flake" ".#14900k" ];
        description = "Command used by DMS nix-monitor widget for rebuild actions.";
      };
    };
  };

  flake.homeManagerModules.desktopShellDms = {
    lib,
    osConfig ? { },
    ...
  }:
  let
    cfg = lib.attrByPath [ "chiasson" "desktop" "shells" "dms" ] { } osConfig;
    selectedShell = lib.attrByPath [ "chiasson" "desktop" "shell" ] null osConfig;
    dmsEnabled = selectedShell == "dms";
    hostName = lib.attrByPath [ "networking" "hostName" ] "nixos" osConfig;
    rebuildCommand =
      if (cfg.rebuildCommand or null) != null then
        cfg.rebuildCommand
      else
        [ "sudo" "nixos-rebuild" "switch" "--flake" ".#${hostName}" ];
  in
  {
    imports = [
      ./home-manager/default.nix
    ];

    config = lib.mkIf dmsEnabled {
      dms.enable = true;
      dms.enableGpuTemp = cfg.enableGpuTemp or true;
      dms.obsidianSnippetsDir = cfg.obsidianSnippetsDir or null;
      dms.obsidianConfigDirs = cfg.obsidianConfigDirs or [ ];
      dms.obsidianSnippetsDirs = cfg.obsidianSnippetsDirs or [ ];
      dms.enableWvkbdToggle = cfg.enableWvkbdToggle or false;
      dms.enableRbwLockToggle = cfg.enableRbwLockToggle or false;
      dms.extraRightBarWidgets =
        (lib.optionals (cfg.enableWvkbdToggle or false) [
          {
            id = "wvkbdToggle";
            enabled = true;
          }
        ])
        ++ (lib.optionals (cfg.enableRbwLockToggle or false) [
          {
            id = "rbwLockToggle";
            enabled = true;
          }
        ])
        ++ (cfg.extraRightBarWidgets or [ ]);
      programs.nix-monitor.rebuildCommand = rebuildCommand;
    };
  };
}
