diff --git a/pkgs/by-name/op/opentxl/package.nix b/pkgs/by-name/op/opentxl/package.nix index 790eae5a7d23..ae5d1c644e84 100644 --- a/pkgs/by-name/op/opentxl/package.nix +++ b/pkgs/by-name/op/opentxl/package.nix @@ -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}";