summary refs log tree commit diff
path: root/pkgs/by-name/me
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/me')
-rw-r--r--pkgs/by-name/me/mermaid-cli/package.nix2
-rw-r--r--pkgs/by-name/me/meson/001-fix-rpath.patch24
-rw-r--r--pkgs/by-name/me/meson/002-clear-old-rpath.patch20
-rw-r--r--pkgs/by-name/me/meson/003-more-env-vars.patch12
-rw-r--r--pkgs/by-name/me/meson/004-gir-fallback-path.patch21
-rw-r--r--pkgs/by-name/me/meson/005-boost-Do-not-add-system-paths-on-nix.patch21
-rw-r--r--pkgs/by-name/me/meson/006-disable-bitcode.patch24
-rw-r--r--pkgs/by-name/me/meson/emulator-hook.sh5
-rw-r--r--pkgs/by-name/me/meson/package.nix166
-rw-r--r--pkgs/by-name/me/meson/setup-hook.sh87
10 files changed, 381 insertions, 1 deletions
diff --git a/pkgs/by-name/me/mermaid-cli/package.nix b/pkgs/by-name/me/mermaid-cli/package.nix
index a42fe9754ff..a45930287a5 100644
--- a/pkgs/by-name/me/mermaid-cli/package.nix
+++ b/pkgs/by-name/me/mermaid-cli/package.nix
@@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
     cp -r . "$out/lib/node_modules/@mermaid-js/mermaid-cli"
 
     makeWrapper "${nodejs}/bin/node" "$out/bin/mmdc" \
-  '' + lib.optionalString (lib.meta.availableOn stdenv.targetPlatform chromium) ''
+  '' + lib.optionalString (lib.meta.availableOn stdenv.hostPlatform chromium) ''
       --set PUPPETEER_EXECUTABLE_PATH '${lib.getExe chromium}' \
   '' + ''
       --add-flags "$out/lib/node_modules/@mermaid-js/mermaid-cli/src/cli.js"
