summaryrefslogtreecommitdiffstats
path: root/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'package.nix')
-rw-r--r--package.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/package.nix b/package.nix
new file mode 100644
index 0000000..97f9a7d
--- /dev/null
+++ b/package.nix
@@ -0,0 +1,76 @@
+{
+ stdenv,
+ zola,
+ fd,
+ cacert,
+}:
+stdenv.mkDerivation {
+ pname = "b-peetz.de";
+ version = "v1.0";
+ src = ./src;
+
+ # Run local
+ preferLocalBuild = true;
+ allowSubstitutes = false;
+
+ nativeBuildInputs = [
+ zola
+ fd
+ cacert
+ ];
+
+ buildPhase = let
+ installWriting = name: source:
+ # bash
+ ''
+ pdf_path="writings/${name}"
+ rm --recursive "$pdf_path/"
+ rm "$pdf_path.base"
+
+ install -D "${source}" "$pdf_path"
+ fd . --type file --exec sed --in-place "s|$pdf_path/|$pdf_path|g"
+
+ export base="$pdf_path"
+ '';
+ in
+ # bash
+ ''
+ zola build
+
+ cd ./public || exit 1
+
+ # Remove some useless stuff
+ rm --recursive ./categories
+
+ mkdir --parents ./dead-trees{,/chemistry,/philosophy}
+
+ {
+ ${installWriting "kant-and-free-software.pdf" "${./src/content/writings/kant-and-free-software.pdf.base}"}
+
+ # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
+ ln --symbolic --relative "$base" ./dead-trees/kant_and_free_software.pdf
+ ln --symbolic --relative "$base" ./dead-trees/philosophy/kant_and_free_software.pdf
+ }
+
+ {
+ ${installWriting "raman-spectroscopy.pdf" "${./src/content/writings/raman-spectroscopy.pdf.base}"}
+
+ # NOTE: This link is for backward compatibility, as I have given out links with that url <2024-07-13>
+ ln --symbolic --relative "$base" ./dead-trees/raman_spectrometer.pdf
+ ln --symbolic --relative "$base" ./dead-trees/chemistry/facharbeit.pdf
+ }
+ '';
+
+ installPhase = ''
+ install -d $out/
+ cp --recursive . $out/
+
+ # # Make the website relative (this allows serving it from the ./result via python for
+ # # debugging.)
+ # fd . $out --type file --exec sed --in-place 's|https://b-peetz.de/|/|g'
+ # fd . $out --type file --exec sed --in-place 's|https:&#x2F;&#x2F;b-peetz.de&#x2F;|/|g'
+ #
+ # fd . $out --type file --exec sed --in-place 's|https://b-peetz.de|/|g'
+ # fd . $out --type file --exec sed --in-place 's|https:&#x2F;&#x2F;b-peetz.de|/|g'
+ '';
+}