opentxl: use generated code as src instead of repo (#501157)

This commit is contained in:
Sandro
2026-04-06 16:07:32 +00:00
committed by GitHub
+15 -24
View File
@@ -2,44 +2,38 @@
lib,
stdenv,
callPackage,
fetchFromGitHub,
fetchurl,
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=";
# The code generation part of the upstream build system relies on an x86-only binary,
# so the generated code is fetched from the GitHub release instead
src = fetchurl {
url = "https://github.com/CordyJ/OpenTxl/releases/download/v${finalAttrs.version}/OpenTxl-${finalAttrs.version}-csrc.tar.gz";
hash = "sha256-qIvxQqo1yCVJImjUvNNinzhoywVgaq9s0E+Ab+QStc0=";
};
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 FHS paths in various files
find . -type f -exec sed -i \
-e 's#/bin/mv#mv#g' \
-e 's#/bin/rm#rm#g' \
-e "s#/usr/local/bin#$out/bin#g" \
-e "s#/usr/local/lib/txl#$out/lib#g" \
{} +
# Replace hardcoded gcc references
substituteInPlace src/scripts/c/unix/{txlc,txl2c} \
substituteInPlace scripts/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"
@@ -64,10 +58,7 @@ stdenv.mkDerivation (finalAttrs: {
meta = {
description = "Open-source compiler for the Txl language";
mainProgram = "txl";
platforms = [
"x86_64-linux"
"x86_64-darwin"
];
platforms = lib.platforms.unix;
homepage = "https://github.com/CordyJ/OpenTxl";
downloadPage = "https://github.com/CordyJ/OpenTxl/releases";
changelog = "https://github.com/CordyJ/OpenTxl/releases/tag/v${finalAttrs.version}";