about summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2023-08-26 17:15:25 -0400
committerGitHub <noreply@github.com>2023-08-26 17:15:25 -0400
commit2e6b6acee9f4477ced494a5f88e430a5f8e98210 (patch)
tree7a87b0937114b2f007722404859f88bba41958cf /pkgs/tools/typesetting/tex/texlive
parent4e49e4928d44ce1ffc9a880ec035d1441a1b7650 (diff)
parent65923600fec7fa56ad428605f2af4dd4090de327 (diff)
downloadnixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar.gz
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar.bz2
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar.lz
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar.xz
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.tar.zst
nixlib-2e6b6acee9f4477ced494a5f88e430a5f8e98210.zip
Merge pull request #247323 from xworld21/texdoc-zsh-completion
texdoc: install zsh completion
Diffstat (limited to 'pkgs/tools/typesetting/tex/texlive')
-rw-r--r--pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix2
-rw-r--r--pkgs/tools/typesetting/tex/texlive/default.nix16
2 files changed, 17 insertions, 1 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix b/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix
index 1415d2d39f9f..2e9572f168a5 100644
--- a/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix
+++ b/pkgs/tools/typesetting/tex/texlive/build-texlive-package.nix
@@ -29,6 +29,7 @@
 , hasManpages ? false
 , hasRunfiles ? false
 , hasTlpkg ? false
+, extraNativeBuildInputs ? [ ]
 , ...
 }@args:
 
@@ -119,6 +120,7 @@ let
         inherit meta;
         # shebang interpreters
         buildInputs = (args.extraBuildInputs or [ ]) ++ [ bash perl ] ++ (lib.attrVals (args.scriptExts or [ ]) extToInput);
+        nativeBuildInputs = extraNativeBuildInputs;
         # absolute scripts folder
         scriptsFolder = lib.optionalString (run ? outPath) (run.outPath + "/scripts/" + args.scriptsFolder or pname);
         # binaries info
diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix
index b382dc258e8c..90a65ab1405e 100644
--- a/pkgs/tools/typesetting/tex/texlive/default.nix
+++ b/pkgs/tools/typesetting/tex/texlive/default.nix
@@ -4,7 +4,7 @@
 */
 { stdenv, lib, fetchurl, runCommand, writeText, buildEnv
 , callPackage, ghostscript_headless, harfbuzz
-, makeWrapper
+, makeWrapper, installShellFiles
 , python3, ruby, perl, tk, jdk, bash, snobol4
 , coreutils, findutils, gawk, getopt, gnugrep, gnumake, gnupg, gnused, gzip, ncurses, zip
 , libfaketime, asymptote, biber-ms, makeFontsConf
@@ -376,6 +376,8 @@ let
         extraRevision = "-tlpdb${toString tlpdbVersion.revision}";
         extraVersion = "-tlpdb-${toString tlpdbVersion.revision}";
 
+        extraNativeBuildInputs = [ installShellFiles ];
+
         # build Data.tlpdb.lua (part of the 'tlType == "run"' package)
         postUnpack = ''
           if [[ -f "$out"/scripts/texdoc/texdoc.tlu ]]; then
@@ -392,6 +394,18 @@ let
             cp texdoc/cache-tlpdb.lua "$out"/scripts/texdoc/Data.tlpdb.lua
           fi
         '';
+
+        # install zsh completion
+        postFixup = ''
+          TEXMFCNF="${bin.core}"/share/texmf-dist/web2c TEXMF="$scriptsFolder/../.." \
+            texlua "$out"/bin/texdoc --print-completion zsh > "$TMPDIR"/_texdoc
+          substituteInPlace "$TMPDIR"/_texdoc \
+            --replace 'compdef __texdoc texdoc' '#compdef texdoc' \
+            --replace '$(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb' '$(kpsewhich Data.tlpdb.lua)' \
+            --replace '/^name[^.]*$/ {print $2}' '/^  \["[^"]*"\] = {$/ { print substr($1,3,length($1)-4) }'
+          echo '__texdoc' >> "$TMPDIR"/_texdoc
+          installShellCompletion --zsh "$TMPDIR"/_texdoc
+        '';
       };
 
       "texlive.infra" = {