Commit 4fafd05b authored by Jan Tojnar's avatar Jan Tojnar
Browse files

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.
parent ea6117d6
Loading
Loading
Loading
Loading
+261 −188
Original line number Diff line number Diff line
{ config
, lib
, stdenv
, fetchurl
, gettext
, meson
, ninja
, pkg-config
, perl
, python3
, python3Packages
, libiconv, zlib, libffi, pcre2, elfutils, gnome, libselinux, bash, gnum4, libxslt
, docutils, gi-docgen
{
  config,
  lib,
  stdenv,
  fetchurl,
  gettext,
  meson,
  ninja,
  pkg-config,
  perl,
  python3,
  python3Packages,
  libiconv,
  zlib,
  libffi,
  pcre2,
  elfutils,
  gnome,
  libselinux,
  bash,
  gnum4,
  libxslt,
  docutils,
  gi-docgen,
  # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib)
, util-linuxMinimal ? null
, buildPackages
  util-linuxMinimal ? null,
  buildPackages,

  # this is just for tests (not in the closure of any regular package)
, dbus, tzdata
, desktop-file-utils, shared-mime-info
, darwin
, makeHardcodeGsettingsPatch
, testers
, gobject-introspection
, libsystemtap
, libsysprof-capture
, mesonEmulatorHook
, withIntrospection ?
  stdenv.hostPlatform.emulatorAvailable buildPackages &&
  lib.meta.availableOn stdenv.hostPlatform gobject-introspection &&
  stdenv.hostPlatform.isLittleEndian == stdenv.buildPlatform.isLittleEndian
  dbus,
  tzdata,
  desktop-file-utils,
  shared-mime-info,
  darwin,
  makeHardcodeGsettingsPatch,
  testers,
  gobject-introspection,
  libsystemtap,
  libsysprof-capture,
  mesonEmulatorHook,
  withIntrospection ?
    stdenv.hostPlatform.emulatorAvailable buildPackages
    && lib.meta.availableOn stdenv.hostPlatform gobject-introspection
    && stdenv.hostPlatform.isLittleEndian == stdenv.buildPlatform.isLittleEndian,
}:

assert stdenv.hostPlatform.isLinux -> util-linuxMinimal != null;
@@ -40,15 +53,23 @@ let
    x11Support = false;
  };

  librarySuffix = if (stdenv.hostPlatform.extensions.library == ".so") then "2.0.so.0"
                  else if (stdenv.hostPlatform.extensions.library == ".dylib") then "2.0.0.dylib"
                  else if (stdenv.hostPlatform.extensions.library == ".a") then "2.0.a"
                  else if (stdenv.hostPlatform.extensions.library == ".dll") then "2.0-0.dll"
                  else "2.0-0.lib";
  librarySuffix =
    if (stdenv.hostPlatform.extensions.library == ".so") then
      "2.0.so.0"
    else if (stdenv.hostPlatform.extensions.library == ".dylib") then
      "2.0.0.dylib"
    else if (stdenv.hostPlatform.extensions.library == ".a") then
      "2.0.a"
    else if (stdenv.hostPlatform.extensions.library == ".dll") then
      "2.0-0.dll"
    else
      "2.0-0.lib";

  systemtap' = buildPackages.linuxPackages.systemtap.override { withStap = false; };

  withDtrace =
    lib.meta.availableOn stdenv.buildPlatform systemtap' &&
    lib.meta.availableOn stdenv.buildPlatform systemtap'
    &&
      # dtrace support requires sys/sdt.h header
      lib.meta.availableOn stdenv.hostPlatform libsystemtap;
