# Shared Home Manager selection for all desktop hosts (14900k, t2mbp, ideapad, uConsole).
# Wisdom slices resolved here (NixOS has `self`); toggles select what actually installs.
{ self, inputs, ... }:
{
  flake.nixosModules.desktopHomeBase =
    { self, lib, pkgs, ... }:
    {
      chiasson.system.chromiumHevc.enable = lib.mkDefault true;

      chiasson.users.extraModules.olivier =
        self.lib.wisdomCatalogExtraModules self
        ++ [
          (
            { lib, pkgs, ... }:
            let
              aarch64 = pkgs.stdenv.hostPlatform.isAarch64;
            in
            {
              programs.git = {
                enable = lib.mkDefault true;
                settings.user = {
                  name = "OlivierChiasson";
                  email = "olivierchiasson@hotmail.fr";
                };
              };

              #TODO[epic=Moderate] Check if git-crypt should belong in desktop-home-base.
              home.packages = [ pkgs.git-crypt ];

              chiasson.home = {
                # Catalog of `chiasson.home.*` toggles — host `home.nix` sets `enable = true` to override `mkDefault false`.
                shell = {
                  fish.enable = lib.mkDefault true;
                  ohMyPosh.enable = lib.mkDefault true;
                  yazi.enable = lib.mkDefault true;
                };

                terminals.kitty.enable = lib.mkDefault true;

                filebrowsers.dolphin.enable = lib.mkDefault true;

                browsers = {
                  chrome.enable = lib.mkDefault false;
                  chromiumHevc = {
                    enable = lib.mkDefault true;
                    packages = lib.mkDefault (
                      if aarch64 then
                        [ "chromium" ]
                      else
                        [ "google-chrome" ]
                    );
                  } // lib.optionalAttrs (!aarch64) {
                    # Chromium + NVIDIA VA-API → frame pool errors in Jellyfin; gecko may fare better on NVIDIA.
                    vaapi.gpu = lib.mkDefault "intel";
                  };
                  edge.enable = lib.mkDefault false;
                  flow.enable = lib.mkDefault false;
                  orion.enable = lib.mkDefault false;
                  zen.enable = lib.mkDefault false;
                };

                editors = {
                  cursor.enable = lib.mkDefault true;
                  kate.enable = lib.mkDefault false;
                  obsidian.enable = lib.mkDefault true;
                };

                apps = {
                  discord.enable = lib.mkDefault false;
                  localsend.enable = lib.mkDefault true;
                  pokeclicker.enable = lib.mkDefault false;
                  spotify = {
                    enable = lib.mkDefault false;
                    openDiscoveryFirewall = lib.mkDefault false;
                  };
                };

                desktop = {
                  screenshot = {
                    enable = lib.mkDefault true;
                    swiftshareApiKeyFile = "/run/secrets/swiftshare/API_KEY"; #TODO[epic=sops] redo this by passing sops file output directly
                  };
                  # WhiteSur GTK/icons, Phinger cursor, Qt via KDE platform theme; imports DMS matugen `dank-colors.css`.
                  theming.enable = lib.mkDefault true;
                };

                hardware.uconsoleGamepad.enable = lib.mkDefault false;
              };
            }
          )
        ];
    };
}
