From e2d64efdcbc0b5987d72bfa1e4524845a0f54aee Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:28:20 +0100 Subject: [PATCH] asymptote: do not build sty, docs if provided via texlive --- pkgs/tools/graphics/asymptote/default.nix | 71 ++++++++++++++++++----- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/pkgs/tools/graphics/asymptote/default.nix b/pkgs/tools/graphics/asymptote/default.nix index bb1fadc1143f..6c4727752698 100644 --- a/pkgs/tools/graphics/asymptote/default.nix +++ b/pkgs/tools/graphics/asymptote/default.nix @@ -4,21 +4,27 @@ , boehmgc, libGLU, libGL, mesa, ncurses, readline, gsl, libsigsegv , python3, qtbase, qtsvg, boost , zlib, perl, curl -, texliveSmall, texinfo +, texinfo +, texlive +, texliveSmall , darwin }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { version = "2.88"; pname = "asymptote"; outputs = [ "out" "man" "info" "doc" "tex" ]; src = fetchurl { - url = "mirror://sourceforge/asymptote/${version}/asymptote-${version}.src.tgz"; + url = "mirror://sourceforge/asymptote/${finalAttrs.version}/asymptote-${finalAttrs.version}.src.tgz"; hash = "sha256-DecadD+m7pORuH3Sdcs/5M3vUbN6rhSkFoNN0Soq9bs="; }; + # override with TeX Live containers to avoid building sty, docs from source + texContainer = null; + texdocContainer = null; + patches = [ (fetchpatch { # partial fix for macOS XDR/V3D support (LDFLAGS change seems like an unrelated bugfix) @@ -37,8 +43,8 @@ stdenv.mkDerivation rec { wrapQtAppsHook cmake pkg-config - (texliveSmall.withPackages (ps: with ps; [ epsf cm-super ps.texinfo media9 ocgx2 collection-latexextra ])) - ]; + ] ++ lib.optional (finalAttrs.texContainer == null || finalAttrs.texdocContainer == null) + (texliveSmall.withPackages (ps: with ps; [ epsf cm-super ps.texinfo media9 ocgx2 collection-latexextra ])); buildInputs = [ ghostscriptX imagemagick fftw eigen @@ -57,12 +63,25 @@ stdenv.mkDerivation rec { dontWrapQtApps = true; - # Do not build $tex/ls-R which will be generated by texlive.combine + # do not build $tex/ls-R which will be generated by texlive.withPackages + # do not build and install sty and docs, if provided by tex/texdoc texlive containers + # (this is an optimisation to make texliveMedium and texliveFull independent of texliveSmall) preConfigure = '' HOME=$TMP substituteInPlace Makefile.in \ - --replace-fail 'install: install-notexhash install-texhash' 'install: install-notexhash install-asy' - prependToVar configureFlags "--with-latex=$tex/tex/latex" "--with-context=$tex/tex/context/third" + --replace-fail ' install-texhash' ''' + if [[ -n $texContainer ]] ; then + sed -i Makefile.in -e '/(\(latex\|context\)dir)/d' + substituteInPlace Makefile.in \ + --replace-fail 'asy sty' 'asy' + else + prependToVar configureFlags "--with-latex=$tex/tex/latex" "--with-context=$tex/tex/context/third" + fi + if [[ -n $texdocContainer ]] ; then + substituteInPlace Makefile.in \ + --replace-fail ' install-man' ''' \ + --replace-fail 'docdir = $(DESTDIR)@docdir@' 'docdir = $(TMP)/doc' + fi ''; # do not use bundled libgc.so @@ -76,12 +95,36 @@ stdenv.mkDerivation rec { rm "$out"/bin/xasy makeQtWrapper "$out"/share/asymptote/GUI/xasy.py "$out"/bin/xasy --prefix PATH : "$out"/bin - mv "$info"/share/info/asymptote/*.info "$info"/share/info/ - sed -i -e 's|(asymptote/asymptote)|(asymptote)|' "$info"/share/info/asymptote.info - rmdir "$info"/share/info/asymptote - rm -f "$info"/share/info/dir + if [[ -z $texdocContainer ]] ; then + mv "$info"/share/info/asymptote/*.info "$info"/share/info/ + sed -i -e 's|(asymptote/asymptote)|(asymptote)|' "$info"/share/info/asymptote.info + rmdir "$info"/share/info/asymptote + rm -f "$info"/share/info/dir + fi + install -Dt $out/share/emacs/site-lisp/${finalAttrs.pname} $out/share/asymptote/*.el + ''; - install -Dt $out/share/emacs/site-lisp/${pname} $out/share/asymptote/*.el + # fixupPhase crashes if the outputs are not directories + preFixup = '' + if [[ -n $texContainer ]] ; then + mkdir -p "$tex" + fi + if [[ -n $texdocContainer ]] ; then + mkdir -p "$doc" "$man" "$info" + fi + ''; + + postFixup = '' + if [[ -n $texContainer ]] ; then + rmdir "$tex" + ln -s "$texContainer" "$tex" + fi + if [[ -n $texdocContainer ]] ; then + mkdir -p "$man/share" "$info/share" + ln -s "$texdocContainer" "$doc/share" + ln -s "$texdocContainer/doc/man" "$man/share" + ln -s "$texdocContainer/doc/info" "$info/share" + fi ''; dontUseCmakeConfigure = true; @@ -98,4 +141,4 @@ stdenv.mkDerivation rec { maintainers = [ maintainers.raskin ]; platforms = platforms.linux ++ platforms.darwin; }; -} +})