mirth: init at 0-unstable-2026-05-28
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromSourcehut,
|
||||
buildPackages,
|
||||
stdenv,
|
||||
makeBinaryWrapper,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "mirth";
|
||||
version = "0-unstable-2026-05-28";
|
||||
|
||||
src = fetchFromSourcehut {
|
||||
owner = "~typeswitch";
|
||||
repo = "mirth";
|
||||
rev = "b180112a547cb803e3bf5720a0bb08f8bffa9742";
|
||||
hash = "sha256-6nd1DrN3sGobmOh+E/8hYUFW2tBSFLdaEPXrViKDVSc=";
|
||||
};
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"lib"
|
||||
"bin"
|
||||
"doc"
|
||||
"examples"
|
||||
"vim"
|
||||
];
|
||||
|
||||
strictDeps = true;
|
||||
__structuredAttrs = true;
|
||||
|
||||
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
||||
|
||||
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||
|
||||
postPatch = ''
|
||||
# Replace hard-coded GCC with stdenv’s C compiler.
|
||||
# NOTE: newer GCC requires optimization level ≥1 to use fortity. -O1 is
|
||||
# fast enough as a default for the compiler stages.
|
||||
substituteInPlace Makefile \
|
||||
--replace-fail "-O0" "-O1" \
|
||||
--replace-fail "CC=gcc \$(C99FLAGS)" "CC=${buildPackages.stdenv.cc.targetPrefix}cc \$(C99FLAGS)"
|
||||
|
||||
# Override the final binary, mirth3, with the target’s C compiler & -O2
|
||||
# optimization for distribution.
|
||||
echo "bin/mirth3: CC := ${stdenv.cc.targetPrefix}cc \$(C99FLAGS) -O2" >>Makefile
|
||||
'';
|
||||
|
||||
buildFlags = [
|
||||
"bin/mirth2"
|
||||
"bin/mirth3"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -d "$lib/lib/mirth" "$doc/share/doc/mirth/tutorial" \
|
||||
"$examples/share/mirth/examples" "$vim/share/vim-plugins/mirth"
|
||||
|
||||
cp -Tr lib "$lib/lib/mirth"
|
||||
cp -Tr examples "$examples/share/mirth/examples"
|
||||
cp -Tr tutorial "$doc/share/doc/mirth/tutorial"
|
||||
cp -Tr tools/mirth-vim "$vim/share/vim-plugins/mirth"
|
||||
|
||||
bin/mirth2 src/main.mth --docs "$doc/share/doc/mirth" -c
|
||||
install -Dm644 LICENSE README.md -t "$doc/share/doc/mirth"
|
||||
|
||||
# stages 0–2 aren’t needed anymore
|
||||
install -Dm755 bin/mirth3 "$bin/bin/mirth"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# The raw binary @ $bin needs wrapping to get the stdlib @ $lib. By wrapping
|
||||
# it here, it will be more flexible towards allowing users to wrap the Mirth
|
||||
# binary with their own stdlib & other packages.
|
||||
postFixup = ''
|
||||
makeBinaryWrapper "$bin/bin/mirth" "$out/bin/mirth" \
|
||||
--add-flags "-P $lib/lib/mirth"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Concatenative functional programming language with strong static linear types";
|
||||
longDescription = ''
|
||||
Mirth is inspired by Forth, Joy, Haskell, Lisp, and monoidal category theory.
|
||||
Mirth compiles to C99.
|
||||
'';
|
||||
homepage = "https://git.sr.ht/~typeswitch/mirth";
|
||||
license = lib.licenses.bsd0;
|
||||
mainProgram = "mirth";
|
||||
# https://git.sr.ht/~typeswitch/mirth/tree/main/item/src/mirth.h#L4-22
|
||||
platforms = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-windows"
|
||||
"i686-linux"
|
||||
"i686-windows"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
"x86_64-windows"
|
||||
];
|
||||
maintainers = with lib.maintainers; [ toastal ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user