{
  lib,
  inputs,
  system,
  ...
}: let
  alejandra = lib.getExe inputs.alejandra.packages.${system}.default;
  nil = lib.getExe inputs.nil.packages.${system}.default;
  helixPackage = inputs.helix.packages.${system}.default;
  helix = lib.getExe helixPackage;
in {
  home.sessionVariables = {
    EDITOR = lib.mkForce helix;
    VISUAL = lib.mkForce helix;
  };
  programs.zsh.sessionVariables = {
    EDITOR = lib.mkForce helix;
    VISUAL = lib.mkForce helix;
  };
  systemd.user.sessionVariables = {
    EDITOR = lib.mkForce helix;
    VISUAL = lib.mkForce helix;
  };

  programs.helix = {
    enable = true;
    package = helixPackage;
    languages = {
      language = [
        {
          name = "nix";
          auto-format = true;
          language-servers = ["nil"];
          formatter = {
            command = alejandra;
            args = ["-q"];
          };
        }
      ];
      language-server.nil = {
        command = nil;
        config.nil.nix = {
          maxMemoryMB = 8192;
          flake.autoEvalInputs = true;
        };
      };
    };
    settings = {
      theme = "solarized_dark";
      editor = {
        auto-save = true;
        auto-pairs = false;
        file-picker.hidden = false;
        lsp.display-messages = true;
        line-number = "relative";
        soft-wrap.enable = true;
      };
    };
  };
}
