{ inputs, config, pkgs, lib, osConfig, ... }:
let
  unstable = import inputs.nixpkgs-unstable {
    system = "x86_64-linux";
    config.allowUnfree = true;
  };
in
{
  imports = [
    ../../../../shared/modules/home-manager/base-home.nix
  ];

  baseHome = {
    enable = true;
    userName = "nate";
    fullName = "Nathan Anderson";
    email = "n8r@tuta.io";
    stateVersion = "23.11";
    hostDir = "nate";
  };

  # Zsh — add direnv hook + yt-audio function
  programs.zsh.initContent = ''
    eval "$(direnv hook zsh)"

    yt-audio() {
      nix-shell -p yt-dlp --run "yt-dlp -x $1 --audio-format mp3"
    }
  '';

  # Additional programs
  programs.direnv = {
    enable = true;
    enableZshIntegration = true;
    nix-direnv.enable = true;
  };
  programs.delta = {
    enable = true;
    enableGitIntegration = true;
    options = {
      side-by-side = true;
      hyperlinks = true;
    };
  };

  # Git — SSH rewrite for GitHub
  programs.git.settings.url = {
    "git@github.com:" = {
      insteadOf = "https://github.com/";
    };
  };

  # KDEConnect (HM-level indicator)
  services.kdeconnect = {
    enable = true;
    indicator = true;
  };

  # Git autosync for star-command
  services.git-autosync = {
    enable = true;
    repos.star-command = {
      path = "/home/nate/source/star-command";
      gitName = "Nathan Anderson";
      gitEmail = "n8r@tuta.io";
    };
  };

  # Enable Noctalia shell (replaces Waybar, SwayNC, SwayOSD, wlsunset)
  noctaliaShell = {
    enable = true;
    settings = {
      bar.position = "top";
      colorSchemes = {
        darkMode = true;
        useWallpaperColors = true;
      };
      location.name = "Denver";
      general.avatarImage = "/home/nate/.face";
    };
  };

  # Additional user packages
  home.packages = with pkgs; [
    #
    # Dev Tools
    #
    docker
    unstable.godot
    jq
    python3
    unstable.claude-code
    usbutils
    openscad
    ### LSP's
    nil
    nodePackages_latest.bash-language-server
    vscode-langservers-extracted
    python313Packages.python-lsp-server

    #
    # Gaming
    #
    mumble
    mangohud
    wine-wayland

    #
    # Unix tools
    #
    duf
    dust
    fd
    ripgrep
    gtop

    #
    # Photo / Video
    #
    unstable.davinci-resolve-studio
    obs-studio
    imv
    ffmpeg

    #
    # Other
    #
    kdePackages.filelight
    simple-scan
    tailscale-systray

    #
    # Additional fonts
    #
    unstable.nerd-fonts.hurmit
    unstable.nerd-fonts.overpass
    recursive
  ];

  # Local dotfiles (host-specific, override shared)
  home.file = lib.mkMerge [
    (
      let
        localDotfilesPath = ../../dotfiles;
      in
      if builtins.pathExists localDotfilesPath && builtins.readDir localDotfilesPath != { } then
        builtins.listToAttrs (
          map (name: {
            name = "${config.xdg.configHome}/${name}";
            value = {
              source = localDotfilesPath + "/${name}";
            };
          }) (builtins.attrNames (builtins.readDir localDotfilesPath))
        )
      else
        { }
    )
  ];

  # Configure default applications for opening links
  xdg.mimeApps = {
    enable = true;
    defaultApplications = {
      "text/html" = "firefox.desktop";
      "x-scheme-handler/http" = "firefox.desktop";
      "x-scheme-handler/https" = "firefox.desktop";
      "x-scheme-handler/about" = "firefox.desktop";
      "x-scheme-handler/unknown" = "firefox.desktop";
    };
  };

  # Cava audio visualizer
  programs.cava = {
    enable = true;
    settings = {
      smoothing.noise_reduction = 55;
    };
  };
}
