From ec9c385bf2c16f8027f3944843ded797ecbfec5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Sun, 14 Jun 2026 23:45:50 +0700 Subject: [PATCH 1/4] mirth: init at 0-unstable-2026-05-28 --- pkgs/by-name/mi/mirth/package.nix | 106 ++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 pkgs/by-name/mi/mirth/package.nix diff --git a/pkgs/by-name/mi/mirth/package.nix b/pkgs/by-name/mi/mirth/package.nix new file mode 100644 index 000000000000..759d556cd217 --- /dev/null +++ b/pkgs/by-name/mi/mirth/package.nix @@ -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 ]; + }; +} From ae48e54926c99897a562fa1096aba7c87b9aa83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Tue, 16 Jun 2026 22:59:26 +0700 Subject: [PATCH 2/4] mirth: patch up st_mode offset on aarch64-linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is out of my wheelhouse but mirrors the Darwin code. It’s either do this sort of ugly patch, or set a aarch64-linux to broken… Assisted-by: DeepSeek V4 Flash --- pkgs/by-name/mi/mirth/package.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/mi/mirth/package.nix b/pkgs/by-name/mi/mirth/package.nix index 759d556cd217..23036eac3194 100644 --- a/pkgs/by-name/mi/mirth/package.nix +++ b/pkgs/by-name/mi/mirth/package.nix @@ -34,6 +34,14 @@ stdenv.mkDerivation { nativeBuildInputs = [ makeBinaryWrapper ]; postPatch = '' + ${lib.optionalString (with stdenv.buildPlatform; isAarch64 && isLinux) /* sh */ '' + # Bug report: https://todo.sr.ht/~typeswitch/mirth/16 + substituteInPlace bin/mirth0.c \ + --replace-fail "WRAP_I63(24LL);" "WRAP_I63(16LL);" + substituteInPlace lib/std/world.mth \ + --replace-fail "Linux -> 24u," "Linux -> running-arch Arch.ARM64 = if(16u, 24u)," + ''} + # 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. @@ -51,7 +59,8 @@ stdenv.mkDerivation { "bin/mirth3" ]; - doCheck = true; + # st_mode substitution intentionally diverges from the pre-generated mirth0.c + doCheck = with stdenv.buildPlatform; !(isAarch64 && isLinux); installPhase = '' runHook preInstall From 0ab8999464e63ba44b322027d18ba96d7e9601d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Mon, 15 Jun 2026 15:39:30 +0700 Subject: [PATCH 3/4] vimPlugins.mirth: init at mirth.version --- .../vim/plugins/non-generated/mirth/default.nix | 15 +++++++++++++++ pkgs/by-name/mi/mirth/package.nix | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/editors/vim/plugins/non-generated/mirth/default.nix diff --git a/pkgs/applications/editors/vim/plugins/non-generated/mirth/default.nix b/pkgs/applications/editors/vim/plugins/non-generated/mirth/default.nix new file mode 100644 index 000000000000..3409d9f27312 --- /dev/null +++ b/pkgs/applications/editors/vim/plugins/non-generated/mirth/default.nix @@ -0,0 +1,15 @@ +{ vimUtils, mirth }: + +vimUtils.buildVimPlugin { + pname = "mirth"; + inherit (mirth) version; + src = mirth.vim; + meta = { + inherit (mirth.meta) + homepage + license + platforms + ; + description = "Syntax highlighting & filetype detection for the Mirth programming language"; + }; +} diff --git a/pkgs/by-name/mi/mirth/package.nix b/pkgs/by-name/mi/mirth/package.nix index 23036eac3194..a50de7b73adb 100644 --- a/pkgs/by-name/mi/mirth/package.nix +++ b/pkgs/by-name/mi/mirth/package.nix @@ -66,12 +66,12 @@ stdenv.mkDerivation { runHook preInstall install -d "$lib/lib/mirth" "$doc/share/doc/mirth/tutorial" \ - "$examples/share/mirth/examples" "$vim/share/vim-plugins/mirth" + "$examples/share/mirth/examples" "$vim" 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" + cp -Tr tools/mirth-vim "$vim" bin/mirth2 src/main.mth --docs "$doc/share/doc/mirth" -c install -Dm644 LICENSE README.md -t "$doc/share/doc/mirth" From 12b7e11d7b6447cad09bf72ee3b0d413d3553ba4 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 22 Jun 2026 15:22:01 +0000 Subject: [PATCH 4/4] mirth: minor cleanup --- pkgs/by-name/mi/mirth/package.nix | 43 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/pkgs/by-name/mi/mirth/package.nix b/pkgs/by-name/mi/mirth/package.nix index a50de7b73adb..ada6e8fada17 100644 --- a/pkgs/by-name/mi/mirth/package.nix +++ b/pkgs/by-name/mi/mirth/package.nix @@ -17,6 +17,28 @@ stdenv.mkDerivation { hash = "sha256-6nd1DrN3sGobmOh+E/8hYUFW2tBSFLdaEPXrViKDVSc="; }; + postPatch = + # Bug report: https://todo.sr.ht/~typeswitch/mirth/16 + lib.optionalString (with stdenv.buildPlatform; isAarch64 && isLinux) '' + substituteInPlace bin/mirth0.c \ + --replace-fail "WRAP_I63(24LL);" "WRAP_I63(16LL);" + substituteInPlace lib/std/world.mth \ + --replace-fail "Linux -> 24u," "Linux -> running-arch Arch.ARM64 = if(16u, 24u)," + '' + # 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 + ''; + outputs = [ "out" "lib" @@ -33,27 +55,6 @@ stdenv.mkDerivation { nativeBuildInputs = [ makeBinaryWrapper ]; - postPatch = '' - ${lib.optionalString (with stdenv.buildPlatform; isAarch64 && isLinux) /* sh */ '' - # Bug report: https://todo.sr.ht/~typeswitch/mirth/16 - substituteInPlace bin/mirth0.c \ - --replace-fail "WRAP_I63(24LL);" "WRAP_I63(16LL);" - substituteInPlace lib/std/world.mth \ - --replace-fail "Linux -> 24u," "Linux -> running-arch Arch.ARM64 = if(16u, 24u)," - ''} - - # 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"