in
@@ -57,17 +78,29 @@ stdenv.mkDerivation (finalAttrs: {
  pname = "glib";
  version = "2.82.1";

  outputs = [
    "bin"
    "out"
    "dev"
    "devdoc"
  ];

  setupHook = ./setup-hook.sh;

  src = fetchurl {
    url = "mirror://gnome/sources/glib/${lib.versions.majorMinor finalAttrs.version}/glib-${finalAttrs.version}.tar.xz";
    hash = "sha256-R4Y0RAv1LuTsRCjVWHhzmMC+awQ8UhvrMIM0s9tEiaY=";
  };

  patches = lib.optionals stdenv.hostPlatform.isDarwin [
  patches =
    lib.optionals stdenv.hostPlatform.isDarwin [
      ./darwin-compilation.patch
  ] ++ lib.optionals stdenv.hostPlatform.isMusl [
    ]
    ++ lib.optionals stdenv.hostPlatform.isMusl [
      ./quark_init_on_demand.patch
      ./gobject_init_on_demand.patch
  ] ++ [
    ]
    ++ [
      # This patch lets GLib's GDesktopAppInfo API watch and notice changes
      # to the Nix user and system profiles.  That way, the list of available
      # applications shown by the desktop environment is immediately updated
@@ -120,36 +153,50 @@ stdenv.mkDerivation (finalAttrs: {
      ./gdb_script.patch
    ];

  outputs = [ "bin" "out" "dev" "devdoc" ];

  setupHook = ./setup-hook.sh;
  strictDeps = true;

  buildInputs = [
  buildInputs =
    [
      finalAttrs.setupHook
  ] ++ lib.optionals (!stdenv.hostPlatform.isFreeBSD) [
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isFreeBSD) [
      libsysprof-capture
  ] ++ [
    ]
    ++ [
      pcre2
  ] ++ lib.optionals (!stdenv.hostPlatform.isWindows) [
    bash gnum4 # install glib-gettextize and m4 macros for other apps to use
  ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
    ]
    ++ lib.optionals (!stdenv.hostPlatform.isWindows) [
      bash
      gnum4 # install glib-gettextize and m4 macros for other apps to use
    ]
    ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform elfutils) [
      elfutils
  ] ++ lib.optionals withDtrace [
    ]
    ++ lib.optionals withDtrace [
      libsystemtap
  ] ++ lib.optionals stdenv.hostPlatform.isLinux [
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      libselinux
      util-linuxMinimal # for libmount
  ] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
    AppKit Carbon Cocoa CoreFoundation CoreServices Foundation
  ]);

  strictDeps = true;
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin (
      with darwin.apple_sdk.frameworks;
      [
        AppKit
        Carbon
        Cocoa
        CoreFoundation
        CoreServices
        Foundation
      ]
    );

  depsBuildBuild = [
    pkg-config # required to find native gi-docgen
  ];

  nativeBuildInputs = [
  nativeBuildInputs =
    [
      docutils # for rst2man, rst2html5
      meson
      ninja
@@ -160,18 +207,33 @@ stdenv.mkDerivation (finalAttrs: {
      python3Packages.wrapPython # for patchPythonScript
      gettext
      libxslt
  ] ++ lib.optionals withIntrospection [
    ]
    ++ lib.optionals withIntrospection [
      gi-docgen
      gobject-introspection'
  ] ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
    ]
    ++ lib.optionals (withIntrospection && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
      mesonEmulatorHook
  ] ++ lib.optionals withDtrace [
    ]
    ++ lib.optionals withDtrace [
      systemtap' # for dtrace
    ];

  propagatedBuildInputs = [ zlib libffi gettext libiconv ];
  propagatedBuildInputs = [
    zlib
    libffi
    gettext
    libiconv
  ];

  nativeCheckInputs = [
    tzdata
    desktop-file-utils
    shared-mime-info
  ];

  mesonFlags = [
  mesonFlags =
    [
      "-Dglib_debug=disabled" # https://gitlab.gnome.org/GNOME/glib/-/issues/3421#note_2206315
      "-Ddocumentation=true" # gvariant specification can be built without gi-docgen
      (lib.mesonEnable "dtrace" withDtrace)
@@ -182,22 +244,27 @@ stdenv.mkDerivation (finalAttrs: {
      # FIXME: Fails when linking target glib/tests/libconstructor-helper.so
      # relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
      "-Dtests=${lib.boolToString (!stdenv.hostPlatform.isStatic)}"
  ] ++ lib.optionals (!lib.meta.availableOn stdenv.hostPlatform elfutils) [
    ]
    ++ lib.optionals (!lib.meta.availableOn stdenv.hostPlatform elfutils) [
      "-Dlibelf=disabled"
  ] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
    ]
    ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
      "-Db_lundef=false"
      "-Dxattr=false"
      "-Dsysprof=disabled" # sysprof-capture does not build on FreeBSD
    ];

  env.NIX_CFLAGS_COMPILE = toString [
  env = {
    NIX_CFLAGS_COMPILE = toString [
      "-Wno-error=nonnull"
      # Default for release buildtype but passed manually because
      # we're using plain
      "-DG_DISABLE_CAST_CHECKS"
    ];
  };

  postPatch = ''
  postPatch =
    ''
      patchShebangs glib/gen-unicode-tables.pl
      patchShebangs glib/tests/gen-casefold-txt.py
      patchShebangs glib/tests/gen-casemap-txt.py
@@ -213,7 +280,8 @@ stdenv.mkDerivation (finalAttrs: {
      sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c
      # Needed because of libtool wrappers
      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
  '' + lib.optionalString stdenv.hostPlatform.isWindows ''
    ''
    + lib.optionalString stdenv.hostPlatform.isWindows ''
      substituteInPlace gio/win32/meson.build \
        --replace "libintl, " ""
    '';
@@ -258,8 +326,6 @@ stdenv.mkDerivation (finalAttrs: {
    moveToOutput "share/doc" "$devdoc"
  '';

  nativeCheckInputs = [ tzdata desktop-file-utils shared-mime-info ];

  # Conditional necessary to break infinite recursion with passthru.tests
  preCheck = lib.optionalString finalAttrs.finalPackage.doCheck or config.doCheckByDefault or false ''
    export LD_LIBRARY_PATH="$NIX_BUILD_TOP/glib-${finalAttrs.version}/glib/.libs''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
@@ -302,7 +368,9 @@ stdenv.mkDerivation (finalAttrs: {
    getSchemaDataDirPath = pkg: makeSchemaDataDirPath pkg pkg.name;

    tests = {
      withChecks = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; });
      withChecks = finalAttrs.finalPackage.overrideAttrs (_: {
        doCheck = true;
      });
      pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
    };

@@ -328,7 +396,12 @@ stdenv.mkDerivation (finalAttrs: {
    description = "C library of programming buildings blocks";
    homepage = "https://gitlab.gnome.org/GNOME/glib";
    license = licenses.lgpl21Plus;
    maintainers = teams.gnome.members ++ (with maintainers; [ lovek323 raskin ]);
    maintainers =
      teams.gnome.members
      ++ (with maintainers; [
        lovek323
        raskin
      ]);
    pkgConfigModules = [
      "gio-2.0"
      "gobject-2.0"