blog-static-flake/default.nix
2021-10-21 23:24:34 -07:00

59 lines
1.5 KiB
Nix

{ blog-source, blog-source-localized, pkgs }:
with pkgs;
let
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
website = settings: stdenv.mkDerivation {
name = "blog-static";
version = settings.source.rev;
src = settings.source;
urlSub =
let
regexEscape = lib.escape [ "/" "(" ")" "[" "]" "+" "*" "\\" ];
in
if (settings ? replaceUrl)
then (with settings.replaceUrl; "s/${regexEscape from}/${regexEscape to}/g")
else "";
publicPath = settings.path;
extraFlags = if settings.drafts then " -D " else "";
builder = ./build/builder.sh;
converter = ./build/convert.rb;
server = ./build/katexserver.js;
buildInputs = [
hugo nodejs
requiredPackages."katex-0.11.1"
requiredPackages.express
requiredPackages.body-parser
(ruby.withPackages (ps: [ ps.nokogiri ]))
];
};
in
{
english = website {
source = blog-source;
path = ".";
drafts = false;
};
drafts = {
english = website {
source = blog-source;
path = ".";
drafts = true;
replaceUrl = {
from = "https://danilafe.com";
to = "http://drafts.danilafe.com";
};
};
russian = website {
source = blog-source-localized;
path = "ru";
drafts = true;
replaceUrl = {
from = "https://ru.danilafe.com";
to = "http://drafts.ru.danilafe.com";
};
};
};
}