summary refs log tree commit diff
path: root/pkgs/tools/typesetting/asciidoc
diff options
context:
space:
mode:
authorRick van Schijndel <rol3517@gmail.com>2021-07-15 22:19:54 +0200
committerRick van Schijndel <rol3517@gmail.com>2021-07-16 07:58:56 +0200
commit2e36e8ad73cfcdbb759e52190f52fc02eff6af0d (patch)
treebec300f657d6537a90f9cdf827f81f80c76d496a /pkgs/tools/typesetting/asciidoc
parent2165de17580e16c20a12a70de6c075ed0e89f0a4 (diff)
downloadnixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar.gz
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar.bz2
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar.lz
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar.xz
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.tar.zst
nixpkgs-2e36e8ad73cfcdbb759e52190f52fc02eff6af0d.zip
asciidoc: support cross-compilation
Be explicit in patchShebangs by suggestion of SuperSandro2000.
Enable strictDeps to enforce better support in the future.
Diffstat (limited to 'pkgs/tools/typesetting/asciidoc')
-rw-r--r--pkgs/tools/typesetting/asciidoc/default.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix
index ce3b142fbc5..cc45455eeaf 100644
--- a/pkgs/tools/typesetting/asciidoc/default.nix
+++ b/pkgs/tools/typesetting/asciidoc/default.nix
@@ -40,6 +40,8 @@
 
 # java is problematic on some platforms, where it is unfree
 , enableJava ? true
+
+, buildPackages
 }:
 
 assert enableStandardFeatures ->
@@ -157,7 +159,9 @@ stdenv.mkDerivation rec {
     sha256 = "1clf1axkns23wfmh48xfspzsnw04pjh4mq1pshpzvj0cwxhz0yaq";
   };
 
+  strictDeps = true;
   nativeBuildInputs = [ python3 unzip autoreconfHook ];
+  buildInputs = [ python3 ];
 
   # install filters early, so their shebangs are patched too
   postPatch = with lib; ''
@@ -262,7 +266,20 @@ stdenv.mkDerivation rec {
         -e "s|^XMLLINT =.*|XMLLINT = '${libxml2.bin}/bin/xmllint'|" \
         -i a2x.py
   '') + ''
-    patchShebangs .
+    patchShebangs --host \
+      asciidoc.py \
+      a2x.py \
+      tests/testasciidoc.py \
+      filters/code/code-filter.py \
+      filters/latex/latex2img.py \
+      filters/music/music2png.py \
+      filters/unwraplatex.py \
+      filters/graphviz/graphviz2png.py
+
+    # Hardcode the path to its own asciidoc.
+    # This helps with cross-compilation.
+    substituteInPlace a2x.py \
+      --replace "find_executable(ASCIIDOC)" "'${placeholder "out"}/bin/asciidoc'"
 
     # Note: this substitution will not work in the planned 10.0.0 release:
     #
@@ -273,6 +290,10 @@ stdenv.mkDerivation rec {
     # --replace "python3 -m asciidoc.a2x" "python3 -m asciidoc.a2x -a revdate=01/01/1980"
     substituteInPlace Makefile.in \
       --replace "python3 a2x.py" "python3 a2x.py -a revdate=01/01/1980"
+  '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
+    # We want to use asciidoc from the build platform to build the documentation.
+    substituteInPlace Makefile.in \
+      --replace "python3 a2x.py" "python3 ${buildPackages.asciidoc}/bin/a2x.py"
   '';
 
   preInstall = "mkdir -p $out/etc/vim";