blog-static-flake/lib.nix

53 lines
1.5 KiB
Nix

{ blog-source, blog-source-localized, pkgs, katex-html }:
with pkgs;
let
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
website = settings: stdenv.mkDerivation {
inherit (settings) src ssl host;
name = "blog-static";
version = settings.src.rev;
urlSub =
let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
in
with settings.replaceUrl; "s/${regexEscape from}/${regexEscape to}/g";
publicPath = settings.path;
extraFlags = if settings.drafts then " -D " else "";
builder = ./build/builder.sh;
buildInputs = [
hugo nodejs katex-html
requiredPackages."katex-0.11.1"
requiredPackages.express
requiredPackages.body-parser
(ruby.withPackages (ps: [ ps.nokogiri ]))
];
};
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 = ".";
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";
replaceUrl = {
from = "https://ru.danilafe.com";
to = wrapHost (settings.ssl or false) settings.host;
};
};
}