Skip to content

Instantly share code, notes, and snippets.

@BenBals
Created May 6, 2019 10:57
Show Gist options
  • Save BenBals/cc159f96a8f8901dfc8ce3d0c78b0fe9 to your computer and use it in GitHub Desktop.
Save BenBals/cc159f96a8f8901dfc8ce3d0c78b0fe9 to your computer and use it in GitHub Desktop.
image: nixos/nix
build-latex:
stage: build
script:
- nix-build
- cp -Lr result artifacts
artifacts:
paths:
- artifacts
stages:
- build

The nice thing is, that you can now also build the files locally and be guaranteed to have the same output as the CI server. Simply install the nix package manager (curl https://nixos.org/nix/install | sh) and run nix-build.

Note: To keep the amount of software to download to the CI server small, you have to add all needed TeX packages not included in the TeXLive-basic distribution into the build inputs. (I have included examples.) Alternatively you can upgrade the distribution (scheme) (e. g. to small, medium, or full).

To use this snippet simply place both files (.gitlab-ci.yml and default.nix) at the root of your project.

with import <nixpkgs> {};
stdenv.mkDerivation rec {
name = "project-name";
src = ./.;
buildInputs = [
(texlive.combine {
inherit (texlive)
scheme-basic
xetex
collection-fontsrecommended
collection-langgerman
fontspec
sectsty
caption;
})
];
buildPhase = ''
xelatex File1.tex
xelatex folder/File2.tex
'';
installPhase = ''
mkdir -p $out/output-subfolder
cp File1.pdf $out
cp File2.pdf $out/output-subfolder
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment