This repository has been archived on 2021-01-10. You can view files and clone it, but cannot push or open issues or pull requests.
custom-nix/blog/default.nix

64 lines
1.8 KiB
Nix

{ stdenv, lib, hugo, fetchgit, pkgs, nodejs, ruby }:
let
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
website = settings: stdenv.mkDerivation {
name = "blog-static";
version = settings.rev;
src = fetchgit {
inherit url;
inherit (settings) rev sha256;
};
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 = ./builder.sh;
converter = ./convert.rb;
server = ./katexserver.js;
buildInputs = [
hugo nodejs
requiredPackages.katex requiredPackages.express requiredPackages.bodyParser
(ruby.withPackages (ps: [ ps.nokogiri ]))
];
};
rev = "565d4a695541de1d2c760270adf082e36809c464";
sha256 = "0sv23falf3dciapclhl25yf22qi6c26in9zqcl3dvad2v2j7bzbc";
localizationRev = "0b5748cc5a19b5d1d78bfcfa58d4027cc10524dd";
localizationSha256 = "12pqh534z3ppvgzy0a77s9j1qzzmiyxwvlmh5y76pccf32wvi9wz";
in
{
english = website {
inherit rev sha256;
path = ".";
drafts = false;
};
drafts = {
english = website {
inherit rev sha256;
path = ".";
drafts = true;
replaceUrl = {
from = "https://danilafe.com";
to = "http://drafts.danilafe.com";
};
};
russian = website {
rev = localizationRev;
sha256 = localizationSha256;
path = "ru";
drafts = true;
replaceUrl = {
from = "https://ru.danilafe.com";
to = "http://drafts.ru.danilafe.com";
};
};
};
}