From b8384ad90d7443e34eb61341b7442395f05fa94e Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Wed, 24 Sep 2025 19:58:06 -0400 Subject: [PATCH 1/3] maintainers: add MysteryBlokHed --- maintainers/maintainer-list.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 413061ab2dfa..9b7dea1dc5d7 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -18138,6 +18138,13 @@ githubId = 9636071; name = "Myrl Hex"; }; + MysteryBlokHed = { + name = "Adam Thompson-Sharpe"; + email = "hi@adamts.me"; + github = "MysteryBlokHed"; + githubId = 13910387; + keys = [ { fingerprint = "086E EF20 D54E D348 E5BA 6263 16E9 43E6 596F FB4E"; } ]; + }; myypo = { email = "nikirsmcgl@gmail.com"; github = "myypo"; From 44a381cc22f0c8f8ffa0e287e13f980e1969417e Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Thu, 25 Sep 2025 18:38:26 -0400 Subject: [PATCH 2/3] turingplus: init at 6.2.1 --- pkgs/by-name/tu/turingplus/bootstrap.nix | 93 ++++++++++++++++++++++ pkgs/by-name/tu/turingplus/package.nix | 75 +++++++++++++++++ pkgs/by-name/tu/turingplus/use-gnu89.patch | 13 +++ 3 files changed, 181 insertions(+) create mode 100644 pkgs/by-name/tu/turingplus/bootstrap.nix create mode 100644 pkgs/by-name/tu/turingplus/package.nix create mode 100644 pkgs/by-name/tu/turingplus/use-gnu89.patch diff --git a/pkgs/by-name/tu/turingplus/bootstrap.nix b/pkgs/by-name/tu/turingplus/bootstrap.nix new file mode 100644 index 000000000000..074b6d52c7d7 --- /dev/null +++ b/pkgs/by-name/tu/turingplus/bootstrap.nix @@ -0,0 +1,93 @@ +{ + lib, + stdenv, + fetchzip, + autoPatchelfHook, + makeWrapper, + coreutils, + libredirect, +}: +let + sources = { + "x86_64-linux" = { + url = "https://github.com/CordyJ/Open-TuringPlus/releases/download/v6.2.1/opentplus-62-linux64.tar.gz"; + sha256 = "sha256-FoOlOcRWpStg4aerjr+FmcXXnwYftrqG1j4iZJ+4AzE="; + }; + "x86_64-darwin" = { + url = "https://github.com/CordyJ/Open-TuringPlus/releases/download/v6.2.1/opentplus-62-macos64.tar.gz"; + sha256 = "sha256-8o1hIA74JPqZyjWfg4leC99z1+YMVhwFGME5qBf/BP0="; + }; + }; + + redirects = [ + # Turing+ library/includes + "/usr/local/lib/tplus=${placeholder "out"}/lib" + "/local/lib/tplus=${placeholder "out"}/lib" + "/usr/local/include/tplus=${placeholder "out"}/include" + "/local/include/tplus=${placeholder "out"}/include" + # Turing+ binaries + "/usr/local/bin=${placeholder "out"}/bin" + # Other + "/bin/rm=${coreutils}/bin/rm" + ]; +in +stdenv.mkDerivation (finalAttrs: { + pname = "turingplus-bootstrap"; + version = "6.2.1"; + + src = fetchzip sources."${stdenv.hostPlatform.system}"; + + nativeBuildInputs = [ + makeWrapper + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + autoPatchelfHook + ]; + buildInputs = [ stdenv.cc.cc.lib ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib,include} + cp bin/* $out/bin/ + cp lib/* $out/lib/ + cp -r include/* $out/include/ + + runHook postInstall + ''; + + # Wrap package and redirect FHS reads to the derivation output + postInstall = + let + preloadVar = if stdenv.hostPlatform.isDarwin then "DYLD_INSERT_LIBRARIES" else "LD_PRELOAD"; + preloadLib = "${libredirect}/lib/libredirect" + stdenv.hostPlatform.extensions.sharedLibrary; + in + '' + wrapProgram $out/bin/tpc \ + --set ${preloadVar} ${preloadLib} \ + --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects} \ + --set NIX_ENFORCE_PURITY 0 + + wrapProgram $out/bin/tssl \ + --set ${preloadVar} ${preloadLib} \ + --set NIX_REDIRECTS ${builtins.concatStringsSep ":" redirects} \ + --set NIX_ENFORCE_PURITY 0 + ''; + + meta = with lib; { + description = "Extended version of the Turing programming language with concurrency and systems programming features"; + mainProgram = "tpc"; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + homepage = "https://github.com/CordyJ/Open-TuringPlus"; + downloadPage = "https://github.com/CordyJ/Open-TuringPlus/releases"; + changelog = "https://github.com/CordyJ/Open-TuringPlus/releases/tag/v${finalAttrs.version}"; + license = licenses.mit; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + maintainers = with maintainers; [ MysteryBlokHed ]; + }; +}) diff --git a/pkgs/by-name/tu/turingplus/package.nix b/pkgs/by-name/tu/turingplus/package.nix new file mode 100644 index 000000000000..10cad49005a7 --- /dev/null +++ b/pkgs/by-name/tu/turingplus/package.nix @@ -0,0 +1,75 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + bootstrap ? callPackage ./bootstrap.nix { }, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "turingplus"; + version = "6.2.1"; + + src = fetchFromGitHub { + owner = "CordyJ"; + repo = "Open-TuringPlus"; + tag = "v${finalAttrs.version}"; + hash = "sha256-jiMbSuNg2o9fNCPNoLpyAdMCxgMVBiDjRhC0HgKwmqk="; + }; + + nativeBuildInputs = [ bootstrap ]; + + # Using -std=gnu89 to prevent errors that occur with default args + env.NIX_CFLAGS_COMPILE = "-std=gnu89 -Wno-int-conversion"; + + # Patch required to fix compilation errors when certain C input files are used with tpc + patches = [ ./use-gnu89.patch ]; + + postPatch = '' + # Replace hardcoded paths in source + find src -type f -exec sed -i \ + -e "s#/usr/local/lib/tplus#$out/lib#g" \ + -e "s#/local/lib/tplus#$out/lib#g" \ + -e "s#/usr/local/include/tplus#$out/include#g" \ + -e "s#/local/include/tplus#$out/include#g" \ + -e "s#/usr/local/bin#$out/bin#g" \ + -e "s#/bin/rm#rm#g" \ + {} + + + # Use proper C compiler for target + substituteInPlace src/cmd/lib/* \ + --replace-fail 'cc ' '${stdenv.cc}/bin/cc ' + ''; + + buildFlags = [ + "INCLUDE_DIR=${bootstrap}/include" + "TPC=${bootstrap}/bin/tpc" + ]; + + checkFlags = [ "-C test" ]; + checkTarget = "all"; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib,include} + cp bin/* $out/bin/ + cp lib/* $out/lib/ + cp -r include/* $out/include/ + + runHook postInstall + ''; + + meta = with lib; { + description = "Extended version of the Turing programming language with concurrency and systems programming features"; + mainProgram = "tpc"; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + homepage = "https://github.com/CordyJ/Open-TuringPlus"; + downloadPage = "https://github.com/CordyJ/Open-TuringPlus/releases"; + changelog = "https://github.com/CordyJ/Open-TuringPlus/releases/tag/v${finalAttrs.version}"; + license = licenses.mit; + maintainers = with maintainers; [ MysteryBlokHed ]; + }; +}) diff --git a/pkgs/by-name/tu/turingplus/use-gnu89.patch b/pkgs/by-name/tu/turingplus/use-gnu89.patch new file mode 100644 index 000000000000..1c053269d97f --- /dev/null +++ b/pkgs/by-name/tu/turingplus/use-gnu89.patch @@ -0,0 +1,13 @@ +--- a/src/cmd/tpc.t ++++ b/src/cmd/tpc.t +@@ -1342,6 +1342,10 @@ procedure CompileC (cFileName : string, var s : string, var status : int) + i += 1 + end if + ++ % Use C standard that allows C++-style comments ++ tArgs(i) := "-std=gnu89" ++ i += 1 ++ + % ignore warnings from C compiler + tArgs(i) := "-w" + i += 1 From b4bd28b16031036eecfffbff61c886e6e0beb1a0 Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Thu, 25 Sep 2025 19:32:27 -0400 Subject: [PATCH 3/3] opentxl: init at 11.3.7 --- pkgs/by-name/op/opentxl/factorial-test.nix | 17 +++++ pkgs/by-name/op/opentxl/factorial.txl | 34 ++++++++++ pkgs/by-name/op/opentxl/package.nix | 77 ++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 pkgs/by-name/op/opentxl/factorial-test.nix create mode 100644 pkgs/by-name/op/opentxl/factorial.txl create mode 100644 pkgs/by-name/op/opentxl/package.nix diff --git a/pkgs/by-name/op/opentxl/factorial-test.nix b/pkgs/by-name/op/opentxl/factorial-test.nix new file mode 100644 index 000000000000..38978a720bf2 --- /dev/null +++ b/pkgs/by-name/op/opentxl/factorial-test.nix @@ -0,0 +1,17 @@ +{ + lib, + runCommandNoCC, + opentxl, +}: +runCommandNoCC "opentxl-test" + { + nativeBuildInputs = [ opentxl ]; + src = lib.sources.sourceByRegex ./. [ + ".*.txl" + ]; + } + '' + printf '10' > factorial.in + result=$(txl factorial.in $src/factorial.txl) + [[ "$result" -eq '3628800' ]] && touch $out + '' diff --git a/pkgs/by-name/op/opentxl/factorial.txl b/pkgs/by-name/op/opentxl/factorial.txl new file mode 100644 index 000000000000..f1eb406a6620 --- /dev/null +++ b/pkgs/by-name/op/opentxl/factorial.txl @@ -0,0 +1,34 @@ +% From: https://en.wikipedia.org/wiki/TXL_(programming_language) + +%Syntax specification +define program + [number] +end define + +%Transformation rules +function main + replace [program] + p [number] + by + p [fact][fact0] +end function + +function fact + replace [number] + n [number] + construct nMinusOne [number] + n [- 1] + where + n [> 1] + construct factMinusOne [number] + nMinusOne [fact] + by + n [* factMinusOne] +end function + +function fact0 + replace [number] + 0 + by + 1 +end function diff --git a/pkgs/by-name/op/opentxl/package.nix b/pkgs/by-name/op/opentxl/package.nix new file mode 100644 index 000000000000..277be7f19c99 --- /dev/null +++ b/pkgs/by-name/op/opentxl/package.nix @@ -0,0 +1,77 @@ +{ + lib, + stdenv, + callPackage, + fetchFromGitHub, + nix-update-script, + turingplus, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "opentxl"; + version = "11.3.7"; + + src = fetchFromGitHub { + owner = "CordyJ"; + repo = "OpenTxl"; + tag = "v${finalAttrs.version}"; + hash = "sha256-Gh0OEZ5pGhbxDIKYuBLdzUV7Ezn+7elm146ccpJ5bn8="; + }; + + nativeBuildInputs = [ turingplus ]; + + # Using -std=gnu89 to prevent errors that occur with default args + env.NIX_CFLAGS_COMPILE = "-std=gnu89 -Wno-int-conversion"; + + postPatch = '' + # Replace hardcoded /bin/rm in various files + find . -type f -exec sed -i 's#/bin/rm#rm#g' {} + + + # Replace hardcoded gcc references + substituteInPlace src/scripts/c/unix/{txlc,txl2c} \ + --replace-fail gcc '${stdenv.cc}/bin/cc' + + # Replace hardcoded FHS paths + substituteInPlace src/scripts/c/unix/* src/scripts/t/* \ + --replace-fail '/usr/local/bin' "$out/bin" \ + --replace-fail '/usr/local/lib/txl' "$out/lib" + ''; + + # Generate source files and enter directory + preBuild = '' + make csrc + cd csrc + makeFlagsArray+=( + CC="$CC" + LD="$CC" + ) + ''; + + checkFlags = [ "-C test" ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,lib} + cp bin/* $out/bin/ + cp lib/* $out/lib/ + + runHook postInstall + ''; + + passthru.tests.factorial = callPackage ./factorial-test.nix { opentxl = finalAttrs.finalPackage; }; + passthru.updateScript = nix-update-script { }; + + meta = with lib; { + description = "Open-source compiler for the Txl language"; + mainProgram = "txl"; + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + homepage = "https://github.com/CordyJ/OpenTxl"; + downloadPage = "https://github.com/CordyJ/OpenTxl/releases"; + changelog = "https://github.com/CordyJ/OpenTxl/releases/tag/v${finalAttrs.version}"; + license = licenses.mit; + maintainers = with maintainers; [ MysteryBlokHed ]; + }; +})