downgrade or upgrade a package in NixOS
As you may know (or not, if you forgot), packages are pinned to nixpkgs
, so you may not have the latest version of a package, e.g. your favorite neovim.
Or worst, you have a bug or an incompatibility issue with a package pinned by nixpkgs
.
In Flakes, package versions and hash values are directly tied to the git commit, of their flake input. To modify the package version, you need to lock the git, commit of the flake input.
Here’s an example of how you can add multiple nixpkgs
inputs, each using a, different git commit or branch:
Then in your package, you can use this pinned nixpkgs
:
Don’t forget to apply your change in your home-manager afterwards!
You can find the nixpkgs version/hash that contains your package at a specific version using https://lazamar.co.uk/nix-versions/.
Source: https://nixos-and-flakes.thiscute.world/nixos-with-flakes/downgrade-or-upgrade-packages