Super new to Nix and NixOS in general so bear with me… I’m trying to set up an XFCE desktop with NixOS and make it as close as I can to my current Xubuntu system. I use a built-from-source version of xfce4-terminal
that I’d like to have in NixOS as well. I found the source of the xfce4-terminal package. But I have no idea how to go about overriding the version there. I tried the generic instructions on overriding packages to no avail, maybe because it uses a custom mkXfceDerivation
? Any advice on how to go about this?
Hi. I think normally, the best way to do this is using <pkg>.override
which is the highest level (closer to the input as opposed to the output derivation) one out of the three functions used to override a derivation (the other two being <pkg>.overrideAttrs
and <pkg>.overrideDerivation
). When a value is overridden that change won’t affect the higher levels, which might include logic that is necessary to correctly package the project.
So in this case, I think the levels from the highest to the lowest are like this:
pkgs/desktops/xfce/applications/xfce4-terminal/default.nix → mkXfceDerivation
→ mkDerivation
→ builtins.derivation
I checked which one of the functions override
actually affects in nix repl
:
nix-repl> xfce.xfce4-terminal.override.__functionArgs
{ docbook_xml_dtd_45 = false; docbook_xsl = false; gtk3 = false; libxfce4ui = false; libxslt = false; mkXfceDerivation = false; pcre2 = false; vte = false; xfconf = false; }
Which looks like “xfce4-terminal/default.nix”. But since that function doesn’t have any parameters for the version (and the hash), I decided to override the value of mkXfceDerivation
key with another function that takes the same parameters as mkXfceDerivation
. This function acts as a shim/wrapper by merging the arguments passed to it with the set { version = <new-version>; sha256 = <new-hash>; }
before passing it to the actual mkXfceDerivation
:
let
createMkXfceDerivationShim = overrideArgs: args: xfce.mkXfceDerivation (args // overrideArgs);
mkXfceDerivationShim = createMkXfceDerivationShim {
version = "0.8.9";
sha256 = "sha256-q/HLoILt5f9F2C0f2/OPtukuRCvUF10LV9VWo4OkCyQ=";
};
customTerminal = xfce.xfce4-terminal.override {
mkXfceDerivation = mkXfceDerivationShim;
};
in
customTerminal
To get the correct hash, I first used lib.fakeSha256
.
Wow, thank you for the detailed response! This is great for learning how to do this kind of thing in general. I think I need to do some more research into how exactly overriding works, but I’ll try out your suggestion. Thanks!