tl;dr: Sometimes overrideAttrs
doesn’t seem to override everything and old version-specific attributes are left behind leading to build failures. What to do in this case?
Whenever a new version of SoftMaker Office is going to be released, the old version goes on special for like 20 bucks, so I grabbed a cheap license. Of course, this license is only valid for the old version of SoftMaker Office, so in my personal overlay I’m trying to override the version-specific attributes, to downgrade to my licensed version.
However, it seems like you cannot override the softmaker-office
derivation in this way. Consider the following Nix expression:
# test1.nix
with import (fetchTarball { url = "https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"; }) {};
let
version = "976";
edition = "2018";
in softmaker-office.overrideAttrs (oldAttrs: {
pname = "softmaker-office";
inherit version edition;
suiteName = "SoftMaker Office";
src = fetchurl {
url = "https://www.softmaker.net/down/softmaker-office-${edition}-${version}-amd64.tgz";
sha256 = "0s8kzpc6w2cjkfqmhb2p1pkmkiq9vk9gnc7z2992kijaf9bwk3qz";
};
archive = "office${edition}.tar.lzma";
})
When I instantiate this expression and search for the version number that I wanted to override, there are still matches:
$ nix show-derivation $(nix-instantiate test1.nix) | grep -c 2021
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
3
Of course this derivation fails to build, because now there is a mix of different editions all over the place. Taking a look at the derivation in softmaker_office.nix
in the nixpkgs tree I find that this derivation is created by calling a generic.nix
package with appropriate arguments. In fact, when I write a derivation which uses that, it works:
# test2.nix
with import <nixpkgs> {};
let
version = "976";
edition = "2018";
in callPackage <nixpkgs/pkgs/applications/office/softmaker/generic.nix> {
pname = "softmaker-office";
inherit version edition;
suiteName = "SoftMaker Office";
src = fetchurl {
url = "https://www.softmaker.net/down/softmaker-office-${edition}-${version}-amd64.tgz";
sha256 = "0s8kzpc6w2cjkfqmhb2p1pkmkiq9vk9gnc7z2992kijaf9bwk3qz";
};
archive = "office${edition}.tar.lzma";
}
Instantiating shows no reference to the wrong edition:
$ nix show-derivation $(nix-instantiate test2.nix) | grep -c 2021
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
0
This however is really bad, because this depends on NIX_PATH
and I want this to work even if my NIX_PATH
is empty. How can I override this derivation without depending on NIX_PATH
?