2022-09-30 11:47:45 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromSourcehut
|
|
|
|
, fetchurl
|
|
|
|
, curl
|
|
|
|
, libarchive
|
|
|
|
, libpkgconf
|
|
|
|
, pkgconf
|
|
|
|
, python3
|
|
|
|
, samurai
|
|
|
|
, scdoc
|
|
|
|
, zlib
|
|
|
|
, embedSamurai ? false
|
|
|
|
, buildDocs ? true
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "muon"
|
|
|
|
+ lib.optionalString embedSamurai "-embedded-samurai";
|
2023-04-29 16:46:19 +00:00
|
|
|
version = "0.2.0";
|
2022-09-30 11:47:45 +00:00
|
|
|
|
|
|
|
src = fetchFromSourcehut {
|
|
|
|
name = "muon-src";
|
|
|
|
owner = "~lattis";
|
|
|
|
repo = "muon";
|
2022-10-21 18:38:19 +00:00
|
|
|
rev = finalAttrs.version;
|
2023-04-29 16:46:19 +00:00
|
|
|
hash = "sha256-ZHWyUV/BqM3ihauXDqDVkZURDDbBiRcEzptyGQmw94I=";
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
outputs = [ "out" ] ++ lib.optionals buildDocs [ "man" ];
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgconf
|
|
|
|
samurai
|
|
|
|
]
|
|
|
|
++ lib.optionals buildDocs [
|
|
|
|
(python3.withPackages (ps: [ ps.pyyaml ]))
|
|
|
|
scdoc
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
curl
|
|
|
|
libarchive
|
|
|
|
libpkgconf
|
|
|
|
samurai
|
|
|
|
zlib
|
|
|
|
];
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
postUnpack = let
|
|
|
|
# URLs manually extracted from subprojects directory
|
|
|
|
meson-docs-wrap = fetchurl {
|
|
|
|
name = "meson-docs-wrap";
|
2023-04-29 16:46:19 +00:00
|
|
|
url = "https://mochiro.moe/wrap/meson-docs-1.0.1-19-gdd8d4ee22.tar.gz";
|
|
|
|
hash = "sha256-jHSPdLFR5jUeds4e+hLZ6JOblor5iuCV5cIwoc4K9gI=";
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
samurai-wrap = fetchurl {
|
|
|
|
name = "samurai-wrap";
|
2023-04-29 16:46:19 +00:00
|
|
|
url = "https://mochiro.moe/wrap/samurai-1.2-32-g81cef5d.tar.gz";
|
|
|
|
hash = "sha256-aPMAtScqweGljvOLaTuR6B0A0GQQQrVbRviXY4dpCoc=";
|
2022-09-30 11:47:45 +00:00
|
|
|
};
|
|
|
|
in ''
|
|
|
|
pushd $sourceRoot/subprojects
|
|
|
|
${lib.optionalString buildDocs "tar xvf ${meson-docs-wrap}"}
|
|
|
|
${lib.optionalString embedSamurai "tar xvf ${samurai-wrap}"}
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs bootstrap.sh
|
|
|
|
''
|
|
|
|
+ lib.optionalString buildDocs ''
|
|
|
|
patchShebangs subprojects/meson-docs/docs/genrefman.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
# tests try to access "~"
|
|
|
|
postConfigure = ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = let
|
2022-12-17 10:02:37 +00:00
|
|
|
muonBool = lib.mesonBool;
|
|
|
|
muonEnable = lib.mesonEnable;
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
cmdlineForMuon = lib.concatStringsSep " " [
|
2022-12-17 10:02:37 +00:00
|
|
|
(muonBool "static" stdenv.targetPlatform.isStatic)
|
|
|
|
(muonEnable "docs" buildDocs)
|
|
|
|
(muonEnable "samurai" embedSamurai)
|
2022-09-30 11:47:45 +00:00
|
|
|
];
|
|
|
|
cmdlineForSamu = "-j$NIX_BUILD_CORES";
|
|
|
|
in ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
./bootstrap.sh stage-1
|
|
|
|
|
|
|
|
./stage-1/muon setup ${cmdlineForMuon} stage-2
|
|
|
|
samu ${cmdlineForSamu} -C stage-2
|
|
|
|
|
|
|
|
stage-2/muon setup -Dprefix=$out ${cmdlineForMuon} stage-3
|
|
|
|
samu ${cmdlineForSamu} -C stage-3
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
# tests are failing because they don't find Python
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
./stage-3/muon -C stage-3 test
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
stage-3/muon -C stage-3 install
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://muon.build/";
|
|
|
|
description = "An implementation of Meson build system in C99";
|
|
|
|
license = licenses.gpl3Only;
|
|
|
|
maintainers = with maintainers; [ AndersonTorres ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
broken = stdenv.isDarwin; # typical `ar failure`
|
|
|
|
};
|
|
|
|
})
|
|
|
|
# TODO LIST:
|
2022-10-21 18:38:19 +00:00
|
|
|
# 1. automate sources acquisition (especially wraps)
|
|
|
|
# 2. setup hook
|
|
|
|
# 3. tests
|