Git Product home page Git Product logo

tex2nix's Introduction

tex2nix

Generate Texlive environment containing all dependencies for your document rather than downloading gigabytes of texlive packages.

Installation

With stable nix you can do:

nix-build && ./result/bin/tex2nix

If you use flakes put the following in your inputs

{
  inputs.tex2nix.url = "github:rgri/tex2nix";
  inputs.tex2nix.inputs.utils.follows = "nixpkgs";
}

or just do:

$ nix run github:rgri/tex2nix

USAGE

$ tex2nix main.tex
wrote tex-env.nix
$ cat tex-env.nix
# Generated with tex2nix 0.0.0
{ texlive }:
(texlive.combine {
    inherit (texlive) scheme-small;
    "varwidth" = texlive."varwidth";
    "tabu" = texlive."tabu";

})

tex2nix does not follow \input or \include. However you can specify multiple texfiles as input

$ tex2nix *.tex

The resulting expression can be imported like this to in your document directory:

# shell.nix
with import <nixpkgs> {};
mkShell {
  buildInputs = [ (pkgs.callPackage ./tex-env.nix {}) ];
}
$ nix-shell shell.nix
nix-shell> pdflatex --version
pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020/NixOS.org)
...

To add additional packages you can use the extraTexPackages field:

with import <nixpkgs> {};
mkShell {
  buildInputs = [ (pkgs.callPackage ./tex-env.nix {
    extraTexPackages = {
      inherit (texlive) latexmk;
    };
  }) ];
}

Project history

tex2nix was originally written by Mic92. Since 2023, rgri is the new maintainer.

tex2nix's People

Contributors

bors[bot] avatar dependabot[bot] avatar doronbehar avatar harryprayiv avatar mic92 avatar r-vdp avatar rgri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tex2nix's Issues

Error: experimental Nix feature 'nix-command' is disabled

[pbb@mozarella:~/nyantec/doc]$ nix run -f https://github.com/Mic92/tex2nix/archive/main.tar.gz
[1 built, 29 copied (29.4 MiB), 5.4 MiB DL]

[pbb@mozarella:~/nyantec/doc]$ result

[pbb@mozarella:~/.../doc]$ tex2nix pandoc/default.latex
error: --- Error ------------------------------------------------------------------------------------ nix
experimental Nix feature 'nix-command' is disabled; use '--experimental-features nix-command' to override
Traceback (most recent call last):
  File "/nix/store/wnp6kx90fmv9rpzx1i8imyz5w93whxgh-tex2nix/bin/.tex2nix-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/wnp6kx90fmv9rpzx1i8imyz5w93whxgh-tex2nix/lib/python3.8/site-packages/tex2nix/__init__.py", line 92, in main
    packages = extract_dependencies(fileinput.input())
  File "/nix/store/wnp6kx90fmv9rpzx1i8imyz5w93whxgh-tex2nix/lib/python3.8/site-packages/tex2nix/__init__.py", line 86, in extract_dependencies
    all_packages = get_nix_packages()
  File "/nix/store/wnp6kx90fmv9rpzx1i8imyz5w93whxgh-tex2nix/lib/python3.8/site-packages/tex2nix/__init__.py", line 13, in get_nix_packages
    res = subprocess.run(
  File "/nix/store/m7080pw0ryjk0jhljp55rq1hd2qy8gki-python3-3.8.6/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['nix', 'eval', '--json', 'nixpkgs#texlive', '--apply', 'builtins.attrNames']' returned non-zero exit status 1.

[pbb@mozarella:~/.../doc]$

This is caused by the program being wrapped to use nixFlakes and using the nix v2 nix eval command.

Maintainence status

I see that you're looking for a new maintainer. I'm new to the OSS and Nix communities and am looking for the chance to gain some experience. Would this project be a good place to start? If so, I'm pretty familiar with latex having used it in school extensively, and I know how to read Nix and use Flakes.

Packages with different style file name are ignored

Given this example document:

\documentclass{article}
\usepackage{MnSymbol}
\begin{document}
 $\bigcircle$
\end{document}

When running tex2nix on it, it does not add the package to the environment.

This is because there is no TeXLive package named MnSymbol, only mnsymbol. However, the style file is called MnSymbol.sty, so using \usepackage{mnsymbol} (for which tex2nix produces the correct environment) does not work.

I don’t know how this could be fixed, because searching the name of the style files would require building all TeXLive packages, which takes a long time and uses up a high amount of storage. In this specific case, a workaround might be to compare the packages case-insensitive, though that might lead to other problems.

find dependencies recursively

recurse into

  • \input files
  • \usepackage files
  • \RequirePackage files
    consider [] before {} and that lines may be commented

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.