20 inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation LDAP OpenAL OpenGL;
22 python3.pkgs.buildPythonApplication rec {
26 src = fetchFromGitHub {
29 rev = "refs/tags/${version}";
30 hash = "sha256-cesMepnD3fHX2CwnSQ3c5TE9kPSa0FkCVVVZDgXwo8M=";
34 # Nixpkgs cmake uses NIXPKGS_CMAKE_PREFIX_PATH for the search path
35 ./000-nixpkgs-cmake-prefix-path.patch
37 # In typical distributions, RPATH is only needed for internal libraries so
38 # meson removes everything else. With Nix, the locations of libraries
39 # are not as predictable, therefore we need to keep them in the RPATH.
40 # At the moment we are keeping the paths starting with /nix/store.
41 # https://github.com/NixOS/nixpkgs/issues/31222#issuecomment-365811634
43 src = ./001-fix-rpath.patch;
44 inherit (builtins) storeDir;
47 # When Meson removes build_rpath from DT_RUNPATH entry, it just writes
48 # the shorter NUL-terminated new rpath over the old one to reduce
49 # the risk of potentially breaking the ELF files.
50 # But this can cause much bigger problem for Nix as it can produce
51 # cut-in-half-by-\0 store path references.
52 # Let’s just clear the whole rpath and hope for the best.
53 ./002-clear-old-rpath.patch
55 # Meson is currently inspecting fewer variables than autoconf does, which
56 # makes it harder for us to use setup hooks, etc.
57 # https://github.com/mesonbuild/meson/pull/6827
58 ./003-more-env-vars.patch
60 # Unlike libtool, vanilla Meson does not pass any information about the path
61 # library will be installed to to g-ir-scanner, breaking the GIR when path
62 # other than ${!outputLib}/lib is used.
63 # We patch Meson to add a --fallback-library-path argument with library
64 # install_dir to g-ir-scanner.
65 ./004-gir-fallback-path.patch
67 # Patch out default boost search paths to avoid impure builds on
68 # unsandboxed non-NixOS builds, see:
69 # https://github.com/NixOS/nixpkgs/issues/86131#issuecomment-711051774
70 ./005-boost-Do-not-add-system-paths-on-nix.patch
72 # Nixpkgs cctools does not have bitcode support.
73 ./006-disable-bitcode.patch
75 # This edge case is explicitly part of meson but is wrong for nix
76 ./007-freebsd-pkgconfig-path.patch
79 name = "tests-skip-framework-recasting-if-CMake-unavailable.patch";
80 url = "https://github.com/mesonbuild/meson/commit/8a8a3a0578fd8d5a8720a7a706f6f3b99e857f9c.patch";
81 hash = "sha256-XkwNQ5eg/fVekhsFg/V2/S2LbIVGz3H0wsSFlUT3ZZE=";
84 # Fix extraframework lookup on case-sensitive APFS.
85 # https://github.com/mesonbuild/meson/pull/13038
86 ./007-case-sensitive-fs.patch
88 # Fix meson's detection for zig's linker
89 # https://github.com/mesonbuild/meson/pull/12293
91 name = "linker-support-zig-cc.patch";
92 url = "https://github.com/mesonbuild/meson/pull/12293/commits/2baae244c995794d9addfe6ed924dfa72f01be82.patch";
93 hash = "sha256-dDOmSRBKl/gs7I3kmLXIyQk3zsOdlaYov72pPSel4+I=";
97 buildInputs = lib.optionals (python3.pythonOlder "3.9") [
101 nativeBuildInputs = [ installShellFiles ];
103 nativeCheckInputs = [
111 ++ lib.optionals stdenv.hostPlatform.isDarwin [
119 ] ++ lib.optionals (stdenv.cc.isClang && !stdenv.hostPlatform.isDarwin) [
120 # https://github.com/mesonbuild/meson/blob/bd3f1b2e0e70ef16dfa4f441686003212440a09b/test%20cases/common/184%20openmp/meson.build
122 # https://github.com/mesonbuild/meson/blob/1670fca36fcb1a4fe4780e96731e954515501a35/test%20cases/frameworks/29%20blocks/meson.build
126 checkPhase = lib.concatStringsSep "\n" ([
129 patchShebangs 'test cases'
131 'test cases/native/8 external program shebang parsing/script.int.in' \
132 'test cases/common/273 customtarget exe for test/generate.py' \
133 --replace /usr/bin/env ${coreutils}/bin/env
136 # Remove problematic tests
137 ++ (builtins.map (f: ''rm -vr "${f}";'') ([
138 # requires git, creating cyclic dependency
139 ''test cases/common/66 vcstag''
140 # requires glib, creating cyclic dependency
141 ''test cases/linuxlike/6 subdir include order''
142 ''test cases/linuxlike/9 compiler checks with dependencies''
143 # requires static zlib, see #66461
144 ''test cases/linuxlike/14 static dynamic linkage''
145 # Nixpkgs cctools does not have bitcode support.
146 ''test cases/osx/7 bitcode''
147 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
148 # requires llvmPackages.openmp, creating cyclic dependency
149 ''test cases/common/184 openmp''
150 ] ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
151 # pch doesn't work quite right on FreeBSD, I think
152 ''test cases/common/13 pch''
155 ''HOME="$TMPDIR" python ./run_project_tests.py''
160 installShellCompletion --zsh data/shell-completions/zsh/_meson
161 installShellCompletion --bash data/shell-completions/bash/meson
166 # undo shell wrapper as meson tools are called with python
168 mv ".$i-wrapped" "$i"
172 # Do not propagate Python
173 rm $out/nix-support/propagated-build-inputs
175 substituteInPlace "$out/share/bash-completion/completions/meson" \
176 --replace "python3 -c " "${python3.interpreter} -c "
179 setupHook = ./setup-hook.sh;
182 homepage = "https://mesonbuild.com";
183 description = "Open source, fast and friendly build system made in Python";
184 mainProgram = "meson";
186 Meson is an open source build system meant to be both extremely fast, and,
187 even more importantly, as user friendly as possible.
189 The main design point of Meson is that every moment a developer spends
190 writing or debugging build definitions is a second wasted. So is every
191 second spent waiting for the build system to actually start compiling
194 license = lib.licenses.asl20;
195 maintainers = with lib.maintainers; [ AndersonTorres qyliss ];
196 inherit (python3.meta) platforms;
199 # TODO: a more Nixpkgs-tailoired test suite