{ 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; ssl = settings.ssl; 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 ])) ]; }; wrapHost = ssl: host: (if ssl then "https" else "http") + "//${host}"; in lib = { english = settings: website { inherit (settings) drafts; ssl = settings.ssl or false; source = blog-source; path = "."; replaceUrl = { from = "https://danilafe.com"; to = wrapHost settings.ssl settings.host; }; }; 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; }; }; };