{
  inputs,
  pkgs,
  hostname,
  ...
}: {
  stylix.targets.nixvim.enable = false; # style is defined below.

  # Install some packages.
  programs = {
    lazygit.enable = true;
    yazi.enable = true;
    tmux.enable = true;
    btop.enable = true;

    aria2 = {
      enable = true;
      settings = {
        max-concurrent-downloads = 2;
        max-connection-per-server = 16;
        min-split-size = "8M";
        split = 32;
        continue = true;
      };
    };

    git = {
      enable = true;
      userEmail = "mail@fern.garden";
      userName = "Fern Garden";
    };

    fish = {
      enable = true;
      shellAbbrs = let
        flake = "/home/fern/Repositories/flock";
      in {
        ns = "nh os switch ${flake}";
        nt = "nh os test ${flake}";
        nb = "nh os boot ${flake}";
      };
      functions = {
        y = ''
          set tmp (mktemp -t "yazi-cwd.XXXXXX")
          yazi $argv --cwd-file="$tmp"
          if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
            builtin cd -- "$cwd"
          end
          rm -f -- "$tmp"
        '';
      };
    };

    nixvim = {
      enable = true;

      # Set $EDITOR
      defaultEditor = true;

      # For telescope grep.
      dependencies.ripgrep.enable = true;

      # Space as leader.
      globals.mapleader = " ";

      keymaps = [
        {
          key = "<Leader>t";
          action = "<cmd> ToggleTerm direction=float <CR>";
        }
        {
          key = "<Leader>x";
          action = "<cmd> Trouble diagnostics toggle focus=false <CR>";
        }
        {
          key = "<Leader>y";
          action = "<cmd> Yazi <CR>";
        }
        {
          key = "<Leader>fs";
          action = "<cmd> SessionSearch <CR>";
        }
      ];

      colorschemes.everforest = {
        enable = true;
        settings.background = "hard";
      };

      opts = rec {
        shiftwidth = 2;
        tabstop = shiftwidth;
        softtabstop = shiftwidth;
        expandtab = true;
        number = true;
        cursorline = true;
        undofile = true;
      };

      plugins = {
        auto-session.enable = true;
        bufferline.enable = true;
        colorizer.enable = true;
        comment.enable = true;
        gitsigns.enable = true;
        lsp-format.enable = true;
        notify.enable = true;
        nvim-autopairs.enable = true;
        nvim-surround.enable = true;
        toggleterm.enable = true;
        trouble.enable = true;
        web-devicons.enable = true;
        yazi.enable = true;

        lualine = {
          enable = true;
          settings.extensions = ["trouble" "toggleterm"];
        };

        telescope = {
          enable = true;
          keymaps = {
            "<Leader>ff" = "find_files";
            "<Leader>fg" = "live_grep";
            "<Leader>fb" = "buffers";
          };
        };

        blink-cmp = {
          enable = true;
          settings = {
            keymap = {
              preset = "enter";
              "<Tab>" = [
                "select_next"
                "fallback"
              ];
              "<S-Tab>" = [
                "select_prev"
                "fallback"
              ];
            };
            completion = {
              menu.auto_show = true;
              documentation.auto_show = true;
              list.selection.preselect = false;
            };
            cmdline = {
              keymap.preset = "inherit";
              completion = {
                menu.auto_show = true;
                list.selection.preselect = false;
              };
            };
          };
        };

        lsp = {
          enable = true;
          inlayHints = true;
          servers = {
            nixd = {
              enable = true;
              settings = {
                nixpkgs.expr = "import (builtins.getFlake (builtins.toString ${inputs.self})).inputs.nixpkgs { }";
                formatting.command = ["${pkgs.alejandra}/bin/alejandra"];
                options = {
                  nixos.expr = "(builtins.getFlake (builtins.toString ${inputs.self})).nixosConfigurations.${hostname}.options";
                  home-manager.expr = "(builtins.getFlake (builtins.toString ${inputs.self})).nixosConfigurations.${hostname}.options.home-manager.users.type.getSubOptions []";
                };
              };
            };
            docker_compose_language_service.enable = true;
          };
        };

        treesitter = {
          enable = true;
          settings = {
            highlight.enable = true;
            incremental_selection.enable = true;
            indent.enable = true;
          };
        };
      };
    };
  };

  home.packages = with pkgs; [
    ncdu
    rsync
    trash-cli
  ];
}
