From ed923bb61dd373a536bb8608e2599a11e637fc19 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 17 Mar 2023 14:58:55 +0100 Subject: [PATCH] gimp: Use env attribute for environment variables This is in preparation for __structuredAttrs. --- pkgs/applications/graphics/gimp/default.nix | 8 +-- .../graphics/gimp/plugins/default.nix | 54 +++++++++++-------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/pkgs/applications/graphics/gimp/default.nix b/pkgs/applications/graphics/gimp/default.nix index 3b9572a8a982..cdc8e9445b67 100644 --- a/pkgs/applications/graphics/gimp/default.nix +++ b/pkgs/applications/graphics/gimp/default.nix @@ -154,10 +154,12 @@ in stdenv.mkDerivation (finalAttrs: { doCheck = true; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DGDK_OSX_BIG_SUR=16"; + env = { + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-DGDK_OSX_BIG_SUR=16"; - # Check if librsvg was built with --disable-pixbuf-loader. - PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}"; + # Check if librsvg was built with --disable-pixbuf-loader. + PKG_CONFIG_GDK_PIXBUF_2_0_GDK_PIXBUF_MODULEDIR = "${librsvg}/${gdk-pixbuf.moduleDir}"; + }; preConfigure = '' # The check runs before glib-networking is registered diff --git a/pkgs/applications/graphics/gimp/plugins/default.nix b/pkgs/applications/graphics/gimp/plugins/default.nix index 2077fabc35df..f101569219ff 100644 --- a/pkgs/applications/graphics/gimp/plugins/default.nix +++ b/pkgs/applications/graphics/gimp/plugins/default.nix @@ -31,26 +31,27 @@ let install -Dt "$pluginDir" "$@" } ''; - - # Override installation paths. - PKG_CONFIG_GIMP_2_0_GIMPLIBDIR = "${placeholder "out"}/${gimp.targetLibDir}"; - PKG_CONFIG_GIMP_2_0_GIMPDATADIR = "${placeholder "out"}/${gimp.targetDataDir}"; } // attrs // { - name = "${gimp.pname}-plugin-${name}"; - buildInputs = [ - gimp - gimp.gtk - glib - ] ++ (attrs.buildInputs or []); + name = "${gimp.pname}-plugin-${name}"; + buildInputs = [ + gimp + gimp.gtk + glib + ] ++ (attrs.buildInputs or []); - nativeBuildInputs = [ - pkg-config - intltool - ] ++ (attrs.nativeBuildInputs or []); - } - ); + nativeBuildInputs = [ + pkg-config + intltool + ] ++ (attrs.nativeBuildInputs or []); + + # Override installation paths. + env = { + PKG_CONFIG_GIMP_2_0_GIMPLIBDIR = "${placeholder "out"}/${gimp.targetLibDir}"; + PKG_CONFIG_GIMP_2_0_GIMPDATADIR = "${placeholder "out"}/${gimp.targetDataDir}"; + } // attrs.env or { }; + }); scriptDerivation = {src, ...}@attrs : pluginDerivation ({ prePhases = "extraLib"; @@ -116,8 +117,13 @@ in url = "https://ftp.gimp.org/pub/gimp/plug-ins/v2.6/gap/gimp-gap-2.6.0.tar.bz2"; sha256 = "1jic7ixcmsn4kx2cn32nc5087rk6g8xsrz022xy11yfmgvhzb0ql"; }; - NIX_LDFLAGS = "-lm"; + hardeningDisable = [ "format" ]; + + env = { + NIX_LDFLAGS = "-lm"; + }; + meta = with lib; { description = "The GIMP Animation Package"; homepage = "https://www.gimp.org"; @@ -233,15 +239,19 @@ in pname = "wavelet-sharpen"; version = "0.1.2"; - # Workaround build failure on -fno-common toolchains like upstream - # gcc-10. Otherwise build fails as: - # ld: interface.o:(.bss+0xe0): multiple definition of `fimg'; plugin.o:(.bss+0x40): first defined here - env.NIX_CFLAGS_COMPILE = "-fcommon"; - NIX_LDFLAGS = "-lm"; src = fetchurl { url = "https://github.com/pixlsus/registry.gimp.org_static/raw/master/registry.gimp.org/files/wavelet-sharpen-0.1.2.tar.gz"; sha256 = "0vql1k67i21g5ivaa1jh56rg427m0icrkpryrhg75nscpirfxxqw"; }; + + env = { + # Workaround build failure on -fno-common toolchains like upstream + # gcc-10. Otherwise build fails as: + # ld: interface.o:(.bss+0xe0): multiple definition of `fimg'; plugin.o:(.bss+0x40): first defined here + NIX_CFLAGS_COMPILE = "-fcommon"; + NIX_LDFLAGS = "-lm"; + }; + installPhase = "installPlugin src/wavelet-sharpen"; # TODO translations are not copied .. How to do this on nix? };