Merge new texlive infrastructure, /CC #287

This commit is contained in:
Vladimír Čunát 2015-09-18 20:43:06 +02:00
commit 0fdb93864e
19 changed files with 30651 additions and 97 deletions

View File

@ -142,10 +142,11 @@ while (scalar(keys %postponed) > 0) {
# Create the symlinks. # Create the symlinks.
my $extraPrefix = $ENV{"extraPrefix"};
my $nrLinks = 0; my $nrLinks = 0;
foreach my $relName (sort keys %symlinks) { foreach my $relName (sort keys %symlinks) {
my ($target, $priority) = @{$symlinks{$relName}}; my ($target, $priority) = @{$symlinks{$relName}};
my $abs = "$out/$relName"; my $abs = "$out" . "$extraPrefix" . "/$relName";
next unless isInPathsToLink $relName; next unless isInPathsToLink $relName;
if ($target eq "") { if ($target eq "") {
#print "creating directory $relName\n"; #print "creating directory $relName\n";

View File

@ -21,14 +21,20 @@
# directories in the list is not symlinked. # directories in the list is not symlinked.
pathsToLink ? ["/"] pathsToLink ? ["/"]
, # Shell command to run after building the symlink tree. , # Root the result in directory "$out${extraPrefix}", e.g. "/share".
extraPrefix ? ""
, # Shell commands to run after building the symlink tree.
postBuild ? "" postBuild ? ""
, # Additional inputs. Handy e.g. if using makeWrapper in `postBuild`.
buildInputs ? []
, passthru ? {} , passthru ? {}
}: }:
runCommand name runCommand name
{ inherit manifest ignoreCollisions passthru pathsToLink postBuild; { inherit manifest ignoreCollisions passthru pathsToLink extraPrefix postBuild buildInputs;
pkgs = builtins.toJSON (map (drv: { pkgs = builtins.toJSON (map (drv: {
paths = [ drv ]; # FIXME: handle multiple outputs paths = [ drv ]; # FIXME: handle multiple outputs
priority = drv.meta.priority or 5; priority = drv.meta.priority or 5;

View File

@ -6,7 +6,7 @@ let
mpfr m4 binutils emacs gmp mpfr m4 binutils emacs gmp
libX11 xproto inputproto libXi libX11 xproto inputproto libXi
libXext xextproto libXt libXaw libXmu libXext xextproto libXt libXaw libXmu
zlib which texinfo texLive zlib which texinfo
]; ];
in in

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, fetchpatch, pkgconfig, libiconv, libintlOrEmpty { stdenv, lib, fetchurl, fetchpatch, pkgconfig, libiconv, libintlOrEmpty
, zlib, curl, cairo, freetype, fontconfig, lcms, libjpeg, openjpeg , zlib, curl, cairo, freetype, fontconfig, lcms, libjpeg, openjpeg
, qt4Support ? false, qt4 ? null, qt5Support ? false, qt5 ? null , minimal ? false, qt4Support ? false, qt4 ? null, qt5Support ? false, qt5 ? null
, utils ? false, suffix ? "glib" , utils ? false, suffix ? "glib"
}: }:
@ -16,28 +16,31 @@ stdenv.mkDerivation rec {
inherit sha256; inherit sha256;
}; };
outputs = [ "out" "doc" ]; outputs = [ "out" ] ++ lib.optional (!minimal) "doc";
patches = [ ./datadir_env.patch ]; patches = [ ./datadir_env.patch ];
propagatedBuildInputs = with stdenv.lib; # TODO: reduce propagation to necessary libs
[ zlib cairo freetype fontconfig libjpeg lcms curl openjpeg ] propagatedBuildInputs = with lib;
[ zlib freetype fontconfig libjpeg lcms curl openjpeg ]
++ optional (!minimal) cairo
++ optional qt4Support qt4 ++ optional qt4Support qt4
++ optional qt5Support qt5.base; ++ optional qt5Support qt5.base;
nativeBuildInputs = [ pkgconfig libiconv ] ++ libintlOrEmpty; nativeBuildInputs = [ pkgconfig libiconv ] ++ libintlOrEmpty;
configureFlags = configureFlags = with lib;
[ [
"--enable-xpdf-headers" "--enable-xpdf-headers"
"--enable-libcurl" "--enable-libcurl"
"--enable-zlib" "--enable-zlib"
] ]
++ stdenv.lib.optional (!utils) "--disable-utils"; ++ optionals minimal [ "--disable-poppler-glib" "--disable-poppler-cpp" ]
++ optional (!utils) "--disable-utils";
enableParallelBuilding = true; enableParallelBuilding = true;
meta = { meta = with lib; {
homepage = http://poppler.freedesktop.org/; homepage = http://poppler.freedesktop.org/;
description = "A PDF rendering library"; description = "A PDF rendering library";
@ -45,8 +48,8 @@ stdenv.mkDerivation rec {
Poppler is a PDF rendering library based on the xpdf-3.0 code base. Poppler is a PDF rendering library based on the xpdf-3.0 code base.
''; '';
license = stdenv.lib.licenses.gpl2; license = licenses.gpl2;
platforms = stdenv.lib.platforms.all; platforms = platforms.all;
maintainers = with stdenv.lib.maintainers; [ ttuegel ]; maintainers = with maintainers; [ ttuegel ];
}; };
} }

View File

@ -20,6 +20,8 @@ stdenv.mkDerivation rec {
homepage = "http://www.latex2html.org/"; homepage = "http://www.latex2html.org/";
description = "Converter written in Perl that converts LaTeX documents to HTML"; description = "Converter written in Perl that converts LaTeX documents to HTML";
license = stdenv.lib.licenses.gpl2Plus; license = stdenv.lib.licenses.gpl2Plus;
broken = true;
}; };
} }

View File

@ -1,13 +0,0 @@
source $stdenv/setup
buildPhase=true
installPhase=myInstallPhase
myInstallPhase() {
mkdir -p "$out/share/texmf-nix/tex/latex/lazylist"
cp lazylist.sty "$out/share/texmf-nix/tex/latex/lazylist"
}
genericBuild

View File

@ -1,15 +0,0 @@
{stdenv, fetchurl, tetex}:
stdenv.mkDerivation {
name = "lazylist-1.0a";
builder = ./builder.sh;
src = fetchurl {
url = http://www.iai.uni-bonn.de/~loeh/lhs2tex/lazylist-1.0a.tar.bz2;
md5 = "8ef357df5845bd8d6075fca6e1f214ab";
};
buildInputs = [tetex];
inherit tetex;
}

View File

@ -1,18 +0,0 @@
source $stdenv/setup
buildPhase=true
installPhase=myInstallPhase
myInstallPhase() {
mkdir -p "$out/share/texmf-nix/tex/latex/polytable"
mkdir -p "$out/share/texmf-nix/doc/latex/polytable"
latex polytable.ins
pdflatex polytable.dtx
pdflatex polytable.dtx
cp polytable.sty "$out/share/texmf-nix/tex/latex/polytable"
cp polytable.pdf "$out/share/texmf-nix/doc/latex/polytable"
mkdir -p "$out/nix-support"
echo "$propagatedUserEnvPackages" > "$out/nix-support/propagated-user-env-packages"
}
genericBuild

View File

@ -1,19 +0,0 @@
{stdenv, fetchurl, tetex, lazylist}:
#assert tetex == lazylist.tetex;
stdenv.mkDerivation {
name = "polytable-0.8.2";
builder = ./builder.sh;
src = fetchurl {
url = http://www.iai.uni-bonn.de/~loeh/polytable-0.8.2.tar.gz;
md5 = "c59edf035ae6e19b64b1ae920fea28e7";
};
buildInputs = [tetex];
propagatedBuildInputs = [lazylist];
propagatedUserEnvPackages = [lazylist];
inherit tetex;
}

View File

@ -0,0 +1,225 @@
{ stdenv, lib, fetchurl
, config
, zlib, bzip2, ncurses, libpng, flex, bison, libX11, libICE, xproto
, freetype, t1lib, gd, libXaw, icu, ghostscript, ed, libXt, libXpm, libXmu, libXext
, xextproto, perl, libSM, ruby, expat, curl, libjpeg, python, fontconfig, pkgconfig
, poppler, libpaper, graphite2, lesstif, zziplib, harfbuzz, texinfo, potrace, gmp, mpfr
, xpdf, cairo, pixman, xorg
, makeWrapper
}:
let
withSystemLibs = map (libname: "--with-system-${libname}");
year = "2015";
version = year; # keep names simple for now
common = rec {
src = fetchurl {
url = "ftp://tug.org/historic/systems/texlive/${year}/texlive-20150521-source.tar.xz";
sha256 = "ed9bcd7bdce899c3c27c16a8c5c3017c4f09e1d7fd097038351b72497e9d4669";
};
configureFlags = [
"--with-banner-add=/NixOS.org"
"--disable-missing" "--disable-native-texlive-build"
"--enable-shared" # "--enable-cxx-runtime-hack" # static runtime
"--enable-tex-synctex"
"-C" # use configure cache to speed up
]
++ withSystemLibs [
# see "from TL tree" vs. "Using installed" in configure output
"zziplib" "xpdf" "poppler" "mpfr" "gmp"
"pixman" "potrace" "gd" "freetype2" "libpng" "libpaper" "zlib"
# beware: xpdf means to use stuff from poppler :-/
];
# clean broken links to stuff not built
cleanBrokenLinks = ''
for f in "$out"/bin/*; do
if [[ ! -x "$f" ]]; then rm "$f"; fi
done
'';
};
in rec { # un-indented
inherit (common) cleanBrokenLinks;
texliveYear = year;
core = stdenv.mkDerivation rec {
name = "texlive-bin-${version}";
inherit (common) src;
outputs = [ "out" "doc" ];
buildInputs = [
pkgconfig
/*teckit*/ zziplib poppler mpfr gmp
pixman potrace gd freetype libpng libpaper zlib
perl
];
preConfigure = ''
rm -r libs/{cairo,freetype2,gd,gmp,graphite2,harfbuzz,icu,libpaper,libpng} \
libs/{mpfr,pixman,poppler,potrace,xpdf,zlib,zziplib}
mkdir Work
cd Work
'';
configureScript = "../configure";
configureFlags = common.configureFlags
++ [ "--without-x" ] # disable xdvik and xpdfopen
++ map (what: "--disable-${what}") [
"dvisvgm" "dvipng" # ghostscript dependency
"luatex" "luajittex" "mp" "pmp" "upmp" "mf" # cairo would bring in X and more
"xetex" "bibtexu" "bibtex8" "bibtex-x" # ICU isn't small
]
++ [ "--without-system-harfbuzz" "--without-system-icu" ] # bogus configure
;
enableParallelBuilding = true;
doCheck = false; # triptest fails, likely due to missing TEXMF tree
preCheck = "patchShebangs ../texk/web2c";
installTargets = [ "install" "texlinks" ];
# TODO: perhaps improve texmf.cnf search locations
postInstall = /* a few texmf-dist files are useful; take the rest from pkgs */ ''
mv "$out/share/texmf-dist/web2c/texmf.cnf" .
rm -r "$out/share/texmf-dist"
mkdir -p "$out"/share/texmf-dist/{web2c,scripts/texlive/TeXLive}
mv ./texmf.cnf "$out/share/texmf-dist/web2c/"
cp ../texk/tests/TeXLive/*.pm "$out/share/texmf-dist/scripts/texlive/TeXLive/"
cp ../texk/texlive/linked_scripts/scripts.lst "$out/share/texmf-dist/scripts/texlive/"
'' + /* doc location identical with individual TeX pkgs */ ''
mkdir -p "$doc/doc"
mv "$out"/share/{man,info} "$doc"/doc
'' + cleanBrokenLinks;
setupHook = ./setup-hook.sh; # TODO: maybe texmf-nix -> texmf (and all references)
passthru = { inherit version buildInputs; };
meta = with stdenv.lib; {
description = "Basic binaries for TeX Live";
homepage = http://www.tug.org/texlive;
license = stdenv.lib.licenses.gpl2;
maintainers = with maintainers; [ vcunat lovek323 raskin jwiegley ];
platforms = platforms.all;
};
};
inherit (core-big) metafont metapost luatex xetex;
core-big = stdenv.mkDerivation {
name = "texlive-core-big.bin-${version}";
inherit (common) src;
buildInputs = core.buildInputs ++ [ core cairo harfbuzz icu graphite2 ];
configureFlags = common.configureFlags
++ withSystemLibs [ "kpathsea" "ptexenc" "cairo" "harfbuzz" "icu" "graphite2" ]
++ map (prog: "--disable-${prog}") # don't build things we already have
[ "tex" "ptex" "eptex" "uptex" "euptex" "aleph" "pdftex"
"web-progs" "synctex" "luajittex" # luajittex is mostly not needed, see:
# http://tex.stackexchange.com/questions/97999/when-to-use-luajittex-in-favour-of-luatex
];
configureScript = ":";
# we use static libtexlua, because it's only used by a single binary
postConfigure = ''
mkdir ./Work && cd ./Work
for path in libs/{teckit,lua52} texk/web2c; do
(
if [[ "$path" == "libs/lua52" ]]; then
extraConfig="--enable-static --disable-shared"
else
extraConfig=""
fi
mkdir -p "$path" && cd "$path"
"../../../$path/configure" $configureFlags $extraConfig
)
done
'';
preBuild = "cd texk/web2c";
enableParallelBuilding = true;
# now distribute stuff into outputs, roughly as upstream TL
# (uninteresting stuff remains in $out, typically duplicates from `core`)
outputs = [ "out" "metafont" "metapost" "luatex" "xetex" ];
postInstall = ''
for output in $outputs; do
mkdir -p "''${!output}/bin"
done
mv "$out/bin"/{inimf,mf,mf-nowin} "$metafont/bin/"
mv "$out/bin"/{*tomp,mfplain,*mpost} "$metapost/bin/"
mv "$out/bin"/{luatex,texlua*} "$luatex/bin/"
mv "$out/bin"/xetex "$xetex/bin/"
'';
};
dvisvgm = stdenv.mkDerivation {
name = "texlive-dvisvgm.bin-${version}";
inherit (common) src;
buildInputs = [ pkgconfig core/*kpathsea*/ ghostscript zlib freetype potrace ];
preConfigure = "cd texk/dvisvgm";
configureFlags = common.configureFlags
++ [ "--with-system-kpathsea" "--with-system-libgs" ];
enableParallelBuilding = true;
};
dvipng = stdenv.mkDerivation {
name = "texlive-dvipng.bin-${version}";
inherit (common) src;
buildInputs = [ pkgconfig core/*kpathsea*/ zlib libpng freetype gd ghostscript makeWrapper ];
preConfigure = "cd texk/dvipng";
configureFlags = common.configureFlags
++ [ "--with-system-kpathsea" "--with-gs=yes" "--disable-debug" ];
enableParallelBuilding = true;
# I didn't manage to hardcode gs location by configureFlags
postInstall = ''
wrapProgram "$out/bin/dvipng" --prefix PATH : '${ghostscript}/bin'
'';
};
bibtexu = bibtex8;
bibtex8 = stdenv.mkDerivation {
name = "texlive-bibtex-x.bin-${version}";
inherit (common) src;
buildInputs = [ pkgconfig core/*kpathsea*/ icu ];
preConfigure = "cd texk/bibtex-x";
configureFlags = common.configureFlags
++ [ "--with-system-kpathsea" "--with-system-icu" ];
enableParallelBuilding = true;
};
} # un-indented

View File

@ -0,0 +1,199 @@
params: with params;
# combine =
args@{
pkgFilter ? (pkg: pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "core")
, extraName ? "combined", ...
}:
let
pkgSet = removeAttrs args [ "pkgFilter" "extraName" ] // {
# include a fake "core" package
core.pkgs = [
(bin.core.out // { pname = "core"; tlType = "bin"; })
(bin.core.doc // { pname = "core"; tlType = "doc"; })
];
};
pkgList = rec {
all = lib.filter pkgFilter (combinePkgs pkgSet);
splitBin = lib.partition (p: p.tlType == "bin") all;
bin = mkUniquePkgs splitBin.right;
nonbin = mkUniquePkgs splitBin.wrong;
# extra interpreters needed for shebangs, based on 2015 schemes "medium" and "tetex"
# (omitted tk needed in pname == "epspdf", bin/epspdftk)
pkgNeedsPython = pkg: pkg.tlType == "run" && lib.elem pkg.pname
[ "de-macro" "pythontex" "dviasm" "texliveonfly" ];
pkgNeedsRuby = pkg: pkg.tlType == "run" && pkg.pname == "match-parens";
extraInputs =
lib.optional (lib.any pkgNeedsPython splitBin.wrong) python
++ lib.optional (lib.any pkgNeedsPython splitBin.wrong) ruby;
};
mkUniquePkgs = pkgs: fastUnique (a: b: a < b)
# here we deal with those dummy packages needed for hyphenation filtering
(map (p: if lib.isDerivation p then builtins.toPath p else "") pkgs);
in buildEnv {
name = "texlive-${extraName}-${bin.texliveYear}";
extraPrefix = "/share/texmf";
ignoreCollisions = false;
paths = pkgList.nonbin;
buildInputs = [ makeWrapper ] ++ pkgList.extraInputs;
postBuild = ''
cd "$out"
mkdir -p ./bin
'' +
lib.concatMapStrings
(path: ''
for f in '${path}'/bin/*; do
if [[ -L "$f" ]]; then
cp -d "$f" ./bin/
else
ln -s "$f" ./bin/
fi
done
'')
pkgList.bin
+
''
export PATH="$out/bin:$out/share/texmf/scripts/texlive:${perl}/bin:$PATH"
export TEXMFCNF="$out/share/texmf/web2c"
export TEXMFDIST="$out/share/texmf"
export TEXMFSYSCONFIG="$out/share/texmf-config"
export TEXMFSYSVAR="$out/share/texmf-var"
export PERL5LIB="$out/share/texmf/scripts/texlive"
'' +
# patch texmf-dist -> texmf to be sure
# TODO: cleanup the search paths incl. SELFAUTOLOC, and perhaps do lua actions?
# tried inspiration from install-tl, sub do_texmf_cnf
''
(
cd ./share/texmf/web2c/
local cnfOrig="$(realpath ./texmf.cnf)"
rm ./texmf.cnf
cat "$cnfOrig" | sed 's/texmf-dist/texmf/g' > ./texmf.cnf
rm updmap.cfg
)
'' +
# updmap.cfg seems like not needing changes
# now filter hyphenation patterns, in a hacky way ATM
''
(
local script='${
lib.concatMapStrings (pkg: "/^\% from ${pkg.pname}/,/^\%/p;\n")
pkgList.splitBin.wrong
} 1,/^\% from/p;'
cd ./share/texmf/tex/generic/config/
for fname in language.dat language.def; do
[ -e $fname ] || continue;
cnfOrig="$(realpath ./$fname)"
rm ./$fname
cat "$cnfOrig" | sed -n "$script" > ./$fname
done
)
'' +
# function to wrap created executables with required env vars
''
wrapBin() {
for link in ./bin/*; do
[ -L "$link" -a -x "$link" ] || continue # if not link, assume OK
local target=$(readlink "$link")
# skip simple local symlinks; mktexfmt in particular
echo "$target" | grep / > /dev/null || continue;
echo -n "Wrapping '$link'"
rm "$link"
makeWrapper "$target" "$link" \
--prefix PATH : "$out/bin:${perl}/bin" \
--set TEXMFCNF "$out/share/texmf/web2c" \
--set TEXMFDIST "$out/share/texmf" \
--set TEXMFSYSCONFIG "$out/share/texmf-config" \
--set TEXMFSYSVAR "$out/share/texmf-var" \
--prefix PERL5LIB : "$out/share/texmf/scripts/texlive"
# avoid using non-nix shebang in $target by calling interpreter
if [[ "$(head -c 2 $target)" = "#!" ]]; then
local cmdline="$(head -n 1 $target | sed 's/^\#\! *//;s/ *$//')"
local relative=`basename "$cmdline" | sed 's/^env //' `
local newInterp=`echo "$relative" | cut -d\ -f1`
local params=`echo "$relative" | cut -d\ -f2- -s`
local newPath="$(type -P $newInterp)"
if [[ -z "$newPath" ]]; then
echo " Warning: unknown shebang '$cmdline' in '$target'"
continue
fi
echo " and patching shebang '$cmdline'"
sed "s|^exec |exec $newPath $params |" -i "$link"
else
sed 's|^exec |exec -a "$0" |' -i "$link"
echo
fi
done
}
'' +
# texlive post-install actions
''
mkdir -p "$out/share/texmf/scripts/texlive/"
ln -s '${bin.core.out}/share/texmf-dist/scripts/texlive/TeXLive' "$out/share/texmf/scripts/texlive/"
for tool in updmap; do
ln -sf "$out/share/texmf/scripts/texlive/$tool."* "$out/bin/$tool"
done
'' +
# now hack to preserve "$0" for mktexfmt
''
cp "$out"/share/texmf/scripts/texlive/fmtutil.pl "$out/bin/fmtutil"
patchShebangs "$out/bin/fmtutil"
sed "1s|$| -I $out/share/texmf/scripts/texlive|" -i "$out/bin/fmtutil"
ln -sf fmtutil "$out/bin/mktexfmt"
perl `type -P mktexlsr.pl` ./share/texmf
texlinks.sh "$out/bin" && wrapBin
perl `type -P fmtutil.pl` --sys --refresh | grep '^fmtutil' # too verbose
#texlinks.sh "$out/bin" && wrapBin # do we need to regenerate format links?
perl `type -P updmap.pl` --sys --syncwithtrees --force
perl `type -P mktexlsr.pl` ./share/texmf-* # to make sure
'' +
# install (wrappers for) scripts, based on a list from upstream texlive
''
(
cd "$out/share/texmf/scripts"
source '${bin.core.out}/share/texmf-dist/scripts/texlive/scripts.lst'
for s in $texmf_scripts; do
[[ -x "./$s" ]] || continue
tName="$(basename $s | sed 's/\.[a-z]\+$//')" # remove extension
[[ ! -e "$out/bin/$tName" ]] || continue
ln -sv "$(realpath $s)" "$out/bin/$tName" # wrapped below
done
)
rm "$out"/bin/*-sys
wrapBin
'' +
# TODO: a context trigger https://www.preining.info/blog/2015/06/debian-tex-live-2015-the-new-layout/
# http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29
# I would just create links from "$out"/share/{man,info},
# but buildenv has problems with merging symlinks with directories;
# note: it's possible we might need deepen the work-around to man/*.
''
for d in {man,info}; do
[[ -e "./share/texmf/doc/$d" ]] || continue;
(
mkdir -p "./share/$d" && cd "./share/$d"
ln -s -t . ../texmf/doc/"$d"/*
)
done
''
+ bin.cleanBrokenLinks
;
}
# TODO: make TeX fonts visible by fontconfig: it should be enough to install an appropriate file
# similarly, deal with xe(la)tex font visibility?

View File

@ -0,0 +1,199 @@
/* (new) TeX Live user docs
- Basic usage: just pull texlive.combined.scheme-basic
for an environment with basic LaTeX support.
There are all the schemes as defined upstream (with tiny differences, perhaps).
- You can compose your own collection like this:
texlive.combine {
inherit (texlive) scheme-small collection-langkorean algorithms cm-super;
}
- By default you only get executables and files needed during runtime,
and a little documentation for the core packages.
To change that, you need to add `pkgFilter` function to `combine`.
texlive.combine {
# inherit (texlive) whatever-you-want;
pkgFilter = pkg:
pkg.tlType == "run" || pkg.tlType == "bin" || pkg.pname == "cm-super";
# elem tlType [ "run" "bin" "doc" "source" ]
# there are also other attributes: version, name
}
- Known bugs:
* some tools are still missing, e.g. luajittex
* some apps aren't packaged/tested yet (xdvi, asymptote, biber, etc.)
* feature/bug: when a package is rejected by pkgFilter,
its dependencies are still propagated
* in case of any bugs or feature requests, file a github issue and /cc @vcunat
*/
{ stdenv, lib, fetchurl, runCommand, buildEnv
, callPackage, ghostscriptX, harfbuzz, poppler_min
, makeWrapper, perl, python, ruby
, useFixedHashes ? true
, recurseIntoAttrs
}:
let
# various binaries (compiled)
bin = callPackage ./bin.nix {
poppler = poppler_min; # otherwise depend on various X stuff
ghostscript = ghostscriptX;
harfbuzz = harfbuzz.override {
withIcu = true; withGraphite2 = true;
};
};
# map: name -> fixed-output hash
# sha1 in base32 was chosen as a compromise between security and length
# warning: the following generator command takes lots of resources
# nix-build -Q -A texlive.scheme-full.pkgs | ./fixHashes.sh > ./fixedHashes.nix
fixedHashes = lib.optionalAttrs useFixedHashes (import ./fixedHashes.nix);
# function for creating a working environment from a set of TL packages
combine = import ./combine.nix {
inherit bin combinePkgs buildEnv fastUnique lib makeWrapper perl stdenv python ruby;
};
# the set of TeX Live packages, collections, and schemes; using upstream naming
tl = let
/* curl ftp://tug.ctan.org/pub/tex/historic/systems/texlive/2015/tlnet-final/tlpkg/texlive.tlpdb.xz \
| xzcat | uniq -u | sed -rn -f ./tl2nix.sed > ./pkgs.nix */
orig = import ./pkgs.nix tl;
clean = orig // {
# overrides of texlive.tlpdb
tetex = orig.tetex // { # 2015.08.27 as we need version with mktexlsr.pl
# TODO: official hashed mirror
urlPrefix = "http://lipa.ms.mff.cuni.cz/~cunav5am/nix";
md5.run = "4b4c0208124dfc9c8244c24421946d36";
md5.doc = "983f5e5b5f4e407760b4ec176cf6a58f";
version = "3.0"; # it's the same
postUnpack = "cd $out && patch -p2 < ${./texlinks.patch} || true";
# TODO: postUnpack per tlType instead of these hacks
};
dvidvi = orig.dvidvi // {
hasRunfiles = false; # only contains docs that's in bin.core.doc already
};
texlive-msg-translations = orig.texlive-msg-translations // {
hasRunfiles = false; # only *.po for tlmgr
};
# remove dependency-heavy packages from the basic collections
collection-basic = orig.collection-basic // {
deps = removeAttrs orig.collection-basic.deps [ "luatex" "metafont" "xdvi" ];
};
latex = orig.latex // {
deps = removeAttrs orig.latex.deps [ "luatex" ];
};
}; # overrides
# tl =
in lib.mapAttrs flatDeps clean;
# TODO: texlive.infra for web2c config?
flatDeps = pname: attrs:
let
version = attrs.version or bin.texliveYear;
mkPkgV = tlType: let
pkg = attrs // {
md5 = attrs.md5.${tlType};
inherit pname tlType version;
};
in mkPkgs {
inherit (pkg) pname tlType version;
pkgList = [ pkg ];
};
in {
# TL pkg contains lists of packages: runtime files, docs, sources, binaries
pkgs =
# tarball of a collection/scheme itself only contains a tlobj file
[( if (attrs.hasRunfiles or false) then mkPkgV "run"
# the fake derivations are used for filtering of hyphenation patterns
else { inherit pname version; tlType = "run"; }
)]
++ lib.optional (attrs.md5 ? "doc") (mkPkgV "doc")
++ lib.optional (attrs.md5 ? "source") (mkPkgV "source")
++ lib.optional (bin ? ${pname})
( bin.${pname} // { inherit pname; tlType = "bin"; } )
++ combinePkgs (attrs.deps or {});
};
# the basename used by upstream (without ".tar.xz" suffix)
mkUrlName = { pname, tlType, ... }:
pname + lib.optionalString (tlType != "run") ".${tlType}";
unpackPkg =
{ # url ? null, urlPrefix ? null
md5, pname, tlType, postUnpack ? "", stripPrefix ? 1, ...
}@args: let
url = args.url or "${urlPrefix}/${mkUrlName args}.tar.xz";
urlPrefix = args.urlPrefix or
("${mirror}/pub/tex/historic/systems/texlive/${bin.texliveYear}/tlnet-final/archive");
# beware: standard mirrors http://mirror.ctan.org/ don't have releases
mirror = "ftp://tug.ctan.org"; # also works: ftp.math.utah.edu
in ''
tar -xf '${ fetchurl { inherit url md5; } }' \
'--strip-components=${toString stripPrefix}' \
-C "$out" --anchored --exclude=tlpkg --keep-old-files
'' + postUnpack;
mkPkgs = { pname, tlType, version, pkgList }@args:
/* TODOs:
- "historic" isn't mirrored; posted a question at #287
- maybe cache (some) collections? (they don't overlap)
*/
let
tlName = "${mkUrlName args}-${version}";
fixedHash = fixedHashes.${tlName} or null; # be graceful about missing hashes
in runCommand "texlive-${tlName}"
( { # lots of derivations, not meant to be cached
preferLocalBuild = true; allowSubstitutes = false;
passthru = { inherit pname tlType version; };
} // lib.optionalAttrs (fixedHash != null) {
outputHash = fixedHash;
outputHashAlgo = "sha1";
outputHashMode = "recursive";
}
)
( ''
mkdir "$out"
'' + lib.concatMapStrings unpackPkg (fastUnique (a: b: a.md5 < b.md5) pkgList)
);
# combine a set of TL packages into a single TL meta-package
combinePkgs = pkgSet: lib.concatLists # uniqueness is handled in `combine`
(lib.mapAttrsToList (_n: a: a.pkgs) pkgSet);
# TODO: replace by buitin once it exists
fastUnique = comparator: list: with lib;
let un_adj = l: if length l < 2 then l
else optional (head l != elemAt l 1) (head l) ++ un_adj (tail l);
in un_adj (lib.sort comparator list);
in
tl // {
inherit bin combine;
# Pre-defined combined packages for TeX Live schemes,
# to make nix-env usage more comfortable and build selected on Hydra.
combined = with lib; recurseIntoAttrs (
mapAttrs
(pname: attrs:
addMetaAttrs rec {
description = "TeX Live environment for ${pname}";
platforms = lib.platforms.all;
hydraPlatforms = lib.optionals
(lib.elem pname ["scheme-small" "scheme-basic"]) platforms;
maintainers = [ lib.maintainers.vcunat ];
}
(combine {
${pname} = attrs;
extraName = "combined" + lib.removePrefix "scheme" pname;
})
)
{ inherit (tl) scheme-full
scheme-tetex scheme-medium scheme-small scheme-basic scheme-minimal
scheme-context scheme-gust scheme-xml;
}
);
}

