Override the fmt package with a custom version

I need to use an older version of fmt. And i was wondering how to best override the existing package.

the pkgs/development/libraries/fmt/default.nix looks something like this:

{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
}:

let
  generic =
    {
      version,
      hash,
      patches ? [ ],
    }:
    stdenv.mkDerivation {
      pname = "fmt";
      inherit version;

      src = fetchFromGitHub {
        owner = "fmtlib";
        repo = "fmt";
        rev = version;
        inherit hash;
      };

      inherit patches;
      ....
    };
in
{
  fmt_8 = generic {
    version = "8.1.1";
    hash = "sha256-leb2800CwdZMJRWF5b1Y9ocK0jXpOX/nwo95icDf308=";
  };

  fmt_9 = generic {
    version = "9.1.0";
    hash = "sha256-rP6ymyRc7LnKxUXwPpzhHOQvpJkpnRFOt2ctvUNlYI0=";
  };
}

And i was assuming that i can just override it with:

  libfmt_7 = pkgsi686Linux.fmt.overrideAttrs (
    finalAttrs: previousAttrs: {
      version = "7.1.3";
      hash = "08hyv73qp2ndbs0isk8pspsphdzz5qh8czl3wgyxy3mmif9xdg29";
  );

but this gives you a package called 7.1.3 but contains fmt version 10.
And the hash is not used.

I got this to work:

  libfmt_7 = pkgsi686Linux.fmt.overrideAttrs (
    finalAttrs: previousAttrs: {
      version = "7.1.3";

      src = fetchFromGitHub {
        owner = "fmtlib";
        repo = "fmt";
        rev = finalAttrs.version;
        sha256 = "08hyv73qp2ndbs0isk8pspsphdzz5qh8czl3wgyxy3mmif9xdg29";
      };
      doCheck = false;
    }
  );

but ideally i would want to just override version and hash. Is that even possible?

generic is just a local binding so not that simply. The only thing you can simplify here is

      src = previousAttrs.src.override {
        rev = finalAttrs.version;
        hash = "...";
      };