Hello all! I’m making my way back to wayland full time and I realized that gimp 2.10 has some issues.
I don’t know much about packaging Nix but after some Gimp research I realized that there were newer versions out that worked. So I tried to make an overlay for Gimp. Then I realized nixpkgs version of gtk3 is too new for Gimp( has to be gtk3<=3.22 ) .
So I tried making an overlay for GTK3 inside of the Gimp overlay but I am having some struggles.
Here is what I have so far,
(final: prev: {
gtk3 = prev.gimp.overrideAttrs {
src = pkgs.fetchurl {
url = "https://download.gnome.org/sources/gtk+/3.21/gtk%2B-3.21.6.tar.xz";
hash = "sha256-wDzTcbrzFEjZmvgPOxNU8Gh9tIWfLBmVM2hHFPQnyGQ=";
};
patches = [ ];
};
gimp = prev.gimp.overrideAttrs {
src = pkgs.fetchurl {
url = "https://download.gimp.org/pub/gimp/v2.99/gimp-2.99.8.tar.bz2";
hash = "sha256-3ZFr00dO8u/GUqBRAoCXerjqlePZXZGDlLBmImHDKq4=";
};
patches = [ ];
};
})
I know that in Nix I can’t just choose a specific package version so I thought this would be the right approach. Let me know if there is a more idiomatic way that I glossed over. Also I am using this syntax so I can put the overlay in my configuration.nix
’s nixpkgs.overlay
.
Thanks for the feedback and assistance as always.
EDIT:
Discoveries
I now learned that there are several ways to do it, I could override the gtk3 inside the gimp overlay or I could make a new overlay and set the gtk in gimp to the custom overlay. Just make sure not to use the name gtk3 here or else all other packages that use gtk3 will use the overlay.
Whats next
Well I realized that the gtk3 is better suited to be its own derivation since the version of GTK I am trying to build uses a different build system than the one current in the GTK3 package on Nixpkgs. So I’m probably going to write a new derivation and import it or something.
@mightyiam
I made some changes and tried again I think I am making some more progress now.
(final: prev: {
gtk3-gimp = prev.gtk3.overrideAttrs {
version = "3.21.6";
src = pkgs.fetchurl {
url = "https://download.gnome.org/sources/gtk+/3.21/gtk%2B-3.21.6.tar.xz";
hash = "sha256-wDzTcbrzFEjZmvgPOxNU8Gh9tIWfLBmVM2hHFPQnyGQ=";
};
patches = [ ];
};
gimp = prev.gimp.overrideAttrs {
src = pkgs.fetchurl {
url = "https://download.gimp.org/pub/gimp/v2.99/gimp-2.99.8.tar.bz2";
hash = "sha256-3ZFr00dO8u/GUqBRAoCXerjqlePZXZGDlLBmImHDKq4=";
};
patches = [ ];
gtk = final.gtk3-gimp;
};
})
building with nixos-rebuild switch --flake . --impure --use-remote-sudo
yields an error when building
error: builder for '/nix/store/q0qzz3wqlvrp8azgbizgg017sb0mfgzx-gtk+3-3.21.6.drv' failed with exit code 1;
last 10 log lines:
> Running phase: unpackPhase
> unpacking source archive /nix/store/nqbm1yxls681cinsg93r7v5qz22p81jj-gtk-2B-3.21.6.tar.xz
> calling 'unpackCmd' function hook '_defaultUnpack' /nix/store/nqbm1yxls681cinsg93r7v5qz22p81jj-gtk-2B-3.21.6.tar.xz
> source root is gtk+-3.21.6
> calling 'postUnpack' function hook '_updateSourceDateEpochFromSourceRoot'
> setting SOURCE_DATE_EPOCH to timestamp 1473760732 of file gtk+-3.21.6/build/win32/vs10/gtk3-install.props
> Running phase: patchPhase
> evaling implicit 'postPatch' string hook
> substitute(): ERROR: file 'meson.build' does not exist
> /nix/store/1r32fki5z5ivgaikgh8pq0r6vz3b0jpj-stdenv-linux/setup: line 193: pop_var_context: head of shell_variables not a function context
For full logs, run 'nix log /nix/store/q0qzz3wqlvrp8azgbizgg017sb0mfgzx-gtk+3-3.21.6.drv'.
error: 1 dependencies of derivation '/nix/store/p7ig8zghdazcy5wj3w7m1kqvkf11m8l9-gimp-2.10.38.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2p8vph3lm5lpbd5kf0g7x72qzyybpvak-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xb15j2iv0mav5x6b00kg9nrzbhpd0phl-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/chnfrr70cgawbdjmb27sr3zx2653bz0k-nixos-system-nixos-24.11.20240809.5e0ca22.drv' failed to build
As you can see the gimp build actually sees gtk-3.21.6.
Why do you think that GIMP requires such an ancient GTK version? The latest pre-release version (2.99.18) actually expects at least 3.24.0.
This does not really replace GTK used by GIMP, you would need to use override
for that.
Replacing gtk
using overrideAttrs
this mainly does the two following things:
- It modifies the attribute set passed as an argument to
stdenv.mkDerivation
, adding gtk
, which mkDerivation
will pass as gtk
environment variable to the builder.
- This causes your
gtk3-gimp
to become a build dependency for gimp
(and thus to be built before gimp
can be built).
- But since the
gimp
’s builder does not care about gtk
environment variable, it will not do anything with the dependency. You could just as well do gimp.overrideAttrs { foobar = final.gtk3-gimp; }
- It shadows the
gimp.gtk
attribute from passthru
, which is only used by plug-ins. But plug-ins require GIMP itself to build so it won’t be of much use.
By the way, packaging such different versions is not as easy as replacing the source. There will be significant divergences between dependencies. See gimp: Testing dev version with Meson by jtojnar · Pull Request #67576 · NixOS/nixpkgs · GitHub for what is actually needed.
@jtojnar
Hey! Thanks for clarifying. So after your comment I realized the initial reason I went down this path.
NixOS unstable Gimp has a package of 2.10.38, an old version which I wanted to replace. The requirement for GTK3 <= 3.22.6 comes from this version of Gimp.
Gimp 2.99 as you mentioned has the features I want so I tried to override that, and realized the build no longer uses autotools as well, they now use meson. So the override will need more work.
In the midst of my nix rampage, I tried to rollback to an older gtk version to use with the newer v2.99 of Gimp, but I should have attempted a new meson derivation for Gimp and used the current GTK3. Either way I would need to transition to meson build tools for the derivation.