From ded7874c7a654293b62b4010daafb3d355e9b39d Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Fri, 1 Nov 2024 14:41:12 +0100 Subject: [PATCH 1/2] Add nix flake Signed-off-by: Maximilian Marx --- bkhandbuch.tex | 3 ++ flake.lock | 27 ++++++++++++++ flake.nix | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/bkhandbuch.tex b/bkhandbuch.tex index af477be..498f7a6 100644 --- a/bkhandbuch.tex +++ b/bkhandbuch.tex @@ -40,6 +40,9 @@ %\fancyfoot[EC,OC]{\scshape \footnotesize FH Regensburg} \fancyfoot[OR]{\scshape \footnotesize Berufungskommissionen} +% reproducible documents +\pdftrailerid{} + %--------------------------------------------------------------- %für Fragebogen \definecolor{light}{gray}{0.80} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a2a43a7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1730327045, + "narHash": "sha256-xKel5kd1AbExymxoIfQ7pgcX6hjw9jCgbiBjiUfSVJ8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "080166c15633801df010977d9d7474b4a6c549d7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..821ac89 --- /dev/null +++ b/flake.nix @@ -0,0 +1,96 @@ +{ + description = "Handbuch zur studentischen Mitwirkung in Berufungskommissionen"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; + }; + + outputs = + inputs@{ self, nixpkgs, ... }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + + environment = { + TEXMFHOME = ".cache"; + TEXMFVAR = ".cache/texmf-var"; + SOURCE_DATE_EPOCH = toString self.lastModified; + }; + + texlive = pkgs.texlive.combine { + inherit (pkgs.texlive) + babel + collection-fontsrecommended + collection-langgerman + colorprofiles + csquotes + draftwatermark + ec + hyperref + latex-bin + latexmk + mathtools + metafont + microtype + pdfmanagement-testphase + pdfx + scheme-basic + silence + textpos + titlesec + todonotes + wasysym + xkeyval + xmpincl + xstring + ; + }; + + mkDocument = + name: + pkgs.stdenvNoCC.mkDerivation rec { + inherit name; + src = self; + + allowSubstitutes = false; + buildInputs = [ + pkgs.coreutils + pkgs.gawk + texlive + ]; + phases = [ + "unpackPhase" + "buildPhase" + "installPhase" + ]; + buildPhase = '' + runHook preBuild + export PATH="${pkgs.lib.makeBinPath buildInputs}"; + mkdir -p .cache/texmf-var + env TEXMFHOME=${environment.TEXMFHOME} \ + TEXMFVAR=${environment.TEXMFVAR} \ + SOURCE_DATE_EPOCH=${environment.SOURCE_DATE_EPOCH} \ + latexmk -interaction=nonstopmode -pdf \ + ${name}.tex + runHook postBuild + ''; + installPhase = '' + runHook preInstall + cp ${name}.pdf $out + runHook postInstall + ''; + }; + + in + { + packages."${system}" = rec { + default = bkhandbuch; + bkhandbuch = mkDocument "bkhandbuch"; + }; + + devShells."${system}".default = pkgs.mkShell { + inherit (environment) TEXMFHOME TEXMFVAR SOURCE_DATE_EPOCH; + buildInputs = [ texlive ]; + }; + }; +} From e1114f02e8369a63c2d017d3ac7bb07c85c34bb5 Mon Sep 17 00:00:00 2001 From: Maximilian Marx Date: Fri, 1 Nov 2024 14:43:00 +0100 Subject: [PATCH 2/2] Add GitHub action Signed-off-by: Maximilian Marx --- .github/workflows/build.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..5720eed --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,23 @@ +name: "Build Berufungshandbuch" +on: + pull_request: + branches: + - main + push: + branches: + - main +jobs: + build: + name: "Build the Berufungshandbuch PDF" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@v9 + with: + nix-installer-tag: v0.15.1 + - uses: DeterminateSystems/magic-nix-cache-action@v3 + - env: + BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }} + run: echo "name=BRANCH_NAME::${BRANCH_NAME_OR_REF#refs/heads/}" >> $GITHUB_ENV + - run: echo "name=PR_NUMBER::$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")" >> $GITHUB_ENV + - run: nix --print-build-logs build .#bkhandbuch -o bkhandbuch.pdf