clan/machines/moritz-server/website/root/default.nix
2025-05-17 22:07:17 +02:00

37 lines
948 B
Nix

{
pkgs,
inputs,
lib,
...
}: let
theme = inputs.zola-theme;
themeName = (builtins.fromTOML (builtins.readFile "${theme}/theme.toml")).name;
package = pkgs.stdenv.mkDerivation {
name = "static-website";
src = with lib.fileset;
toSource {
root = ./.;
fileset = difference (gitTracked ./.) (unions [./default.nix ./.envrc]);
};
nativeBuildInputs = [pkgs.zola];
configurePhase = ''
mkdir themes
ln -s ${theme} themes/${themeName}
'';
buildPhase = "zola build";
installPhase = "cp -r public $out";
};
in {
services.nginx.virtualHosts."moritz.place".root = "${package}";
services.nginx.virtualHosts."moritz.place".locations."/" = {
index = "index.html";
tryFiles = ''"''${uri}.html" $uri $uri/ =404'';
};
services.nginx.virtualHosts."moritz.place".extraConfig = ''
error_page 404 /404.html;
location = /404.html {
internal;
}
'';
}