Nix flake / derivation for building my blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

10 months ago
{ blog-source, blog-source-localized, pkgs }:
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;
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
{
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;
};
};
}