2021-10-21 23:00:13 -07:00
|
|
|
{ blog-source, blog-source-localized, pkgs }:
|
|
|
|
|
|
|
|
with pkgs;
|
2020-04-06 16:51:17 -07:00
|
|
|
|
|
|
|
let
|
2020-09-02 17:25:52 -07:00
|
|
|
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
|
|
|
|
website = settings: stdenv.mkDerivation {
|
|
|
|
name = "blog-static";
|
2021-10-21 23:00:13 -07:00
|
|
|
version = settings.source.rev;
|
|
|
|
src = settings.source;
|
2021-10-23 00:27:43 -07:00
|
|
|
ssl = settings.ssl;
|
2020-09-02 17:25:52 -07:00
|
|
|
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 "";
|
2021-10-21 22:39:25 -07:00
|
|
|
builder = ./build/builder.sh;
|
|
|
|
converter = ./build/convert.rb;
|
|
|
|
server = ./build/katexserver.js;
|
2020-12-14 19:16:27 -08:00
|
|
|
buildInputs = [
|
2020-12-14 20:05:29 -08:00
|
|
|
hugo nodejs
|
2021-10-21 22:43:09 -07:00
|
|
|
requiredPackages."katex-0.11.1"
|
|
|
|
requiredPackages.express
|
|
|
|
requiredPackages.body-parser
|
2020-12-14 19:16:27 -08:00
|
|
|
(ruby.withPackages (ps: [ ps.nokogiri ]))
|
|
|
|
];
|
2020-09-02 17:25:52 -07:00
|
|
|
};
|
2021-10-23 00:27:43 -07:00
|
|
|
wrapHost = ssl: host: (if ssl then "https" else "http") + "//${host}";
|
2020-09-02 17:03:02 -07:00
|
|
|
in
|
2021-10-23 00:27:43 -07:00
|
|
|
lib = {
|
|
|
|
english = settings: website {
|
|
|
|
inherit (settings) drafts;
|
|
|
|
ssl = settings.ssl or false;
|
2021-10-21 23:00:13 -07:00
|
|
|
source = blog-source;
|
2020-09-02 17:25:52 -07:00
|
|
|
path = ".";
|
2021-10-23 00:27:43 -07:00
|
|
|
replaceUrl = {
|
|
|
|
from = "https://danilafe.com";
|
|
|
|
to = wrapHost settings.ssl settings.host;
|
2020-09-02 17:25:52 -07:00
|
|
|
};
|
2021-10-23 00:27:43 -07:00
|
|
|
};
|
|
|
|
russian = settings: website {
|
|
|
|
inherit (settings) drafts;
|
|
|
|
ssl = settings.ssl or false;
|
|
|
|
source = blog-source-localized;
|
|
|
|
path = "ru";
|
|
|
|
replaceUrl = {
|
|
|
|
from = "https://ru.danilafe.com";
|
|
|
|
to = wrapHost settings.ssl settings.host;
|
2020-09-02 17:25:52 -07:00
|
|
|
};
|
|
|
|
};
|
2021-10-23 00:27:43 -07:00
|
|
|
};
|