{
  lib,
  config,
  inputs,
  ...
}: {
  imports = [
    ./firefox
    ./tidal.nix
    ./gnome
    ./syncthing.nix
    ./vscode.nix
    inputs.nix-index-database.hmModules.nix-index
    inputs.sops-nix.homeManagerModules.sops
    inputs.nvf.homeManagerModules.default
  ];

  xsession.enable = true;

  xdg = {
    userDirs.enable = true;

    mimeApps = {
      enable = true;

      defaultApplications = let
        applications = {
          telegram = {
            mimeApp = "org.telegram.desktop.desktop";
            mimeTypes = ["x-scheme-handler/tg"];
          };

          librewolf = {
            mimeApp = "librewolf.desktop";

            mimeTypes = [
              "x-scheme-handler/http"
              "text/html"
              "application/xhtml+xml"
              "x-scheme-handler/https"
              "application/pdf"
            ];
          };

          gnomeTextEditor = {
            mimeApp = "org.gnome.TextEditor.desktop";
            mimeTypes = ["text/plain"];
          };

          loupe = {
            mimeApp = "org.gnome.Loupe.desktop";
            mimeTypes = [
              "image/jpeg"
              "image/png"
              "image/gif"
              "image/webp"
              "image/tiff"
              "image/x-tga"
              "image/vnd-ms.dds"
              "image/x-dds"
              "image/bmp"
              "image/vnd.microsoft.icon"
              "image/vnd.radiance"
              "image/x-exr"
              "image/x-portable-bitmap"
              "image/x-portable-graymap"
              "image/x-portable-pixmap"
              "image/x-portable-anymap"
              "image/x-qoi"
              "image/svg+xml"
              "image/svg+xml-compressed"
              "image/avif"
              "image/heic"
              "image/jxl"
            ];
          };
        };

        mimeTypesForApp = {
          mimeApp,
          mimeTypes,
        }:
          map
          (
            mimeType: {"${mimeType}" = mimeApp;}
          )
          mimeTypes;
      in
        lib.zipAttrs (lib.flatten (map mimeTypesForApp (builtins.attrValues applications)));
    };
  };

  programs = {
    home-manager.enable = true;
    bat.enable = true;

    git.delta = {
      enable = true;
      options.syntax-theme = "gruvbox-dark";
    };

    fzf = {
      enable = true;
      enableZshIntegration = true;
    };

    alacritty = {
      enable = true;

      settings.terminal.shell = {
        program = lib.getExe config.programs.tmux.package;
        args = ["attach"];
      };
    };

    direnv = {
      enable = true;
      enableBashIntegration = true;
      nix-direnv.enable = true;
    };

    atuin = {
      enable = true;
      flags = ["--disable-up-arrow"];
      enableFishIntegration = true;

      settings = {
        auto_sync = true;
        sync_frequency = "5m";
        sync_address = "https://atuin.kun.is";
      };
    };

    fish = {
      enable = true;

      interactiveShellInit = ''
        set -U fish_greeting
      '';

      shellAbbrs = {
        htop = "btop";
        gp = "git push";
        gpf = "git push --force";
        gco = "git checkout";
        gd = "git diff";
        gc = "git commit";
        gca = "git commit --amend";
        gpl = "git pull";
        gb = "git branch";
        ga = "git add";
        gl = "git log";
        gs = "git status";
        tf = "tofu";
      };
    };

    starship = {
      enable = true;
      enableFishIntegration = true;
      enableTransience = true;
      settings.nix_shell.heuristic = true;
    };

    nix-index = {
      enable = true;
      enableFishIntegration = true;
    };

    tmux = {
      enable = true;
      shell = lib.getExe config.programs.fish.package;
      shortcut = "a";
      clock24 = true;
      newSession = true;
      mouse = true;
      escapeTime = 10;
      terminal = "screen-256color";

      extraConfig = ''
        unbind _
        bind _ split-window -h
        unbind -
        bind - split-window -v
        unbind h
        bind h select-pane -L
        unbind j
        bind j select-pane -D
        unbind k
        bind k select-pane -U
        unbind l
        bind l select-pane -R
      '';
    };

    ssh = {
      enable = true;
      extraConfig = "User root";

      matchBlocks.github = lib.hm.dag.entryBefore ["*"] {
        hostname = "github.com";
        user = "pizzapim";
        identitiesOnly = true;
      };
    };

    git = {
      enable = true;
      userName = "Pim Kunis";
      userEmail = "pim@kunis.nl";

      extraConfig = {
        push.autoSetupRemote = true;
        commit.verbose = true;
        pull.rebase = true;
        init.defaultBranch = "master";
      };
    };

    # Currently, it is not possible to have Home Manager manage Librewolf extensions.
    # There is a draft PR which addresses this:
    # https://github.com/nix-community/home-manager/pull/3339
    # The extensions I currently use are:
    # - ublock-origin (already installed by librewolf)
    # - cookie-autodelete
    # - clearurls
    # - istilldontcareaboutcookies
    # - keepassxc-browser
    # - redirector
    # - violentmonkey
    # - boring-rss
    # - kagi-search
    # - refined-github
    librewolf = {
      enable = true;

      settings = {
        "identity.fxaccounts.enabled" = true;
        "privacy.clearOnShutdown.history" = false;
        "privacy.clearOnShutdown.downloads" = false;
        "browser.translations.automaticallyPopup" = false;
        "browser.aboutConfig.showWarning" = false;
        "privacy.clearOnShutdown.cookies" = false;
      };
    };
  };
}