From f1b9082f4eddffdf579f5f0c61973b6aa21844d7 Mon Sep 17 00:00:00 2001 From: dadada Date: Tue, 1 Nov 2022 13:50:29 +0100 Subject: [PATCH] initial commit --- .gitignore | 1 + LICENSE | 16 ++++ README.md | 3 + flake.lock | 39 ++++++++++ flake.nix | 53 +++++++++++++ template/.envrc | 2 + template/.gitignore | 22 ++++++ template/Makefile | 15 ++++ template/bibliography.bib | 8 ++ template/devshell.toml | 46 +++++++++++ template/flake.lock | 156 ++++++++++++++++++++++++++++++++++++++ template/flake.nix | 58 ++++++++++++++ template/thesis.tex | 28 +++++++ template/thesisconfig.tex | 11 +++ tubslatex.nix | 40 ++++++++++ 15 files changed, 498 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 template/.envrc create mode 100644 template/.gitignore create mode 100644 template/Makefile create mode 100644 template/bibliography.bib create mode 100644 template/devshell.toml create mode 100644 template/flake.lock create mode 100644 template/flake.nix create mode 100644 template/thesis.tex create mode 100644 template/thesisconfig.tex create mode 100644 tubslatex.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0e0702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,16 @@ +MIT No Attribution + +Copyright 2023 Tim Schubert + +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fc7c105 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# tubslatex-nix + +Unofficial Nix package and project templates for [tubslatex](https://www.tu-braunschweig.de/latex-vorlagen), the corporate design of TU Braunschweig. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c2d3dea --- /dev/null +++ b/flake.lock @@ -0,0 +1,39 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-3nD7iQXd/J6KjkT8IjozTuA5p8qjiLKTxvOUmH+AzNM=", + "path": "/nix/store/ig0dn500x8lm7mjq8sp3s2k1hpji0xxj-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d5cc293 --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "tubslatex"; + + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, flake-utils, nixpkgs }@inputs: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + in + { + packages = rec { + default = tubslatex; + tubslatex = pkgs.tubslatex; + }; + + checks = { + format = pkgs.runCommand "format" { buildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.} && touch $out"; + testOverlay = pkgs.mkShell { + buildInputs = [ pkgs.texliveWithTubslatex ]; + shellHook = ''Shell created''; + }; + }; + + formatter = pkgs.nixpkgs-fmt; + }) // { + overlays.default = final: prev: { + tubslatex = prev.callPackage ./tubslatex.nix { }; + + texliveWithTubslatex = + let + postCombineOverride = oldAttrs: { + postBuild = oldAttrs.postBuild + '' + updmap --sys --enable Map=NexusProSerif.map --enable Map=NexusProSans.map + updmap --sys + ''; + }; + + tubslatexAttrs = { pkgs = [ final.tubslatex ]; }; + + combined = prev.texlive.combine { + inherit (prev.texlive) scheme-full; + inherit tubslatexAttrs; + }; + in + combined.overrideAttrs postCombineOverride; + }; + }; +} diff --git a/template/.envrc b/template/.envrc new file mode 100644 index 0000000..ba3d8c8 --- /dev/null +++ b/template/.envrc @@ -0,0 +1,2 @@ +watch_file devshell.toml +use flake diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..de59da6 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,22 @@ +*.swp +.direnv/ +*.aux +*.fdb_latexmk +*.fls +*.log +*.bbl +*.bcf +*.blg +*.out +*.run.xml +*.dvi +*.ps +*.glsdefs +*.lof +*.toc +*.bak +*.nav +*.snm +*.vrb +*.pyg +thesis.pdf diff --git a/template/Makefile b/template/Makefile new file mode 100644 index 0000000..bfe9f6a --- /dev/null +++ b/template/Makefile @@ -0,0 +1,15 @@ +.PHONY: thesis.pdf all watch clean + +all: thesis.pdf + +clean: + latexmk -C thesis.tex + +thesis.pdf: thesis.tex + latexmk -interaction=batchmode -pdf thesis.tex + +watch: + while true; do \ + inotifywait -qr -e modify -e create -e delete -e move *tex; \ + $(MAKE); \ + done diff --git a/template/bibliography.bib b/template/bibliography.bib new file mode 100644 index 0000000..53a97d1 --- /dev/null +++ b/template/bibliography.bib @@ -0,0 +1,8 @@ +@article{lisa, + author = {Lisa Mueller}, + title = {Example: Why this article does not exist}, + journal = {Super popular journal}, + volume = {3}, + number = {1}, + year = {2020} +} \ No newline at end of file diff --git a/template/devshell.toml b/template/devshell.toml new file mode 100644 index 0000000..fdb7913 --- /dev/null +++ b/template/devshell.toml @@ -0,0 +1,46 @@ +imports = [ "git/hooks" ] +packages = [ "texliveWithTubslatex", "inotify-tools" ] + +[devshell] +name = "thesis" + +[[commands]] +name = "format" +command = "nix fmt" +help = "Formats the nix files" +category = "development" + +[[commands]] +name = "update" +command = "nix flake update --commit-lock-file" +help = "Updates the dependencies" +category = "development" + +[[commands]] +name = "check" +command = "nix flake check" +help = "Checks if this flake is valid" +category = "development" + +[[commands]] +name = "build-thesis" +command = "make thesis.pdf" +category = "outputs" +help = "Builds the thesis" + +[[commands]] +name = "clean" +command = "make clean" +category = "outputs" +help = "Cleans the build directory" + +[git.hooks] +enable = true + +[git.hooks.pre-commit] +text = """ +FILES=$(git diff --cached --name-only --diff-filter=ACMR -- *.nix| sed -e 's| |\\ |g') +[ -z "$FILES" ] && exit 0 +echo $FILES | xargs nix fmt +echo $FILES | xargs git add +exit 0""" diff --git a/template/flake.lock b/template/flake.lock new file mode 100644 index 0000000..056741b --- /dev/null +++ b/template/flake.lock @@ -0,0 +1,156 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1678957337, + "narHash": "sha256-Gw4nVbuKRdTwPngeOZQOzH/IFowmz4LryMPDiJN/ah4=", + "owner": "numtide", + "repo": "devshell", + "rev": "3e0e60ab37cd0bf7ab59888f5c32499d851edb47", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1667077288, + "narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1677383253, + "narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9952d6bc395f5841262b006fbace8dd7e143b634", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681269223, + "narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", + "path": "/nix/store/dnj69agbi6dz7985gvcbmv40wk1skvmy-source", + "rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 0, + "narHash": "sha256-3nD7iQXd/J6KjkT8IjozTuA5p8qjiLKTxvOUmH+AzNM=", + "path": "/nix/store/ig0dn500x8lm7mjq8sp3s2k1hpji0xxj-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "tubslatex": "tubslatex" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "tubslatex": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1667307103, + "narHash": "sha256-lwS0/ON7yc8I+orxt7w+zO0Dmo1peQ65z4ObKaJhAdk=", + "ref": "refs/heads/main", + "rev": "cae35e5ff56a43f446f175a3931c5b468354bb00", + "revCount": 1, + "type": "git", + "url": "ssh://github.com/dadada/tubslatex-nix?branch=main" + }, + "original": { + "type": "git", + "url": "ssh://github.com/dadada/tubslatex-nix?branch=main" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/template/flake.nix b/template/flake.nix new file mode 100644 index 0000000..ce210f9 --- /dev/null +++ b/template/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Thesis"; + inputs.flake-utils.url = github:numtide/flake-utils; + inputs.devshell.url = github:numtide/devshell; + inputs.tubslatex.url = "git+ssh://github.com/dadada/tubslatex-nix?branch=main"; + + outputs = { self, flake-utils, nixpkgs, devshell, tubslatex }@inputs: + flake-utils.lib.eachDefaultSystem + (system: + let + tubslatexOverlay = tubslatex.overlays.default; + pkgs = import nixpkgs { + inherit system; + overlays = [ tubslatexOverlay ]; + }; + in + { + devShells.default = + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + devshell.overlay + tubslatexOverlay + ]; + }; + in + pkgs.devshell.mkShell { + imports = [ (pkgs.devshell.importTOML ./devshell.toml) ]; + }; + + checks = { + format = pkgs.runCommand "format" { buildInputs = [ pkgs.nixpkgs-fmt ]; } "nixpkgs-fmt --check ${./.} && touch $out"; + }; + + formatter = pkgs.nixpkgs-fmt; + + packages.default = pkgs.callPackage + ({ lib, texliveWithTubslatex, stdenvNoCC, ... }: stdenvNoCC.mkDerivation { + pname = "thesis"; + version = "0.1"; + src = ./.; + nativeBuildInputs = [ texliveWithTubslatex ]; + dontConfigure = true; + installPhase = '' + mkdir -p $out + cp thesis.pdf $out + ''; + meta = with lib; { + description = "Master thesis proposal"; + maintainers = [ "dadada" ]; + platforms = platforms.all; + license = licenses.proprietary; + }; + }) + { }; + }); +} diff --git a/template/thesis.tex b/template/thesis.tex new file mode 100644 index 0000000..fc66e36 --- /dev/null +++ b/template/thesis.tex @@ -0,0 +1,28 @@ +\documentclass[german=false,thesistype=bachelor,nolistoftables,noabstract]{tubsthesis} + +\usepackage{lipsum} + +\input{thesisconfig.tex} +\addbibresource{bibliography.bib} + +\thesisinstitute{Institute of Perfect Writing in IT} + +\begin{document} +\thesisabstract{% +% Since `noabstract` is set, this abstract won't be printed +This is an english text.\\ +\lipsum[1-2] +} + +\begin{thesis} + +\chapter{Introduction} + +\lipsum[1-3] + +\end{thesis} + +\chapter{Storage Device} +Put a table of the contents of your attached Storage Device (SD card/USB flash drive) here. +Add explanations where needed! +\end{document} \ No newline at end of file diff --git a/template/thesisconfig.tex b/template/thesisconfig.tex new file mode 100644 index 0000000..f2f0bb7 --- /dev/null +++ b/template/thesisconfig.tex @@ -0,0 +1,11 @@ +\thesisname{Johanna Doe} +\thesismatrikel{1234567} +\thesisemail{j.doe@tu-braunschweig.de} +\thesismajor{Informatik} +\thesisduration{3} +\thesissupervisors{Super Visor, M. Sc.}{Dr. Dipper Visor}{} +\thesisprofessor[Prof.\,Dr.-Ing.\,Jane Smith]{Prof.\,Dr.-Ing.\,Lars Eisbär} +\thesistitle{Titel der Thesis}{Title of the thesis} +\thesisbegindate{2020-01-01} +%\thesisenddate{2020-01-02} +\thesispresentationpoints{5.7} diff --git a/tubslatex.nix b/tubslatex.nix new file mode 100644 index 0000000..b1bcc36 --- /dev/null +++ b/tubslatex.nix @@ -0,0 +1,40 @@ +{ lib +, stdenvNoCC +, texlive +, unzip +, requireFile +, ... +}: +let + pname = "tubslatex"; + version = "1.3.4"; + tubslatexDownload = requireFile { + name = "${pname}_${version}.tds.zip"; + sha256 = "18adp73l1iqn050ivzjmnp6rgpihkl1278x4ip93xjpicd7mrnlv"; + url = "https://www.tu-braunschweig.de/latex-vorlagen"; + }; +in +stdenvNoCC.mkDerivation { + inherit version pname; + src = tubslatexDownload; + passthru.tlType = "run"; + nativeBuildInputs = [ unzip texlive.combined.scheme-small ]; + dontConfigure = true; + unpackPhase = '' + runHook preUnpack + unzip "$src" + runHook postUnpack + ''; + installPhase = '' + runHook preInstall + mkdir -p $out + cp -r * $out/ + runHook postInstall + ''; + meta = with lib; { + description = "TU Braunschweig Corporate Design"; + maintainers = [ "dadada" ]; + platforms = platforms.all; + license = licenses.unfree; + }; +}