···
25
+
writableTmpDirAsHomeHook,
stdenv.mkDerivation (finalAttrs: {
pname = "muon" + lib.optionalString embedSamurai "-embedded-samurai";
22
-
src = fetchFromSourcehut {
26
-
tag = finalAttrs.version;
27
-
hash = "sha256-xTdyqK8t741raMhjjJBMbWnAorLMMdZ02TeMXK7O+Yw=";
31
+
srcs = builtins.attrValues (lib.filterAttrs (_: v: v.use or true) finalAttrs.passthru.srcsAttrs);
33
+
sourceRoot = "muon-src";
outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ];
···
++ lib.optionals (!embedSamurai) [ samurai ]
++ lib.optionals buildDocs [
37
-
(python3.withPackages (ps: [ ps.pyyaml ]))
44
+
++ lib.optionals (buildDocs || finalAttrs.doCheck) [
45
+
(python3.withPackages (ps: [ ps.pyyaml ]))
···
52
-
# URLs manually extracted from subprojects directory
53
-
meson-docs-wrap = fetchurl {
54
-
name = "meson-docs-wrap";
55
-
url = "https://github.com/muon-build/meson-docs/archive/5bc0b250984722389419dccb529124aed7615583.tar.gz";
56
-
hash = "sha256-5MmmiZfadCuUJ2jy5Rxubwf4twX0jcpr+TPj5ssdSbM=";
58
+
for src in $srcs; do
59
+
name=$(stripHash $src)
59
-
meson-tests-wrap = fetchurl {
60
-
name = "meson-tests-wrap";
61
-
url = "https://github.com/muon-build/meson-tests/archive/591b5a053f9aa15245ccbd1d334cf3f8031b1035.tar.gz";
62
-
hash = "sha256-6GXfcheZyB/S/xl/j7pj5EAWtsmx4N0fVhLPMJ2wC/w=";
66
-
mkdir -p $sourceRoot/subprojects/meson-docs
67
-
pushd $sourceRoot/subprojects/meson-docs
68
-
${lib.optionalString buildDocs "tar xvf ${meson-docs-wrap} --strip-components=1"}
61
+
# skip the main project, only move subprojects
62
+
[ "$name" == "$sourceRoot" ] && continue
71
-
mkdir -p $sourceRoot/subprojects/meson-tests
72
-
pushd $sourceRoot/subprojects/meson-tests
73
-
tar xvf ${meson-tests-wrap} --strip-components=1
64
+
cp -r "$name" "$sourceRoot/subprojects/$name"
65
+
chmod +w -R "$sourceRoot/subprojects/$name"
66
+
rm "$sourceRoot/subprojects/$name.wrap"
70
+
patches = [ ./darwin-clang.patch ];
78
-
patchShebangs bootstrap.sh
73
+
find subprojects -name "*.py" -exec chmod +x {} \;
74
+
patchShebangs subprojects
80
-
+ lib.optionalString buildDocs ''
81
-
patchShebangs subprojects/meson-docs/docs/genrefman.py
76
+
+ lib.optionalString finalAttrs.doCheck ''
78
+
"subprojects/meson-tests/common/14 configure file/test.py.in" \
79
+
"subprojects/meson-tests/common/274 customtarget exe for test/generate.py" \
80
+
"subprojects/meson-tests/native/8 external program shebang parsing/script.int.in" \
81
+
--replace-fail "/usr/bin/env" "${coreutils}/bin/env"
84
+
"subprojects/meson-tests/meson.build" \
85
+
--replace-fail "['common/66 vcstag', {'python': true}]," ""
84
-
# tests try to access "~"
86
-
export HOME=$(mktemp -d)
88
+
enableParallelBuilding = true;
muonBool = lib.mesonBool;
muonEnable = lib.mesonEnable;
94
+
muonOption = lib.mesonOption;
96
+
bootstrapFlags = lib.optionalString (!embedSamurai) "CFLAGS=\"$CFLAGS -DBOOTSTRAP_NO_SAMU\"";
97
+
# see `muon options -a` to see built-in options
cmdlineForMuon = lib.concatStringsSep " " [
99
+
(muonOption "prefix" (placeholder "out"))
100
+
# don't let muon override stdenv C flags
101
+
(muonEnable "auto_features" true)
102
+
(muonOption "buildtype" "plain")
103
+
(muonOption "optimization" "plain")
104
+
(muonOption "wrap_mode" "nodownload")
(muonBool "static" stdenv.targetPlatform.isStatic)
96
-
(muonEnable "docs" buildDocs)
107
+
(muonEnable "man-pages" buildDocs)
108
+
(muonEnable "meson-docs" buildDocs)
109
+
(muonEnable "meson-tests" finalAttrs.doCheck)
(muonEnable "samurai" embedSamurai)
111
+
(muonEnable "tracy" false)
112
+
(muonEnable "website" false)
cmdlineForSamu = "-j$NIX_BUILD_CORES";
105
-
lib.optionalString (!embedSamurai) "CFLAGS=\"$CFLAGS -DBOOTSTRAP_NO_SAMU\""
106
-
} ./bootstrap.sh stage-1
119
+
${bootstrapFlags} ./bootstrap.sh stage-1
./stage-1/muon-bootstrap setup ${cmdlineForMuon} stage-2
${lib.optionalString embedSamurai "./stage-1/muon-bootstrap"} samu ${cmdlineForSamu} -C stage-2
111
-
./stage-2/muon setup -Dprefix=$out ${cmdlineForMuon} stage-3
112
-
${lib.optionalString embedSamurai "./stage-2/muon"} samu ${cmdlineForSamu} -C stage-3
117
-
# tests are failing because they don't find Python
126
+
# tests only pass when samurai is embedded
127
+
doCheck = embedSamurai && runTests;
129
+
nativeCheckInputs = [
130
+
# "common/220 fs module"
131
+
writableTmpDirAsHomeHook
132
+
# "common/44 pkgconfig-gen"
134
+
# "frameworks/6 gettext"
137
+
++ lib.optionals stdenv.hostPlatform.isx86_64 [
123
-
./stage-3/muon -C stage-3 test
145
+
./stage-2/muon -C stage-2 test -d dots -S -j$NIX_BUILD_CORES
···
131
-
stage-3/muon -C stage-3 install
153
+
stage-2/muon -C stage-2 install
137
-
homepage = "https://muon.build/";
138
-
description = "Implementation of Meson build system in C99";
139
-
license = licenses.gpl3Only;
140
-
maintainers = with maintainers; [ ];
141
-
platforms = platforms.unix;
142
-
broken = stdenv.hostPlatform.isDarwin; # typical `ar failure`
158
+
passthru.srcsAttrs = {
159
+
muon-src = fetchFromSourcehut {
163
+
tag = finalAttrs.version;
164
+
hash = "sha256-bWEYWUD+GK8R3yVnDTnzFWmm4KAuVPI+1yMfCXWcG/A=";
166
+
meson-docs = fetchFromGitHub {
167
+
name = "meson-docs";
168
+
repo = "meson-docs";
169
+
owner = "muon-build";
170
+
rev = "1017b3413601044fb41ad04977445e68a80e8181";
171
+
hash = "sha256-aFpyJFIqybLNKhm/kyfCjYylj7DE6muI1+OUh4Cq4WY=";
172
+
passthru.use = buildDocs;
174
+
meson-tests = fetchFromGitHub {
175
+
name = "meson-tests";
176
+
repo = "meson-tests";
177
+
owner = "muon-build";
178
+
rev = "db92588773a24f67cda2f331b945825ca3a63fa7";
179
+
hash = "sha256-z4Fc1lr/m2MwIwhXJwoFWpzeNg+udzMxuw5Q/zVvpSM=";
180
+
passthru.use = finalAttrs.doCheck;
184
+
# tests are run here in package tests, rather than enabling doCheck by
185
+
# default, to reduce the number of required dependencies.
186
+
passthru.tests.test = (muon.overrideAttrs { pname = "muon-tests"; }).override {
188
+
embedSamurai = true;
192
+
passthru.updateScript = callPackage ./update.nix { };
195
+
homepage = "https://muon.build";
196
+
description = "Implementation of the meson build system in C99";
197
+
license = lib.licenses.gpl3Only;
199
+
platforms = lib.platforms.unix;
147
-
# 1. automate sources acquisition (especially wraps)