I’ve recently been exploring using nix shell, rather than docker, to create a development environment. One issue I quickly ran into was being able to load up older versions of libraries. This is often necessary if you need to support old code.
For example, suppose I want to use opencv 4.5.4, instead of the current version, opencv 4.7.0. In theory, I can change the version of opencv that gets built by using overrideAttrs. However, when I change the version and source attributes (see example below), I get an error because the patches aren’t compatible with this older version of opencv. I don’t know a way to change the patches directly, since they’re inside mkDerivation and thus inaccessible with overrideAttrs (I think?).
Is there an established way of doing this? Should I load in an older version of the opencv nix file?
Thanks.
An example of what I’m doing:
opencv = (pkgs.opencv.override (previous: {
enablePython = true;})).overrideAttrs (oldAttrs: { nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [pkgs.ant pkgs.jdk]; version = "4.5.4"; src = pkgs.fetchFromGitHub { owner = "opencv"; repo = "opencv"; rev = "4.5.4"; sha256 = "sha256-eIESkc/yYiZZ5iY4t/rAPd+jfjuMYR3srCBC4fO3g70="; }; contribSrc = pkgs.fetchFromGitHub { owner = "opencv"; repo = "opencv_contrib"; rev = "4.5.4"; sha256 = "sha256-RkCIGukZ8KJkmVZQAZTWdVcVKD2I3NcfGShcqzKhQD0="; }; testDataSrc = pkgs.fetchFromGitHub { owner = "opencv"; repo = "opencv_extra"; rev = "4.5.4"; sha256 = "sha256-Ak0sTr4s7tPqRLcuIe+5NVGMz8SwTifYU7vBu1uH4rk="; };
})