Skip to content

Commit

Permalink
Merge pull request #17 from phip1611/nix-modernize
Browse files Browse the repository at this point in the history
nix: modernize + shell.nix + documentation improvements
  • Loading branch information
l3nkz committed Mar 3, 2023
2 parents 3e250df + e523f72 commit 37a656c
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 123 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v17
- run: nix-build ./nix/release.nix -A latex-template
- run: nix-build
# -s: test if this is a file and if it has a size.
- run: test -s result/diplom.pdf

# uses latexmk
regular_build:
Expand Down
85 changes: 47 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
[![Build](https://github.com/TUD-OS/latex-template/actions/workflows/build.yml/badge.svg)](https://github.com/TUD-OS/latex-template/actions/workflows/build.yml)

Was ist das?
============
## Was ist das?

Dieses Diplomarbeits-Latex-Template stellt ein Skelett für eine
Diplomarbeit mit zugehöriger Make-Datei zur Verfügung.

Checkout Submodules First
===================
In order to use the `$ make checkbiw` script please execute: `git submodule update --init --recursive`
## Checkout Submodules First

Um das `$ make checkbiw` ausführen zu können, musst du zuerst die
Submodule auschecken: `git submodule update --init --recursive`

## So geht's los

Als erstes solltest du in diplom.tex alle Vorkommen von Otto
Mustermann, "Dein Titel" und "Dein Betreuer" ersetzen.

`diplom.tex` will deine Aufgabe als PDF einbinden. Es sucht
`images/diplom-aufgabe.pdf`, was eine A4 Seite sein muss. Mit

convert <dein-gescanntes-bild> diplom-aufgabe.pdf

solltest du eine beliebige Bilddatei in ein PDF umwandeln können, wenn
ImageMagick auf deinem System installiert ist.

An diesen Punkt sollte `make` ein `diplom.pdf` produzieren.

Das Template unterstützt sowohl englischen und deutschen Text. Englisch ist
standardmäßig eingestellt. Für deutschen Text kann der letzte `\selectlanguage`
Aufruf in `diplom.tex` einfach weggelassen werden.

## How To Build

- `$ make`: regular build that produces `diplom.pdf` and `yyyy-mm-dd_hhmmss DRAFT Diplomarbeit - Branch <branch>.pdf`.
- `$ make watch`: Performs a watch task, i.e. automatically re-builds everything quickly on changes.
If your PDF viewer supports automatic reload on file changes (such as the default PDF viewer in GNOME)
you get a cool productive working environment.

### Build Prerequisites (Regular Build)

Build Prerequisites
===================
In case you don't want to install `texlive-full` to save disk space, the following packages are
actually required: \

```shell
$ sudo apt install texlive-base \
texlive-lang-german \
Expand All @@ -29,6 +56,7 @@ $ sudo apt install texlive-base \
```

Additionally, please install also:

```shell
$ sudo apt install \
`# for the `make checkbiw` script`
Expand All @@ -37,35 +65,18 @@ $ sudo apt install \
latexmk
```

So geht's los
==============

Als erstes solltest du in diplom.tex alle Vorkommen von Otto
Mustermann, "Dein Titel" und "Dein Betreuer" ersetzen.

`diplom.tex` will deine Aufgabe als PDF einbinden. Es sucht
`images/diplom-aufgabe.pdf`, was eine A4 Seite sein muss. Mit

convert <dein-gescanntes-bild> diplom-aufgabe.pdf
### Build Prerequisites (Nix Build)

solltest du eine beliebige Bilddatei in ein PDF umwandeln können, wenn
ImageMagick auf deinem System installiert ist.

An diesen Punkt sollte `make` ein `diplom.pdf` produzieren.

Das Template unterstützt sowohl englischen und deutschen Text. Englisch ist
standardmäßig eingestellt. Für deutschen Text kann der letzte `\selectlanguage`
Aufruf in `diplom.tex` einfach weggelassen werden.

How To Build
============
- `make`: regular build
- `make watch`: Performs a watch task, i.e. automatically re-builds everything quickly on changes.
If your PDF viewer supports automatic reload on file changes (such as the default PDF viewer in GNOME)
you get a cool productive working environment.
This template can also be built using [Nix](https://nixos.org/download.html). You have
the option to either use `$ nix-build`, which will produce `result/diplom.pdf`, or to
use
```bash
$ nix-shell
$ make clean
$ make watch # (or just make)
```

Grafiken einbinden
==================
## Grafiken einbinden

Grafiken sollten im `images/` Verzeichnis abgelegt werden und im
Makefile in die entsprechende `DOC_IMG_*` Variable eingetragen
Expand All @@ -74,8 +85,7 @@ unterstützt. PDF eignet sich für Vektorgrafiken und kann von den
meisten Vektorgrafikprogrammen erzeugt werden (Inkscape, OpenOffice
Draw, ...).

Tipps
=====
## Tipps

Diese Datei enthält im Moment ein Sammlung von Tipps und Tricks, sowie
einige Hintergrundinformationen.
Expand Down Expand Up @@ -115,8 +125,7 @@ einige Hintergrundinformationen.
vim, ... make sure to activate the setting or add the plugin for that into your IDE/editor


spezielle Tipps von Frank
=========================
## spezielle Tipps von Frank

- Ich verwende in der Vorlage KOMA-Script (`scrbook`), welches vor allem
für den deutschsprachigen Raum gedacht ist. KOMA-Script kann auch
Expand Down
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import ./nix/release.nix {}).pdf
27 changes: 6 additions & 21 deletions nix/build.nix
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
{ stdenvNoCC, gitignoreSource, texlive }:
{ stdenvNoCC, gitignoreSource, tex, gnumake }:

let
tex = texlive.combine {
inherit (texlive) scheme-small
biber
biblatex
csquotes
hyphenat
lastpage
latexmk
siunitx
todonotes
xpatch;
};
in stdenvNoCC.mkDerivation {
stdenvNoCC.mkDerivation {
pname = "latex-template";
version = "1.0.0";

src = gitignoreSource ../.;

nativeBuildInputs = [
gnumake
tex
];

doConfigure = false;

# Avoid luatex failing due to non-writable cache.
TEXMFVAR = "/tmp/texlive/";

buildPhase = ''
make
'';
TEXTMFHOME = "/tmp/texlive/";

installPhase = ''
mkdir -p $out/share/latex-template
install -m 0644 diplom.pdf $out/share/latex-template/
mkdir -p $out
install -m 0644 diplom.pdf $out/
'';
}
10 changes: 6 additions & 4 deletions nix/release.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{ sources ? import ./sources.nix
, pkgs ? import sources.nixpkgs { }
}:
let
sources = import ./sources.nix;
pkgs = import sources.nixpkgs {};

tex = import ./tex-toolchain.nix { inherit pkgs; };
inherit (import sources."gitignore.nix" { inherit (pkgs) lib; }) gitignoreSource;
in
{
latex-template = pkgs.callPackage ./build.nix {
pdf = pkgs.callPackage ./build.nix {
inherit gitignoreSource;
inherit tex;
};
}
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"homepage": "",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "bff2832ec341cf30acb3a4d3e2e7f1f7b590116a",
"sha256": "0va0janxvmilm67nbl81gdbpppal4aprxzb25gp9pqvf76ahxsci",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"sha256": "07vg2i9va38zbld9abs9lzqblz193vc5wvqd6h7amkmwf66ljcgh",
"type": "tarball",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/bff2832ec341cf30acb3a4d3e2e7f1f7b590116a.tar.gz",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/a20de23b925fd8264fd7fad6454652e142fd7f73.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixpkgs-unstable",
"branch": "release-22.11",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5643714dea562f0161529ab23058562afeff46d0",
"sha256": "1xs8h3jqi5fndy8b6x5i44a0l1qvbqwnsbs0is36fy6rwl8pdk8v",
"rev": "62ffdb32823e8d8caca00d0d75ac8e02212de76b",
"sha256": "0nfz26f2lc75av8ijvavq3ajq6cqwmlkn62fcy76222v9hyhqdcy",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5643714dea562f0161529ab23058562afeff46d0.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/62ffdb32823e8d8caca00d0d75ac8e02212de76b.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
Loading

0 comments on commit 37a656c

Please sign in to comment.