blog-static-flake/lib.nix

46 lines
1.1 KiB
Nix

{ pkgs, blog-source, web-files, katex-html, resume }:
with pkgs;
with lib;
let
protocol = ssl: if ssl then "https://" else "http://";
website = settings: stdenv.mkDerivation {
inherit (settings) src ssl host;
inherit resume;
name = "blog-static";
version = settings.src.rev or "dirty";
publicPath = settings.path;
hugoFlags = concatStringsSep " " (
optionals settings.drafts (singleton "-D") ++
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
);
builder = ./build/builder.sh;
webFiles = web-files;
buildInputs = [
hugo ruby stork katex-html
];
};
in
{
english = settings: website {
inherit (settings) host;
ssl = settings.ssl or false;
drafts = settings.drafts or false;
src = blog-source;
path = ".";
};
virtualHostFor = package:
{
"${package.host}" = mkMerge [
{
root = package;
}
(mkIf (package.ssl) {
forceSSL = true;
enableACME = true;
})
];
};
}