glib: Format the expression

- Format with `nixfmt-rfc-style`.
- Move `outputs` and `setupHook` to top.
- Move `strictDeps` above `inputs`.
- Move `nativeCheckInputs` next to the rest of the inputs.
- Move `env` above phases.
- Expand `env.NIX_CFLAGS_COMPILE` to a nested attribute set.

+254 -181
+254 -181
pkgs/development/libraries/glib/default.nix
··· 1 - { config 2 - , lib 3 - , stdenv 4 - , fetchurl 5 - , gettext 6 - , meson 7 - , ninja 8 - , pkg-config 9 - , perl 10 - , python3 11 - , python3Packages 12 - , libiconv, zlib, libffi, pcre2, elfutils, gnome, libselinux, bash, gnum4, libxslt 13 - , docutils, gi-docgen 14 - # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib) 15 - , util-linuxMinimal ? null 16 - , buildPackages 1 + { 2 + config, 3 + lib, 4 + stdenv, 5 + fetchurl, 6 + gettext, 7 + meson, 8 + ninja, 9 + pkg-config, 10 + perl, 11 + python3, 12 + python3Packages, 13 + libiconv, 14 + zlib, 15 + libffi, 16 + pcre2, 17 + elfutils, 18 + gnome, 19 + libselinux, 20 + bash, 21 + gnum4, 22 + libxslt, 23 + docutils, 24 + gi-docgen, 25 + # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib) 26 + util-linuxMinimal ? null, 27 + buildPackages, 17 28 18 - # this is just for tests (not in the closure of any regular package) 19 - , dbus, tzdata 20 - , desktop-file-utils, shared-mime-info 21 - , darwin 22 - , makeHardcodeGsettingsPatch 23 - , testers 24 - , gobject-introspection 25 - , libsystemtap 26 - , libsysprof-capture 27 - , mesonEmulatorHook 28 - , withIntrospection ? 29 - stdenv.hostPlatform.emulatorAvailable buildPackages && 30 - lib.meta.availableOn stdenv.hostPlatform gobject-introspection && 31 - stdenv.hostPlatform.isLittleEndian == stdenv.buildPlatform.isLittleEndian 29 + # this is just for tests (not in the closure of any regular package) 30 + dbus, 31 + tzdata, 32 + desktop-file-utils, 33 + shared-mime-info, 34 + darwin, 35 + makeHardcodeGsettingsPatch, 36 + testers, 37 + gobject-introspection, 38 + libsystemtap, 39 + libsysprof-capture, 40 + mesonEmulatorHook, 41 + withIntrospection ? 42 + stdenv.hostPlatform.emulatorAvailable buildPackages 43 + && lib.meta.availableOn stdenv.hostPlatform gobject-introspection 44 + && stdenv.hostPlatform.isLittleEndian == stdenv.buildPlatform.isLittleEndian, 32 45 }: 33 46 34 47 assert stdenv.hostPlatform.isLinux -> util-linuxMinimal != null; ··· 40 53 x11Support = false; 41 54 }; 42 55 43 - librarySuffix = if (stdenv.hostPlatform.extensions.library == ".so") then "2.0.so.0" 44 - else if (stdenv.hostPlatform.extensions.library == ".dylib") then "2.0.0.dylib" 45 - else if (stdenv.hostPlatform.extensions.library == ".a") then "2.0.a" 46 - else if (stdenv.hostPlatform.extensions.library == ".dll") then "2.0-0.dll" 47 - else "2.0-0.lib"; 56 + librarySuffix = 57 + if (stdenv.hostPlatform.extensions.library == ".so") then 58 + "2.0.so.0" 59 + else if (stdenv.hostPlatform.extensions.library == ".dylib") then 60 + "2.0.0.dylib" 61 + else if (stdenv.hostPlatform.extensions.library == ".a") then 62 + "2.0.a" 63 + else if (stdenv.hostPlatform.extensions.library == ".dll") then 64 + "2.0-0.dll" 65 + else 66 + "2.0-0.lib"; 48 67 49 68 systemtap' = buildPackages.linuxPackages.systemtap.override { withStap = false; }; 69 + 50 70 withDtrace = 51 - lib.meta.availableOn stdenv.buildPlatform systemtap' && 52 - # dtrace support requires sys/sdt.h header 53 - lib.meta.availableOn stdenv.hostPlatform libsystemtap; 71 + lib.meta.availableOn stdenv.buildPlatform systemtap' 72 + && 73 + # dtrace support requires sys/sdt.h header 74 + lib.meta.availableOn stdenv.hostPlatform libsystemtap; 54 75 in 55 76 56 77 stdenv.mkDerivation (finalAttrs: { 57 78 pname = "glib"; 58 79 version = "2.82.1"; 59 80 81 + outputs = [ 82 + "bin" 83 + "out" 84 + "dev" 85 + "devdoc" 86 + ]; 87 + 88 + setupHook = ./setup-hook.sh; 89 + 60 90 src = fetchurl { 61 91 url = "mirror://gnome/sources/glib/${lib.versions.majorMinor finalAttrs.version}/glib-${finalAttrs.version}.tar.xz"; 62 92 hash = "sha256-R4Y0RAv1LuTsRCjVWHhzmMC+awQ8UhvrMIM0s9tEiaY="; 63 93 }; 64 94 65 - patches = lib.optionals stdenv.hostPlatform.isDarwin [ 66 - ./darwin-compilation.patch 67 - ] ++ lib.optionals stdenv.hostPlatform.isMusl [ 68 - ./quark_init_on_demand.patch 69 - ./gobject_init_on_demand.patch 70 - ] ++ [ 71 - # This patch lets GLib's GDesktopAppInfo API watch and notice changes 72 - # to the Nix user and system profiles. That way, the list of available 73 - # applications shown by the desktop environment is immediately updated 74 - # when the user installs or removes any 75 - # (see <https://issues.guix.gnu.org/35594>). 95 + patches = 96 + lib.optionals stdenv.hostPlatform.isDarwin [ 97 + ./darwin-compilation.patch 98 + ] 99 + ++ lib.optionals stdenv.hostPlatform.isMusl [ 100 + ./quark_init_on_demand.patch 101 + ./gobject_init_on_demand.patch 102 + ] 103 + ++ [ 104 + # This patch lets GLib's GDesktopAppInfo API watch and notice changes 105 + # to the Nix user and system profiles. That way, the list of available 106 + # applications shown by the desktop environment is immediately updated 107 + # when the user installs or removes any 108 + # (see <https://issues.guix.gnu.org/35594>). 76 109 77 - # It does so by monitoring /nix/var/nix/profiles (for changes to the system 78 - # profile) and /nix/var/nix/profiles/per-user/USER (for changes to the user 79 - # profile) as well as /etc/profiles/per-user (for chanes to the user 80 - # environment profile) and crawling their share/applications sub-directory when 81 - # changes happen. 82 - ./glib-appinfo-watch.patch 110 + # It does so by monitoring /nix/var/nix/profiles (for changes to the system 111 + # profile) and /nix/var/nix/profiles/per-user/USER (for changes to the user 112 + # profile) as well as /etc/profiles/per-user (for chanes to the user 113 + # environment profile) and crawling their share/applications sub-directory when 114 + # changes happen. 115 + ./glib-appinfo-watch.patch 83 116 84 - ./schema-override-variable.patch 117 + ./schema-override-variable.patch 85 118 86 - # Add support for Pantheon’s terminal emulator. 87 - ./elementary-terminal-support.patch 119 + # Add support for Pantheon’s terminal emulator. 120 + ./elementary-terminal-support.patch 88 121 89 - # GLib contains many binaries used for different purposes; 90 - # we will install them to different outputs: 91 - # 1. Tools for desktop environment and introspection ($bin) 92 - # * gapplication (non-darwin) 93 - # * gdbus 94 - # * gi-compile-repository 95 - # * gi-decompile-typelib 96 - # * gi-inspect-typelib 97 - # * gio 98 - # * gio-launch-desktop (symlink to $out) 99 - # * gsettings 100 - # 2. Development/build tools ($dev) 101 - # * gdbus-codegen 102 - # * gio-querymodules 103 - # * glib-compile-resources 104 - # * glib-compile-schemas 105 - # * glib-genmarshal 106 - # * glib-gettextize 107 - # * glib-mkenums 108 - # * gobject-query 109 - # * gresource 110 - # * gtester 111 - # * gtester-report 112 - # 3. Tools for desktop environment that cannot go to $bin due to $out depending on them ($out) 113 - # * gio-launch-desktop 114 - ./split-dev-programs.patch 122 + # GLib contains many binaries used for different purposes; 123 + # we will install them to different outputs: 124 + # 1. Tools for desktop environment and introspection ($bin) 125 + # * gapplication (non-darwin) 126 + # * gdbus 127 + # * gi-compile-repository 128 + # * gi-decompile-typelib 129 + # * gi-inspect-typelib 130 + # * gio 131 + # * gio-launch-desktop (symlink to $out) 132 + # * gsettings 133 + # 2. Development/build tools ($dev) 134 + # * gdbus-codegen 135 + # * gio-querymodules 136 + # * glib-compile-resources 137 + # * glib-compile-schemas 138 + # * glib-genmarshal 139 + # * glib-gettextize 140 + # * glib-mkenums 141 + # * gobject-query 142 + # * gresource 143 + # * gtester 144 + # * gtester-report 145 + # 3. Tools for desktop environment that cannot go to $bin due to $out depending on them ($out) 146 + # * gio-launch-desktop 147 + ./split-dev-programs.patch 115 148 116 - # Tell Meson to install gdb scripts next to the lib 117 - # GDB only looks there and in ${gdb}/share/gdb/auto-load, 118 - # and by default meson installs in to $out/share/gdb/auto-load 119 - # which does not help 120 - ./gdb_script.patch 121 - ]; 149 + # Tell Meson to install gdb scripts next to the lib 150 + # GDB only looks there and in ${gdb}/share/gdb/auto-load, 151 + # and by default meson installs in to $out/share/gdb/auto-load 152 + # which does not help 153 + ./gdb_script.patch 154 + ]; 122 155 123 - outputs = [ "bin" "out" "dev" "devdoc" ]; 156 + strictDeps = true; 124 157 125 - setupHook = ./setup-hook.sh; 126 - 127 - buildInputs = [ 128 - finalAttrs.setupHook 129 - ] ++ lib.optionals (!stdenv.hostPlatform.isFreeBSD) [ 130 - libsysprof-capture 131 - ] ++ [ 132 - pcre2 133 - ] ++ lib.optionals (!stdenv.hostPlatform.isWindows) [ 134 - bash gnum4 # install glib-gettextize and m4 macros for other apps to use 135 - ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [ 136 - elfutils 137 - ] ++ lib.optionals withDtrace [ 138 - libsystemtap 139 - ] ++ lib.optionals stdenv.hostPlatform.isLinux [ 140 - libselinux 141 - util-linuxMinimal # for libmount 142 - ] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ 143 - AppKit Carbon Cocoa CoreFoundation CoreServices Foundation 144 - ]); 145 - 146 - strictDeps = true; 158 + buildInputs = 159 + [ 160 + finalAttrs.setupHook 161 + ] 162 + ++ lib.optionals (!stdenv.hostPlatform.isFreeBSD) [ 163 + libsysprof-capture 164 + ] 165 + ++ [ 166 + pcre2 167 + ] 168 + ++ lib.optionals (!stdenv.hostPlatform.isWindows) [ 169 + bash 170 + gnum4 # install glib-gettextize and m4 macros for other apps to use 171 + ] 172 + ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [ 173 + elfutils 174 + ] 175 + ++ lib.optionals withDtrace [ 176 + libsystemtap 177 + ] 178 + ++ lib.optionals stdenv.hostPlatform.isLinux [ 179 + libselinux 180 + util-linuxMinimal # for libmount 181 + ] 182 + ++ lib.optionals stdenv.hostPlatform.isDarwin ( 183 + with darwin.apple_sdk.frameworks; 184 + [ 185 + AppKit 186 + Carbon 187 + Cocoa 188 + CoreFoundation 189 + CoreServices 190 + Foundation 191 + ] 192 + ); 147 193 148 194 depsBuildBuild = [ 149 195 pkg-config # required to find native gi-docgen 150 196 ]; 151 197 152 - nativeBuildInputs = [ 153 - docutils # for rst2man, rst2html5 154 - meson 155 - ninja 156 - pkg-config 157 - perl 158 - python3 159 - python3Packages.packaging # mostly used to make meson happy 160 - python3Packages.wrapPython # for patchPythonScript 198 + nativeBuildInputs = 199 + [ 200 + docutils # for rst2man, rst2html5 201 + meson 202 + ninja 203 + pkg-config 204 + perl 205 + python3 206 + python3Packages.packaging # mostly used to make meson happy 207 + python3Packages.wrapPython # for patchPythonScript 208 + gettext 209 + libxslt 210 + ] 211 + ++ lib.optionals withIntrospection [ 212 + gi-docgen 213 + gobject-introspection' 214 + ] 215 + ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 216 + mesonEmulatorHook 217 + ] 218 + ++ lib.optionals withDtrace [ 219 + systemtap' # for dtrace 220 + ]; 221 + 222 + propagatedBuildInputs = [ 223 + zlib 224 + libffi 161 225 gettext 162 - libxslt 163 - ] ++ lib.optionals withIntrospection [ 164 - gi-docgen 165 - gobject-introspection' 166 - ] ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ 167 - mesonEmulatorHook 168 - ] ++ lib.optionals withDtrace [ 169 - systemtap' # for dtrace 226 + libiconv 170 227 ]; 171 228 172 - propagatedBuildInputs = [ zlib libffi gettext libiconv ]; 229 + nativeCheckInputs = [ 230 + tzdata 231 + desktop-file-utils 232 + shared-mime-info 233 + ]; 173 234 174 - mesonFlags = [ 175 - "-Dglib_debug=disabled" # https://gitlab.gnome.org/GNOME/glib/-/issues/3421#note_2206315 176 - "-Ddocumentation=true" # gvariant specification can be built without gi-docgen 177 - (lib.mesonEnable "dtrace" withDtrace) 178 - (lib.mesonEnable "systemtap" withDtrace) # requires dtrace option to be enabled 179 - "-Dnls=enabled" 180 - "-Ddevbindir=${placeholder "dev"}/bin" 181 - (lib.mesonEnable "introspection" withIntrospection) 182 - # FIXME: Fails when linking target glib/tests/libconstructor-helper.so 183 - # relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object 184 - "-Dtests=${lib.boolToString (!stdenv.hostPlatform.isStatic)}" 185 - ] ++ lib.optionals (!lib.meta.availableOn stdenv.hostPlatform elfutils) [ 186 - "-Dlibelf=disabled" 187 - ] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ 188 - "-Db_lundef=false" 189 - "-Dxattr=false" 190 - "-Dsysprof=disabled" # sysprof-capture does not build on FreeBSD 191 - ]; 235 + mesonFlags = 236 + [ 237 + "-Dglib_debug=disabled" # https://gitlab.gnome.org/GNOME/glib/-/issues/3421#note_2206315 238 + "-Ddocumentation=true" # gvariant specification can be built without gi-docgen 239 + (lib.mesonEnable "dtrace" withDtrace) 240 + (lib.mesonEnable "systemtap" withDtrace) # requires dtrace option to be enabled 241 + "-Dnls=enabled" 242 + "-Ddevbindir=${placeholder "dev"}/bin" 243 + (lib.mesonEnable "introspection" withIntrospection) 244 + # FIXME: Fails when linking target glib/tests/libconstructor-helper.so 245 + # relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object 246 + "-Dtests=${lib.boolToString (!stdenv.hostPlatform.isStatic)}" 247 + ] 248 + ++ lib.optionals (!lib.meta.availableOn stdenv.hostPlatform elfutils) [ 249 + "-Dlibelf=disabled" 250 + ] 251 + ++ lib.optionals stdenv.hostPlatform.isFreeBSD [ 252 + "-Db_lundef=false" 253 + "-Dxattr=false" 254 + "-Dsysprof=disabled" # sysprof-capture does not build on FreeBSD 255 + ]; 192 256 193 - env.NIX_CFLAGS_COMPILE = toString [ 194 - "-Wno-error=nonnull" 195 - # Default for release buildtype but passed manually because 196 - # we're using plain 197 - "-DG_DISABLE_CAST_CHECKS" 198 - ]; 257 + env = { 258 + NIX_CFLAGS_COMPILE = toString [ 259 + "-Wno-error=nonnull" 260 + # Default for release buildtype but passed manually because 261 + # we're using plain 262 + "-DG_DISABLE_CAST_CHECKS" 263 + ]; 264 + }; 199 265 200 - postPatch = '' 201 - patchShebangs glib/gen-unicode-tables.pl 202 - patchShebangs glib/tests/gen-casefold-txt.py 203 - patchShebangs glib/tests/gen-casemap-txt.py 204 - patchShebangs tools/gen-visibility-macros.py 205 - patchShebangs tests 266 + postPatch = 267 + '' 268 + patchShebangs glib/gen-unicode-tables.pl 269 + patchShebangs glib/tests/gen-casefold-txt.py 270 + patchShebangs glib/tests/gen-casemap-txt.py 271 + patchShebangs tools/gen-visibility-macros.py 272 + patchShebangs tests 206 273 207 - # Needs machine-id, comment the test 208 - sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c 209 - sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-address-get-session.c 210 - # All gschemas fail to pass the test, upstream bug? 211 - sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c 212 - # Cannot reproduce the failing test_associations on hydra 213 - sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c 214 - # Needed because of libtool wrappers 215 - sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c 216 - '' + lib.optionalString stdenv.hostPlatform.isWindows '' 217 - substituteInPlace gio/win32/meson.build \ 218 - --replace "libintl, " "" 219 - ''; 274 + # Needs machine-id, comment the test 275 + sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c 276 + sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-address-get-session.c 277 + # All gschemas fail to pass the test, upstream bug? 278 + sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c 279 + # Cannot reproduce the failing test_associations on hydra 280 + sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c 281 + # Needed because of libtool wrappers 282 + sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c 283 + '' 284 + + lib.optionalString stdenv.hostPlatform.isWindows '' 285 + substituteInPlace gio/win32/meson.build \ 286 + --replace "libintl, " "" 287 + ''; 220 288 221 289 postConfigure = '' 222 290 patchShebangs gio/gdbus-2.0/codegen/gdbus-codegen gobject/glib-{genmarshal,mkenums} ··· 257 325 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. 258 326 moveToOutput "share/doc" "$devdoc" 259 327 ''; 260 - 261 - nativeCheckInputs = [ tzdata desktop-file-utils shared-mime-info ]; 262 328 263 329 # Conditional necessary to break infinite recursion with passthru.tests 264 330 preCheck = lib.optionalString finalAttrs.finalPackage.doCheck or config.doCheckByDefault or false '' ··· 302 368 getSchemaDataDirPath = pkg: makeSchemaDataDirPath pkg pkg.name; 303 369 304 370 tests = { 305 - withChecks = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; }); 371 + withChecks = finalAttrs.finalPackage.overrideAttrs (_: { 372 + doCheck = true; 373 + }); 306 374 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 307 375 }; 308 376 ··· 326 394 327 395 meta = with lib; { 328 396 description = "C library of programming buildings blocks"; 329 - homepage = "https://gitlab.gnome.org/GNOME/glib"; 330 - license = licenses.lgpl21Plus; 331 - maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 raskin ]); 397 + homepage = "https://gitlab.gnome.org/GNOME/glib"; 398 + license = licenses.lgpl21Plus; 399 + maintainers = 400 + teams.gnome.members 401 + ++ (with maintainers; [ 402 + lovek323 403 + raskin 404 + ]); 332 405 pkgConfigModules = [ 333 406 "gio-2.0" 334 407 "gobject-2.0" 335 408 "gthread-2.0" 336 409 ]; 337 - platforms = platforms.unix ++ platforms.windows; 410 + platforms = platforms.unix ++ platforms.windows; 338 411 339 412 longDescription = '' 340 413 GLib provides the core application building blocks for libraries