{
  lib,
  pkgs,
  ...
}:
let
  shellAliases = {
    update-switch = "darwin-rebuild switch --flake ~/nix-config";
    update-flake = "nix flake update ~/nix-config";
    ducks = "du -cksh * | sort -hr | head -n 15";
  };
  packages = with pkgs; [
    age
    cpufetch
    deadnix
    nixfmt-rfc-style
    nodePackages.nodejs
    uv
    sops
    tree
    wget
  ];
in
{
  # Home Manager needs a bit of information about you and the
  # paths it should manage.
  home = {
    username = "mattjallen";
    homeDirectory = "/Users/mattjallen";
    packages = lib.mkForce packages;
    sessionVariables = {
      NH_DARWIN_FLAKE = lib.mkForce "/Users/mattjallen/nix-config";
    };
  };

  programs = {
    zsh = {
      shellAliases = shellAliases;
    };
  };

  programs.nix-plist-manager = {
    enable = true;
    options = {
      applications = {
        finder = {
          settings = {
            general = {
              showTheseItemsOnTheDesktop = {
                hardDisks = false;
                externalDisks = true;
                cdsDvdsAndiPods = false;
                connectedServers = false;
              };
              openFoldersInTabsInsteadOfNewWindows = true;
            };
            sidebar = {
              recentTags = true;
            };
            advanced = {
              removeItemsFromTheTrashAfter30Days = true;
              showAllFilenameExtensions = true;
              showWarningBeforeChangingAnExtension = true;
              showWarningBeforeRemovingFromiCloudDrive = true;
              showWarningBeforeEmptyingTheTrash = true;
              keepFoldersOnTop = {
                inWindowsWhenSortingByName = true;
                onDesktop = true;
              };
              whenPerformingASearch = "Search This Mac";
            };
          };
          menuBar = {
            view = {
              showTabBar = true;
              showSidebar = true;
              showPathBar = true;
              showStatusBar = true;
            };
          };
        };
        systemSettings = {
          appearance = {
            appearance = "Dark";
            accentColor = "Multicolor";
            # clickInTheScrollBarTo = "Jump to the next page";
            sidebarIconSize = "Medium";
            showScrollBars = "When scrolling";
          };
          controlCenter = {
            wifi = true;
            bluetooth = true;
            airdrop = true;
            stageManager = true;
            focusModes = "active";
            screenMirroring = "active";
            display = "never";
            sound = "always";
            nowPlaying = "active";
            accessibilityShortcuts = "unset";
            musicRecognition = {
              showInMenuBar = false;
              showInControlCenter = true;
            };
            hearing = "unset";
            fastUserSwitching = {
              showInMenuBar = false;
              showInControlCenter = true;
            };
            keyboardBrightness = {
              showInMenuBar = false;
              showInControlCenter = true;
            };
            battery = {
              showInMenuBar = false;
              showInControlCenter = false;
            };
            batteryShowPercentage = true;
            # menuBarOnly = {
            #   spotlight = false;
            #   siri = true;
            # };
            # automaticallyHideAndShowTheMenuBar = "In Full Screen Only";
          };
          desktopAndDock = {
            desktopAndStageManager = {
              showItems = {
                onDesktop = true;
                inStageManager = false;
              };
              clickWallpaperToRevealDesktop = "Always";
              stageManager = true;
              showRecentAppsInStageManager = true;
              showWindowsFromAnApplication = "All at Once";
            };
            dock = {
              animateOpeningApplications = true;
              automaticallyHideAndShowTheDock.enabled = false;
              doubleClickAWindowsTitleBarTo = "Minimize";
              magnification.enabled = false;
              minimizeWindowsIntoApplicationIcon = true;
              minimizeWindowsUsing = "Genie Effect";
              positionOnScreen = "Bottom";
              showIndicatorsForOpenApplications = true;
              showSuggestedAndRecentAppsInDock = false;
              size = 64; # 16 - 128
              #     persistentApps = [
              #       { app = "/Applications/Clock.app"; }
              #       { folder = "/Applications"; }
              #       { app = "/Applications/Safari.app"; }
              #       { app = "/Applications/Firefox.app"; }
              #       { app = "/Applications/Tabby.app"; }
              #       { app = "/Applications/Termius.app"; }
              #       { app = "/Applications/Muic.app"; }
              #       { app = "/Applications/Vesktop.app"; }
              #       { app = "/Applications/Messages.app"; }
              #       { app = "/Applications/Calendar.app"; }
              #       { app = "/Applications/Reminders.app"; }
              #       { app = "/Applications/Notes.app"; }
              #       { app = "/Applications/Weather.app"; }
              #       { app = "/Applications/Maps.app"; }
              #       { app = "/Applications/App Store.app"; }
              #       { app = "/Applications/System Settings.app"; }
              #       { app = "/Applications/ChatGPT.app"; }
              #       { app = "/Applications/Nextcloud.app"; }
              #       { app = "/Applications/VSCodium.app"; }
              #       { app = "/Applications/Omnissa Horizon Client.app"; }
              #       { app = "/Applications/Proton Pass.app"; }
              #       { app = "/Applications/OrcaSlicer.app"; }
              #       { app = "/Applications/AlDente.app"; }
              #     ];
              #     persistentOthers = [
              #       "~/Downloads"
              #     ];
            };
            hotCorners = {
              # ["-" "Mission Control" "Application Windows" "Desktop" "Start Screen Saver" "Disable Screen Saver" "Dashboard" "Put Display to Sleep" "Launchpad" "Notification Center" "Lock Screen" "Quick Note"]
              topLeft = "-";
              topRight = "-";
              bottomLeft = "-";
              bottomRight = "-";
            };
            missionControl = {
              automaticallyRearrangeSpacesBasedOnMostRecentUse = true;
              displaysHaveSeparateSpaces = true;
              dragWindowsToTopOfScreenToEnterMissionControl = true;
              groupWindowsByApplication = true;
              whenSwitchingToAnApplicationSwitchToAspaceWithOpenWindowsForTheApplication = true;
            };
            widgets = {
              showWidgets = {
                onDesktop = true;
                inStageManager = true;
              };
              widgetStyle = "Automatic";
              useIphoneWidgets = true;
            };
            windows = {
              askToKeepChangesWhenClosingDocuments = true;
              closeWindowsWhenQuittingAnApplication = true;
              dragWindowsToScreenEdgesToTile = true;
              dragWindowsToMenuBarToFillScreen = true;
              holdOptionKeyWhileDraggingWindowsToTile = true;
              preferTabsWhenOpeningDocuments = "In Full Screen";
              tiledWindowsHaveMargin = false;
            };
          };
          focus = {
            shareAcrossDevices = true;
          };
          general.dateAndTime."24HourTime" = false;
          notifications = {
            notificationCenter = {
              showPreviews = "When Unlocked";
              summarizeNotifications = true;
            };
          };
          sound = {
            soundEffects = {
              alertSound = "Boop";
              alertVolume = 0.7;
              playFeedbackWhenVolumeIsChanged = true;
              playUserInterfaceSoundEffects = true;
            };
          };
          spotlight = {
            helpAppleImproveSearch = false;
            # searchResults = {
            #   applications = true;
            #   calculator = true;
            #   contacts = true;
            #   conversion = true;
            #   definition = true;
            #   developer = true;
            #   documents = true;
            #   eventsAndReminders = true;
            #   folders = true;
            #   fonts = false;
            #   images = true;
            #   mailAndMessages = true;
            #   movies = true;
            #   music = true;
            #   other = false;
            #   pdfDocuments = true;
            #   presentations = true;
            #   siriSuggestions = false;
            #   systemSettings = true;
            #   tips = false;
            #   websites = true;
          };
        };
      };
    };
  };

  # Manage bug in compilations - who uses manpages in 2024 anyways? :P
  manual.manpages.enable = false;

  # Override defaults that arent supported
  programs = {
    mangohud.enable = lib.mkForce false;

    nh = {
      flake = lib.mkForce "/Users/mattjallen/nix-config";
    };
  };

  services = {
    pass-secret-service.enable = lib.mkForce false;
    nextcloud-client.enable = lib.mkForce false;
    kdeconnect = {
      enable = false;
      indicator = false;
    };
  };
}
