flake/homepage/default.nix
2025-11-08 14:03:24 +00:00

27 lines
670 B
Nix

{pkgs ? import <nixpkgs> {}}:
pkgs.stdenv.mkDerivation {
name = "distrust-network-static-webroot";
src = ./.;
buildInputs = [pkgs.gawk];
buildPhase = ''
for bodyFile in *.body.html; do
baseName=$(basename "$bodyFile" .body.html)
title=$(echo "Distrust - ''${baseName^}" | sed "s/\\w(-)\\w/ /g")
bodyContent=$(cat "$bodyFile")
awk -v title="$title" -v body="$bodyContent" '{
gsub(/%%TITLE%%/, title);
gsub(/%%BODY%%/, body);
print;
}' template.html > "$baseName.html"
done
'';
installPhase = ''
mkdir -p $out
cp * $out/
rm -f $out/template.html $out/*.body.html $out/*.nix
'';
}