How to use a specific package (i.e., specific version of software) with Home Manager?

As far as I can tell, every program that is configurable with Home Manager has a package attribute to refer to a specific version of an application (see the Home Manager user manual’s Appendix A. Configuration Options) but have no clue how to use it.

The problem I’m trying to solve is that fzf is freezing the shell in tmux when the tmux version is above 3.01 so I would need the latest tmux version before 3.0

From appendix A:

The tmux package to install

Type: package

Default: pkgs.tmux

Example: pkgs.tmux

[1]: Well, the proper solution is to run fzf-tmux with run-shell -b (instead of simply with run-shell), but solving this seems to be more involved with Home Manager than to simply just downgrade tmux for the time being. (Found a run-shell invocation in the Home Manager repo’s tmux.nix but it appears that this requires a PR; could be wrong.)

Sometimes, doing this is enough:

programs.tmux.package = pkgs.tmux.overrideAttrs (_: rec {
  version = "2.9a";
  src = pkgs.fetchFromGitHub {
    owner = "tmux";
    repo = "tmux";
    rev = version;
    sha256 = "sha256-78YApTmw2/AG9lLXGzPPcUlzSr6KjwtuwSR82t+iFxA=";

But in this case, build fails in the patch phase:

tmux> unpacking sources
tmux> unpacking source archive /nix/store/xa1jlkyj39h0mm8j3hd76pdq5i9bpgrr-source
tmux> source root is source
tmux> patching sources
tmux> applying patch /nix/store/7ia8skws8wr1ckscapj8hqdna1wp4p7f-d0a2683120ec5a33163a14b0e1b39d208745968f.patch
tmux> patching file
tmux> Hunk #1 FAILED at 160.
tmux> 1 out of 1 hunk FAILED -- saving rejects to file

So you need to further tweak the derivation.