diff --git a/pkgs/by-name/me/meson/001-fix-rpath.patch b/pkgs/by-name/me/meson/001-fix-rpath.patch
new file mode 100644
index 00000000000..29bec7903ca
--- /dev/null
+++ b/pkgs/by-name/me/meson/001-fix-rpath.patch
@@ -0,0 +1,24 @@
+--- a/mesonbuild/backend/backends.py
++++ b/mesonbuild/backend/backends.py
+@@ -723,6 +723,21 @@
+     @staticmethod
+     def get_rpath_dirs_from_link_args(args: T.List[str]) -> T.Set[str]:
+         dirs: T.Set[str] = set()
++
++        nix_ldflags = os.environ.get('NIX_LDFLAGS', '').split()
++        next_is_path = False
++        # Try to add rpaths set by user or ld-wrapper so that they are not removed.
++        # Based on https://github.com/NixOS/nixpkgs/blob/69711a2f5ffe8cda208163be5258266172ff527f/pkgs/build-support/bintools-wrapper/ld-wrapper.sh#L148-L177
++        for flag in nix_ldflags:
++            if flag == '-rpath' or flag == '-L':
++                next_is_path = True
++            elif next_is_path or flag.startswith('-L/'):
++                if flag.startswith('-L/'):
++                    flag = flag[2:]
++                if flag.startswith('@storeDir@'):
++                    dirs.add(flag)
++                next_is_path = False
++
+         # Match rpath formats:
+         # -Wl,-rpath=
+         # -Wl,-rpath,
diff --git a/pkgs/by-name/me/meson/002-clear-old-rpath.patch b/pkgs/by-name/me/meson/002-clear-old-rpath.patch
new file mode 100644
index 00000000000..f1e3c76e8b5
--- /dev/null
+++ b/pkgs/by-name/me/meson/002-clear-old-rpath.patch
@@ -0,0 +1,20 @@
+diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
+index 4176b9a03..faaabf616 100644
+--- a/mesonbuild/scripts/depfixer.py
++++ b/mesonbuild/scripts/depfixer.py
+@@ -336,6 +336,15 @@ class Elf(DataSizes):
+         if not new_rpath:
+             self.remove_rpath_entry(entrynum)
+         else:
++            # Clear old rpath to avoid stale references,
++            # not heeding the warning above about de-duplication
++            # since it does not seem to cause issues for us
++            # and not doing so trips up Nix’s reference checker.
++            # See https://github.com/NixOS/nixpkgs/pull/46020
++            # and https://github.com/NixOS/nixpkgs/issues/95163
++            self.bf.seek(rp_off)
++            self.bf.write(b'\0'*len(old_rpath))
++
+             self.bf.seek(rp_off)
+             self.bf.write(new_rpath)
+             self.bf.write(b'\0')
diff --git a/pkgs/by-name/me/meson/003-more-env-vars.patch b/pkgs/by-name/me/meson/003-more-env-vars.patch
new file mode 100644
index 00000000000..e4ad4355042
--- /dev/null
+++ b/pkgs/by-name/me/meson/003-more-env-vars.patch
@@ -0,0 +1,12 @@
+diff -Naur meson-0.60.2-old/mesonbuild/environment.py meson-0.60.2-new/mesonbuild/environment.py
+--- meson-0.60.2-old/mesonbuild/environment.py	2021-11-02 16:58:13.000000000 -0300
++++ meson-0.60.2-new/mesonbuild/environment.py	2021-12-12 17:44:00.350499307 -0300
+@@ -68,7 +68,7 @@
+         # compiling we fall back on the unprefixed host version. This
+         # allows native builds to never need to worry about the 'BUILD_*'
+         # ones.
+-        ([var_name + '_FOR_BUILD'] if is_cross else [var_name]),
++        [var_name + '_FOR_BUILD'] + ([] if is_cross else [var_name]),
+         # Always just the unprefixed host versions
+         [var_name]
+     )[for_machine]
diff --git a/pkgs/by-name/me/meson/004-gir-fallback-path.patch b/pkgs/by-name/me/meson/004-gir-fallback-path.patch
new file mode 100644
index 00000000000..e6d74026527
--- /dev/null
+++ b/pkgs/by-name/me/meson/004-gir-fallback-path.patch
@@ -0,0 +1,21 @@
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 1c6952df7..9466a0b7d 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -923,6 +923,16 @@ class GnomeModule(ExtensionModule):
+         if fatal_warnings:
+             scan_command.append('--warn-error')
+
++        if len(set(girtarget.get_custom_install_dir()[0] for girtarget in girtargets if girtarget.get_custom_install_dir())) > 1:
++            raise MesonException('generate_gir tries to build multiple libraries with different install_dir at once: {}'.format(','.join([str(girtarget) for girtarget in girtargets])))
++
++        if girtargets[0].get_custom_install_dir():
++            fallback_libpath = girtargets[0].get_custom_install_dir()[0]
++        else:
++            fallback_libpath = None
++        if fallback_libpath is not None and isinstance(fallback_libpath, str) and len(fallback_libpath) > 0 and fallback_libpath[0] == "/":
++            scan_command += ['--fallback-library-path=' + fallback_libpath]
++
+         generated_files = [f for f in libsources if isinstance(f, (GeneratedList, CustomTarget, CustomTargetIndex))]
+ 
+         scan_target = self._make_gir_target(state, girfile, scan_command, generated_files, depends, kwargs)
diff --git a/pkgs/by-name/me/meson/005-boost-Do-not-add-system-paths-on-nix.patch b/pkgs/by-name/me/meson/005-boost-Do-not-add-system-paths-on-nix.patch
new file mode 100644
index 00000000000..0a2eda9de9a
--- /dev/null
+++ b/pkgs/by-name/me/meson/005-boost-Do-not-add-system-paths-on-nix.patch
@@ -0,0 +1,21 @@
+diff -Naur meson-0.60.2-old/mesonbuild/dependencies/boost.py meson-0.60.2-new/mesonbuild/dependencies/boost.py
+--- meson-0.60.2-old/mesonbuild/dependencies/boost.py	2021-11-02 16:58:07.000000000 -0300
++++ meson-0.60.2-new/mesonbuild/dependencies/boost.py	2021-12-12 19:21:27.895705897 -0300
+@@ -682,16 +682,7 @@
+         else:
+             tmp = []  # type: T.List[Path]
+ 
+-            # Add some default system paths
+-            tmp += [Path('/opt/local')]
+-            tmp += [Path('/usr/local/opt/boost')]
+-            tmp += [Path('/usr/local')]
+-            tmp += [Path('/usr')]
+-
+-            # Cleanup paths
+-            tmp = [x for x in tmp if x.is_dir()]
+-            tmp = [x.resolve() for x in tmp]
+-            roots += tmp
++            # Remove such spurious, non-explicit "system" paths for Nix&Nixpkgs
+ 
+         self.check_and_set_roots(roots, use_system=True)
+ 
diff --git a/pkgs/by-name/me/meson/006-disable-bitcode.patch b/pkgs/by-name/me/meson/006-disable-bitcode.patch
new file mode 100644
index 00000000000..a72997c1043
--- /dev/null
+++ b/pkgs/by-name/me/meson/006-disable-bitcode.patch
@@ -0,0 +1,24 @@
+--- a/mesonbuild/compilers/mixins/clang.py
++++ b/mesonbuild/compilers/mixins/clang.py
+@@ -56,10 +56,6 @@ class ClangCompiler(GnuLikeCompiler):
+             {OptionKey('b_colorout'), OptionKey('b_lto_threads'), OptionKey('b_lto_mode'), OptionKey('b_thinlto_cache'),
+              OptionKey('b_thinlto_cache_dir')})
+ 
+-        # TODO: this really should be part of the linker base_options, but
+-        # linkers don't have base_options.
+-        if isinstance(self.linker, AppleDynamicLinker):
+-            self.base_options.add(OptionKey('b_bitcode'))
+         # All Clang backends can also do LLVM IR
+         self.can_compile_suffixes.add('ll')
+ 
+--- a/mesonbuild/linkers/linkers.py
++++ b/mesonbuild/linkers/linkers.py
+@@ -785,7 +785,7 @@ class AppleDynamicLinker(PosixDynamicLinkerMixin, DynamicLinker):
+         return self._apply_prefix('-headerpad_max_install_names')
+ 
+     def bitcode_args(self) -> T.List[str]:
+-        return self._apply_prefix('-bitcode_bundle')
++        raise MesonException('Nixpkgs cctools does not support bitcode bundles')
+ 
+     def fatal_warnings(self) -> T.List[str]:
+         return self._apply_prefix('-fatal_warnings')
diff --git a/pkgs/by-name/me/meson/emulator-hook.sh b/pkgs/by-name/me/meson/emulator-hook.sh
new file mode 100644
index 00000000000..4f08087cf5f
--- /dev/null
+++ b/pkgs/by-name/me/meson/emulator-hook.sh
@@ -0,0 +1,5 @@
+add_meson_exe_wrapper_cross_flag() {
+  mesonFlagsArray+=(--cross-file=@crossFile@)
+}
+
+preConfigureHooks+=(add_meson_exe_wrapper_cross_flag)
diff --git a/pkgs/by-name/me/meson/package.nix b/pkgs/by-name/me/meson/package.nix
new file mode 100644
index 00000000000..6239927848a
--- /dev/null
+++ b/pkgs/by-name/me/meson/package.nix
@@ -0,0 +1,166 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, fetchpatch
+, installShellFiles
+, coreutils
+, darwin
+, libxcrypt
+, ninja
+, pkg-config
+, python3
+, substituteAll
+, zlib
+}:
+
+let
+  inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation OpenGL;
+in
+python3.pkgs.buildPythonApplication rec {
+  pname = "meson";
+  version = "1.2.3";
+
+  src = fetchFromGitHub {
+    owner = "mesonbuild";
+    repo = "meson";
+    rev = "refs/tags/${version}";
+    hash = "sha256-dgYYz3tQDG6Z4eE77WO2dXdardxVzzGaFLQ5znPcTlw=";
+  };
+
+  patches = [
+    # In typical distributions, RPATH is only needed for internal libraries so
+    # meson removes everything else. With Nix, the locations of libraries
+    # are not as predictable, therefore we need to keep them in the RPATH.
+    # At the moment we are keeping the paths starting with /nix/store.
+    # https://github.com/NixOS/nixpkgs/issues/31222#issuecomment-365811634
+    (substituteAll {
+      src = ./001-fix-rpath.patch;
+      inherit (builtins) storeDir;
+    })
+
+    # When Meson removes build_rpath from DT_RUNPATH entry, it just writes
+    # the shorter NUL-terminated new rpath over the old one to reduce
+    # the risk of potentially breaking the ELF files.
+    # But this can cause much bigger problem for Nix as it can produce
+    # cut-in-half-by-\0 store path references.
+    # Let’s just clear the whole rpath and hope for the best.
+    ./002-clear-old-rpath.patch
+
+    # Meson is currently inspecting fewer variables than autoconf does, which
+    # makes it harder for us to use setup hooks, etc.
+    # https://github.com/mesonbuild/meson/pull/6827
+    ./003-more-env-vars.patch
+
+    # Unlike libtool, vanilla Meson does not pass any information about the path
+    # library will be installed to to g-ir-scanner, breaking the GIR when path
+    # other than ${!outputLib}/lib is used.
+    # We patch Meson to add a --fallback-library-path argument with library
+    # install_dir to g-ir-scanner.
+    ./004-gir-fallback-path.patch
+
+    # Patch out default boost search paths to avoid impure builds on
+    # unsandboxed non-NixOS builds, see:
+    # https://github.com/NixOS/nixpkgs/issues/86131#issuecomment-711051774
+    ./005-boost-Do-not-add-system-paths-on-nix.patch
+
+    # Nixpkgs cctools does not have bitcode support.
+    ./006-disable-bitcode.patch
+
+    # Fix passing multiple --define-variable arguments to pkg-config.
+    # https://github.com/mesonbuild/meson/pull/10670
+    (fetchpatch {
+      url = "https://github.com/mesonbuild/meson/commit/d5252c5d4cf1c1931fef0c1c98dd66c000891d21.patch";
+      hash = "sha256-GiUNVul1N5Fl8mfqM7vA/r1FdKqImiDYLXMVDt77gvw=";
+      excludes = [
+        "docs/yaml/objects/dep.yaml"
+      ];
+    })
+  ];
+
+  buildInputs = lib.optionals (python3.pythonOlder "3.9") [
+    libxcrypt
+  ];
+
+  nativeBuildInputs = [ installShellFiles ];
+
+  nativeCheckInputs = [
+    ninja
+    pkg-config
+  ];
+
+  checkInputs = [
+    zlib
+  ]
+  ++ lib.optionals stdenv.isDarwin [
+    AppKit
+    Cocoa
+    Foundation
+    OpenGL
+  ];
+
+  checkPhase = lib.concatStringsSep "\n" ([
+    "runHook preCheck"
+    ''
+      patchShebangs 'test cases'
+      substituteInPlace \
+        'test cases/native/8 external program shebang parsing/script.int.in' \
+          --replace /usr/bin/env ${coreutils}/bin/env
+    ''
+  ]
+  # Remove problematic tests
+  ++ (builtins.map (f: ''rm -vr "${f}";'') [
+    # requires git, creating cyclic dependency
+    ''test cases/common/66 vcstag''
+    # requires glib, creating cyclic dependency
+    ''test cases/linuxlike/6 subdir include order''
+    ''test cases/linuxlike/9 compiler checks with dependencies''
+    # requires static zlib, see #66461
+    ''test cases/linuxlike/14 static dynamic linkage''
+    # Nixpkgs cctools does not have bitcode support.
+    ''test cases/osx/7 bitcode''
+  ])
+  ++ [
+    ''HOME="$TMPDIR" python ./run_project_tests.py''
+    "runHook postCheck"
+  ]);
+
+  postInstall = ''
+    installShellCompletion --zsh data/shell-completions/zsh/_meson
+    installShellCompletion --bash data/shell-completions/bash/meson
+  '';
+
+  postFixup = ''
+    pushd $out/bin
+    # undo shell wrapper as meson tools are called with python
+    for i in *; do
+      mv ".$i-wrapped" "$i"
+    done
+    popd
+
+    # Do not propagate Python
+    rm $out/nix-support/propagated-build-inputs
+
+    substituteInPlace "$out/share/bash-completion/completions/meson" \
+      --replace "python3 -c " "${python3.interpreter} -c "
+  '';
+
+  setupHook = ./setup-hook.sh;
+
+  meta = {
+    homepage = "https://mesonbuild.com";
+    description = "An open source, fast and friendly build system made in Python";
+    longDescription = ''
+      Meson is an open source build system meant to be both extremely fast, and,
+      even more importantly, as user friendly as possible.
+
+      The main design point of Meson is that every moment a developer spends
+      writing or debugging build definitions is a second wasted. So is every
+      second spent waiting for the build system to actually start compiling
+      code.
+    '';
+    license = lib.licenses.asl20;
+    maintainers = with lib.maintainers; [ AndersonTorres ];
+    inherit (python3.meta) platforms;
+  };
+}
+# TODO: a more Nixpkgs-tailoired test suite
diff --git a/pkgs/by-name/me/meson/setup-hook.sh b/pkgs/by-name/me/meson/setup-hook.sh
new file mode 100644
index 00000000000..85849fbec73
--- /dev/null
+++ b/pkgs/by-name/me/meson/setup-hook.sh
@@ -0,0 +1,87 @@
+# shellcheck shell=bash disable=SC2206
+
+mesonConfigurePhase() {
+    runHook preConfigure
+
+    local flagsArray=()
+
+    if [ -z "${dontAddPrefix-}" ]; then
+        flagsArray+=("--prefix=$prefix")
+    fi
+
+    # See multiple-outputs.sh and meson’s coredata.py
+    flagsArray+=(
+        "--libdir=${!outputLib}/lib"
+        "--libexecdir=${!outputLib}/libexec"
+        "--bindir=${!outputBin}/bin"
+        "--sbindir=${!outputBin}/sbin"
+        "--includedir=${!outputInclude}/include"
+        "--mandir=${!outputMan}/share/man"
+        "--infodir=${!outputInfo}/share/info"
+        "--localedir=${!outputLib}/share/locale"
+        "-Dauto_features=${mesonAutoFeatures:-enabled}"
+        "-Dwrap_mode=${mesonWrapMode:-nodownload}"
+        ${crossMesonFlags}
+        "--buildtype=${mesonBuildType:-plain}"
+    )
+
+    flagsArray+=(
+        $mesonFlags
+        "${mesonFlagsArray[@]}"
+    )
+
+    echoCmd 'mesonConfigurePhase flags' "${flagsArray[@]}"
+
+    meson setup build "${flagsArray[@]}"
+    cd build || { echoCmd 'mesonConfigurePhase' "could not cd to build"; exit 1; }
+
+    if ! [[ -v enableParallelBuilding ]]; then
+        enableParallelBuilding=1
+        echoCmd 'mesonConfigurePhase' "enabled parallel building"
+    fi
+
+    if [[ ${checkPhase-ninjaCheckPhase} = ninjaCheckPhase && -z $dontUseMesonCheck ]]; then
+        checkPhase=mesonCheckPhase
+    fi
+    if [[ ${installPhase-ninjaInstallPhase} = ninjaInstallPhase && -z $dontUseMesonInstall ]]; then
+        installPhase=mesonInstallPhase
+    fi
+
+    runHook postConfigure
+}
+
+mesonCheckPhase() {
+    runHook preCheck
+
+    local flagsArray=($mesonCheckFlags "${mesonCheckFlagsArray[@]}")
+
+    echoCmd 'mesonCheckPhase flags' "${flagsArray[@]}"
+    meson test --no-rebuild "${flagsArray[@]}"
+
+    runHook postCheck
+}
+
+mesonInstallPhase() {
+    runHook preInstall
+
+    local flagsArray=()
+
+    if [[ -n "$mesonInstallTags" ]]; then
+        flagsArray+=("--tags" "${mesonInstallTags// /,}")
+    fi
+    flagsArray+=(
+        $mesonInstallFlags
+        "${mesonInstallFlagsArray[@]}"
+    )
+
+    echoCmd 'mesonInstallPhase flags' "${flagsArray[@]}"
+    meson install --no-rebuild "${flagsArray[@]}"
+
+    runHook postInstall
+}
+
+if [ -z "${dontUseMesonConfigure-}" ] && [ -z "${configurePhase-}" ]; then
+    # shellcheck disable=SC2034
+    setOutputFlags=
+    configurePhase=mesonConfigurePhase
+fi