From 4db22860c902d4a5d6609c1f8529c86e6e1be4e3 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sun, 22 Oct 2023 19:19:19 +0200 Subject: [PATCH] latex template --- flake.nix | 7 +++++++ latex/.envrc | 1 + latex/.gitignore | 2 ++ latex/flake.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++ latex/src/main.tex | 14 ++++++++++++++ trivial/flake.nix | 2 ++ 6 files changed, 74 insertions(+) create mode 100644 latex/.envrc create mode 100644 latex/.gitignore create mode 100644 latex/flake.nix create mode 100644 latex/src/main.tex diff --git a/flake.nix b/flake.nix index d87751d..b5262ba 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,17 @@ { description = "My collection of flake templates"; outputs = { self }: { templates = { + + latex = { + path = ./latex; + description = "A fairly basic latex flake"; + }; + trivial = { path = ./trivial; description = "What I consider to be the bare minimum flake"; }; + }; defaultTemplate = self.templates.trivial; }; diff --git a/latex/.envrc b/latex/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/latex/.envrc @@ -0,0 +1 @@ +use flake diff --git a/latex/.gitignore b/latex/.gitignore new file mode 100644 index 0000000..726d2d6 --- /dev/null +++ b/latex/.gitignore @@ -0,0 +1,2 @@ +result +.direnv diff --git a/latex/flake.nix b/latex/flake.nix new file mode 100644 index 0000000..0d281dd --- /dev/null +++ b/latex/flake.nix @@ -0,0 +1,48 @@ +# inspired by https://flyx.org/nix-flakes-latex/ +{ description = "A latex template"; + inputs = { + nixpkgs.url = github:nixos/nixpkgs/nixos-23.05; + flake-utils.url = github:numtide/flake-utils; + }; + outputs = { self, nixpkgs, flake-utils}: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; }; + texInput = "main"; + # If you're not lazy, figure out what dependencies you need. + # If you are lazy, just take the full scheme. + tex = (pkgs.texlive.combine { + inherit (pkgs.texlive) scheme-full; + #scheme-basic latex-bin latexmk; + }); + in { + packages = rec { + document = pkgs.stdenvNoCC.mkDerivation rec { + pname = throw "put document name here"; + version = "0.0"; + src = ./src; + buildInputs = with pkgs; [ + tex + ]; + buildPhase = '' + mkdir -p .cache/texmf-var + env TEXMFHOME=.cache TEXMFVAR=.cache/texmf-var \ + latexmk -interaction=nonstopmode -pdf -lualatex \ + ${texInput}.tex + ''; + installPhase = '' + mkdir -p $out + cp ${texInput}.pdf $out/ + ''; + }; + default = document; + }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + texlab # my language server of choice + tex + ]; + }; + + }); +} diff --git a/latex/src/main.tex b/latex/src/main.tex new file mode 100644 index 0000000..70dba00 --- /dev/null +++ b/latex/src/main.tex @@ -0,0 +1,14 @@ +\documentclass[a4paper,openany,twoside]{memoir} +\usepackage[english]{babel} +\usepackage[a-3u]{pdfx} +\usepackage[utf8]{inputenc} +\usepackage{hyperref} +\usepackage{lipsum} +\usepackage[T1]{fontenc} +\author{Marty Sluijtman} +\title{On the Wonders of Bikes} +\begin{document} +\maketitle{} +\tableofcontents{} + +\end{document} diff --git a/trivial/flake.nix b/trivial/flake.nix index df5b99d..a59be97 100644 --- a/trivial/flake.nix +++ b/trivial/flake.nix @@ -10,10 +10,12 @@ packages = rec { default = throw "put derivation information here"; }; + devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ (throw "put packages here") ]; }; + }); }