View File

@ -0,0 +1,10 @@
#!/bin/sh
echo "{"
grep -v -F '.bin-' | while read path; do
hash=`nix-hash --type sha1 --base32 "$path"`
echo -n "$path" | sed -E 's/[^-]*-texlive-(.*)/"\1"/'
echo "=\"$hash\";"
done
echo "}"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
addTeXMFPath () {
if test -d "$1/share/texmf-nix"; then
export TEXINPUTS="${TEXINPUTS}${TEXINPUTS:+:}$1/share/texmf-nix//:"
fi
}
envHooks+=(addTeXMFPath)

View File

@ -0,0 +1,15 @@
Don't overwrite already existing files!
diff --git a/texmf-dist/scripts/texlive/texlinks.sh b/texmf-dist/scripts/texlive/texlinks.sh
index 91540ea..9b1d7ed 100755
--- a/texmf-dist/scripts/texlive/texlinks.sh
+++ b/texmf-dist/scripts/texlive/texlinks.sh
@@ -157,7 +157,7 @@ install_link()
verbose_echo "skipped ConTeXtish symlink $src -> $dest (special case)"
;;
*)
- test "x$src" != "x`(ls -ld $src | awk '{print $NF}') 2>/dev/null`" &&
+ test ! -f "$src" &&
rm -f "$src"
if test -f "$src"; then

View File

@ -0,0 +1,31 @@
# wrap whole file into an attrset
1itl: { # no indentation
$a}
# trash packages we don't want
/^name .*\./,/^$/d
# quote package names, as some start with a number :-/
s/^name (.*)/name "\1"/
# form an attrmap per package
/^name /s/^name (.*)/\1 = {/p
/^$/,1i};
# extract md5 for runfiles
s/^containermd5 (.*)/ md5.run = "\1";/p
s/^doccontainermd5 (.*)/ md5.doc = "\1";/p
s/^srccontainermd5 (.*)/ md5.source = "\1";/p
/^runfiles /i\ hasRunfiles = true;
# number of path components to strip, defaulting to 1 ("texmf-dist/")
/^relocated 1/i\ stripPrefix = 0;
# extract version and clean unwanted chars from it
/^catalogue-version/y/ \/~/_--/
/^catalogue-version/s/[\#,:\(\)]//g
s/^catalogue-version_(.*)/ version = "\1";/p
# extract deps
s/^depend ([^.]*)$/ deps."\1" = tl."\1";/p

View File

@ -3121,7 +3121,7 @@ let
telnet = callPackage ../tools/networking/telnet { }; telnet = callPackage ../tools/networking/telnet { };
texmacs = callPackage ../applications/editors/texmacs { texmacs = callPackage ../applications/editors/texmacs {
tex = texLive; /* tetex is also an option */ tex = texlive.combined.scheme-small;
extraFonts = true; extraFonts = true;
}; };
@ -3953,11 +3953,6 @@ let
gcl = builderDefsPackage (callPackage ../development/compilers/gcl) { gcl = builderDefsPackage (callPackage ../development/compilers/gcl) {
gmp = gmp4; gmp = gmp4;
texLive = texLiveAggregationFun {
paths = [
texLive texLiveExtra
];
};
}; };
gcc-arm-embedded-4_7 = callPackage_i686 ../development/compilers/gcc-arm-embedded { gcc-arm-embedded-4_7 = callPackage_i686 ../development/compilers/gcc-arm-embedded {
@ -7799,6 +7794,11 @@ let
poppler = callPackage ../development/libraries/poppler { lcms = lcms2; }; poppler = callPackage ../development/libraries/poppler { lcms = lcms2; };
poppler_min = poppler.override { # TODO: maybe reduce even more
minimal = true;
suffix = "min";
};
poppler_qt4 = poppler.override { poppler_qt4 = poppler.override {
qt4Support = true; qt4Support = true;
suffix = "qt4"; suffix = "qt4";
@ -8729,7 +8729,10 @@ let
### DEVELOPMENT / R MODULES ### DEVELOPMENT / R MODULES
R = callPackage ../applications/science/math/R { R = callPackage ../applications/science/math/R {
texLive = texLiveAggregationFun { paths = [ texLive texLiveExtra ]; }; # TODO: split docs into a separate output
texLive = texlive.combine {
inherit (texlive) scheme-small inconsolata helvetic texinfo fancyvrb cm-super;
};
openblas = openblasCompat; openblas = openblasCompat;
withRecommendedPackages = false; withRecommendedPackages = false;
}; };
@ -11124,15 +11127,11 @@ let
proofgeneral_4_2 = callPackage ../applications/editors/emacs-modes/proofgeneral/4.2.nix { proofgeneral_4_2 = callPackage ../applications/editors/emacs-modes/proofgeneral/4.2.nix {
texinfo = texinfo4 ; texinfo = texinfo4 ;
texLive = pkgs.texLiveAggregationFun { texLive = texlive.combine { inherit (texlive) scheme-basic cm-super ec; };
paths = [ pkgs.texLive pkgs.texLiveCMSuper ];
};
}; };
proofgeneral_4_3_pre = callPackage ../applications/editors/emacs-modes/proofgeneral/4.3pre.nix { proofgeneral_4_3_pre = callPackage ../applications/editors/emacs-modes/proofgeneral/4.3pre.nix {
texinfo = texinfo4 ; texinfo = texinfo4 ;
texLive = pkgs.texLiveAggregationFun { texLive = texlive.combine { inherit (texlive) scheme-basic cm-super ec; };
paths = [ pkgs.texLive pkgs.texLiveCMSuper ];
};
}; };
proofgeneral = self.proofgeneral_4_2; proofgeneral = self.proofgeneral_4_2;
@ -14643,8 +14642,6 @@ let
keynav = callPackage ../tools/X11/keynav { }; keynav = callPackage ../tools/X11/keynav { };
lazylist = callPackage ../tools/typesetting/tex/lazylist { };
lilypond = callPackage ../misc/lilypond { guile = guile_1_8; }; lilypond = callPackage ../misc/lilypond { guile = guile_1_8; };
mailcore2 = callPackage ../development/libraries/mailcore2 { }; mailcore2 = callPackage ../development/libraries/mailcore2 { };
@ -14747,8 +14744,6 @@ let
pjsip = callPackage ../applications/networking/pjsip { }; pjsip = callPackage ../applications/networking/pjsip { };
polytable = callPackage ../tools/typesetting/tex/polytable { };
PPSSPP = callPackage ../misc/emulators/ppsspp { SDL = SDL2; }; PPSSPP = callPackage ../misc/emulators/ppsspp { SDL = SDL2; };
uae = callPackage ../misc/emulators/uae { }; uae = callPackage ../misc/emulators/uae { };
@ -14828,6 +14823,10 @@ let
texFunctions = callPackage ../tools/typesetting/tex/nix pkgs; texFunctions = callPackage ../tools/typesetting/tex/nix pkgs;
# All the new TeX Live is inside. See description in default.nix.
texlive = recurseIntoAttrs
(callPackage ../tools/typesetting/tex/texlive-new { });
texLive = builderDefsPackage (callPackage ../tools/typesetting/tex/texlive) { texLive = builderDefsPackage (callPackage ../tools/typesetting/tex/texlive) {
ghostscript = ghostscriptX; ghostscript = ghostscriptX;
harfbuzz = harfbuzz.override { harfbuzz = harfbuzz.override {