turingplus: init at 6.2.1, opentxl: init at 11.3.7 (#446211)
This commit is contained in:
@@ -18149,6 +18149,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";
|
||||
|
||||
@@ -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
|
||||
''
|
||||
@@ -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
|
||||
@@ -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 ];
|
||||
};
|
||||
})
|
||||
@@ -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 ];
|
||||
};
|
||||
})
|
||||
@@ -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 ];
|
||||
};
|
||||
})
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user