mirror of
https://github.com/Smaug123/static-site-pdfs
synced 2025-10-13 03:08:40 +00:00
Compare commits
2 Commits
d8cf76c2f1
...
97c35066c1
Author | SHA1 | Date | |
---|---|---|---|
|
97c35066c1 | ||
|
f2cb47916b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@
|
|||||||
*.pdf
|
*.pdf
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/result
|
||||||
|
24
build.sh
Executable file
24
build.sh
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
USER_DIR=$(readlink -f "$1")
|
||||||
|
WORKDIR=$(mktemp -d -p "$USER_DIR")
|
||||||
|
|
||||||
|
cd "$WORKDIR" || exit 1
|
||||||
|
|
||||||
|
# Build PDFs from LaTeX. Do the build twice to sort out any bookmarks.
|
||||||
|
find "$USER_DIR" -type f -name '*.tex' -print0 | while IFS= read -r -d '' file; do
|
||||||
|
echo ">>> $file"
|
||||||
|
ls -la "$file"
|
||||||
|
output=$(dirname "$file")/$(basename "$file" .tex).pdf
|
||||||
|
if [ -f "$output" ]; then
|
||||||
|
echo "Skipping $file as already built"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "$file - $output"
|
||||||
|
HOME=$(pwd) SOURCE_DATE_EPOCH=1622905527 pdflatex "$file" || exit 1
|
||||||
|
HOME=$(pwd) SOURCE_DATE_EPOCH=1622905527 pdflatex "$file" || exit 1
|
||||||
|
mv "$(basename "$output")" "$output" || exit 1
|
||||||
|
done
|
||||||
|
|
||||||
|
cd "$USER_DIR" || exit 1
|
||||||
|
rm -r "$WORKDIR"
|
77
flake.lock
generated
Normal file
77
flake.lock
generated
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1694529238,
|
||||||
|
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1688392541,
|
||||||
|
"narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-22.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"scripts": "scripts"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696031019,
|
||||||
|
"narHash": "sha256-MuKEC8ZZ1Znm2idxQEQYU18z/1l9rjBZaj5gdKd9elQ=",
|
||||||
|
"owner": "Smaug123",
|
||||||
|
"repo": "flake-shell-script",
|
||||||
|
"rev": "05cc0582a193d3b42b6b4e64c6ec7a9bca4bb3c5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "Smaug123",
|
||||||
|
"repo": "flake-shell-script",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
48
flake.nix
Normal file
48
flake.nix
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
description = "PDFs hosted on patrickstevens.co.uk";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
flake-utils.url = github:numtide/flake-utils;
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
||||||
|
scripts.url = "github:Smaug123/flake-shell-script";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
scripts,
|
||||||
|
}: let
|
||||||
|
commit = self.shortRev or "dirty";
|
||||||
|
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||||
|
version = "1.0.0+${builtins.substring 0 8 date}.${commit}";
|
||||||
|
in
|
||||||
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in let
|
||||||
|
texlive = pkgs.texlive.combine {
|
||||||
|
inherit (pkgs.texlive) scheme-medium mdframed etoolbox zref needspace tikz-cd;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
packages.default = pkgs.stdenv.mkDerivation {
|
||||||
|
__contentAddressed = true;
|
||||||
|
inherit version;
|
||||||
|
pname = "patrickstevens.co.uk-pdfs";
|
||||||
|
src = ./.;
|
||||||
|
buildInputs = [texlive];
|
||||||
|
buildPhase = ''
|
||||||
|
${pkgs.bash}/bin/sh ${scripts.lib.createShellScript pkgs "latex" ./build.sh}/run.sh .
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp ./*.pdf $out
|
||||||
|
cp ./*.tex $out
|
||||||
|
cp ./pdf-targets.txt $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
buildInputs = [pkgs.alejandra pkgs.shellcheck];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user