blog-static-flake/lib.nix

48 lines
1.3 KiB
Nix

{ blog-source, blog-source-localized, pkgs, katex-html }:
with pkgs;
let
website = settings: stdenv.mkDerivation {
inherit (settings) src ssl host;
name = "blog-static";
version = settings.src.rev;
postPatch = with settings.replaceUrl; ''
substituteInPlace config.toml --replace ${from} ${to}
'';
publicPath = settings.path;
extraFlags = (if settings.drafts then " -D " else "") + settings.extraFlags;
builder = ./build/builder.sh;
buildInputs = [
hugo katex-html
];
};
wrapHost = ssl: host: (if ssl then "https" else "http") + "://${host}";
in
{
english = settings: website {
inherit (settings) host;
ssl = settings.ssl or false;
drafts = settings.drafts or false;
src = blog-source;
path = ".";
extraFlags = "--config=config.toml,config-gen.toml";
replaceUrl = {
from = "https://danilafe.com";
to = wrapHost (settings.ssl or false) settings.host;
};
};
russian = settings: website {
inherit (settings) host;
ssl = settings.ssl or false;
drafts = settings.drafts or false;
src = blog-source-localized;
path = "ru";
extraFlags = "";
replaceUrl = {
from = "https://ru.danilafe.com";
to = wrapHost (settings.ssl or false) settings.host;
};
};
}