nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromSourcehut,
5 fetchurl,
6 curl,
7 libarchive,
8 libpkgconf,
9 pkgconf,
10 python3,
11 samurai,
12 scdoc,
13 zlib,
14 embedSamurai ? false,
15 buildDocs ? true,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "muon" + lib.optionalString embedSamurai "-embedded-samurai";
20 version = "0.4.0";
21
22 src = fetchFromSourcehut {
23 name = "muon-src";
24 owner = "~lattis";
25 repo = "muon";
26 rev = finalAttrs.version;
27 hash = "sha256-xTdyqK8t741raMhjjJBMbWnAorLMMdZ02TeMXK7O+Yw=";
28 };
29
30 outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ];
31
32 nativeBuildInputs = [
33 pkgconf
34 ]
35 ++ lib.optionals (!embedSamurai) [ samurai ]
36 ++ lib.optionals buildDocs [
37 (python3.withPackages (ps: [ ps.pyyaml ]))
38 scdoc
39 ];
40
41 buildInputs = [
42 curl
43 libarchive
44 libpkgconf
45 zlib
46 ];
47
48 strictDeps = true;
49
50 postUnpack =
51 let
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=";
57 };
58
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=";
63 };
64 in
65 ''
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"}
69 popd
70
71 mkdir -p $sourceRoot/subprojects/meson-tests
72 pushd $sourceRoot/subprojects/meson-tests
73 tar xvf ${meson-tests-wrap} --strip-components=1
74 popd
75 '';
76
77 postPatch = ''
78 patchShebangs bootstrap.sh
79 ''
80 + lib.optionalString buildDocs ''
81 patchShebangs subprojects/meson-docs/docs/genrefman.py
82 '';
83
84 # tests try to access "~"
85 postConfigure = ''
86 export HOME=$(mktemp -d)
87 '';
88
89 buildPhase =
90 let
91 muonBool = lib.mesonBool;
92 muonEnable = lib.mesonEnable;
93
94 cmdlineForMuon = lib.concatStringsSep " " [
95 (muonBool "static" stdenv.targetPlatform.isStatic)
96 (muonEnable "docs" buildDocs)
97 (muonEnable "samurai" embedSamurai)
98 ];
99 cmdlineForSamu = "-j$NIX_BUILD_CORES";
100 in
101 ''
102 runHook preBuild
103
104 ${
105 lib.optionalString (!embedSamurai) "CFLAGS=\"$CFLAGS -DBOOTSTRAP_NO_SAMU\""
106 } ./bootstrap.sh stage-1
107
108 ./stage-1/muon-bootstrap setup ${cmdlineForMuon} stage-2
109 ${lib.optionalString embedSamurai "./stage-1/muon-bootstrap"} samu ${cmdlineForSamu} -C stage-2
110
111 ./stage-2/muon setup -Dprefix=$out ${cmdlineForMuon} stage-3
112 ${lib.optionalString embedSamurai "./stage-2/muon"} samu ${cmdlineForSamu} -C stage-3
113
114 runHook postBuild
115 '';
116
117 # tests are failing because they don't find Python
118 doCheck = false;
119
120 checkPhase = ''
121 runHook preCheck
122
123 ./stage-3/muon -C stage-3 test
124
125 runHook postCheck
126 '';
127
128 installPhase = ''
129 runHook preInstall
130
131 stage-3/muon -C stage-3 install
132
133 runHook postInstall
134 '';
135
136 meta = with lib; {
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`
143 mainProgram = "muon";
144 };
145})
146# TODO LIST:
147# 1. automate sources acquisition (especially wraps)
148# 2. setup hook
149# 3. tests