opentxl: init wrapper

This commit is contained in:
Adam Thompson-Sharpe
2026-04-09 15:53:24 -04:00
parent 1b769bd0d3
commit 6b57a9f2ff
2 changed files with 74 additions and 2 deletions
@@ -72,8 +72,11 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
passthru.tests.factorial = callPackage ./factorial-test.nix { opentxl = finalAttrs.finalPackage; };
passthru.updateScript = nix-update-script { };
passthru = {
inherit osOption;
tests.factorial = callPackage ./factorial-test.nix { opentxl = finalAttrs.finalPackage; };
updateScript = nix-update-script { };
};
meta = {
description = "Open-source compiler for the Txl language";
+69
View File
@@ -0,0 +1,69 @@
{
lib,
stdenv,
makeWrapper,
opentxl-unwrapped,
targetPackages,
}:
let
inherit (targetPackages.stdenv.cc) targetPrefix;
crossCompiling = stdenv.hostPlatform != stdenv.targetPlatform;
targetOpentxl = if !crossCompiling then opentxl-unwrapped else targetPackages.opentxl-unwrapped;
in
stdenv.mkDerivation (finalAttrs: {
pname = "${targetPrefix}opentxl-wrapper";
inherit (opentxl-unwrapped) version;
preferLocalBuild = true;
strictDeps = true;
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
# Wrap compiler
makeWrapper ${opentxl-unwrapped}/bin/txlc \
$out/bin/${targetPrefix}txlc \
--set TXLLIB ${opentxl-unwrapped}/lib \
--set BUILD_TXLLIB ${opentxl-unwrapped}/lib \
--set TARGET_TXLLIB ${targetOpentxl}/lib \
--set CC ${targetPackages.stdenv.cc}/bin/${targetPrefix}cc \
--set OS ${opentxl-unwrapped.osOption stdenv.targetPlatform}
${
# For convenience, if there is a target prefix, create a symlink named txlc
lib.optionalString (targetPrefix != "") ''
ln -s $out/bin/${targetPrefix}txlc $out/bin/txlc
''
}
# Wrap other scripts
for name in txl2c txlp; do
makeWrapper "${opentxl-unwrapped}/bin/$name" \
"$out/bin/$name" \
--set-default TXLLIB ${opentxl-unwrapped}/lib
done
# Link to binaries that don't need wrapping
for name in txl txldb; do
ln -s "${opentxl-unwrapped}/bin/$name" "$out/bin/$name"
done
runHook postInstall
'';
passthru = {
unwrapped = opentxl-unwrapped;
inherit (opentxl-unwrapped.passthru) tests;
};
meta = opentxl-unwrapped.meta // {
platforms = lib.platforms.unix;
};
})