blog-static-flake/blog/default.nix

59 lines
1.9 KiB
Nix
Raw Normal View History

2020-09-02 17:03:02 -07:00
{ stdenv, lib, hugo, fetchgit, pkgs, nodejs, ruby }:
2020-04-06 16:51:17 -07:00
let
url = "https://dev.danilafe.com/Web-Projects/blog-static.git";
requiredPackages = import ./required-packages.nix { inherit pkgs nodejs; };
2020-09-02 17:03:02 -07:00
website = settings: stdenv.mkDerivation {
2020-04-06 16:51:17 -07:00
name = "blog-static";
2020-09-02 17:03:02 -07:00
version = settings.rev;
2020-04-06 16:51:17 -07:00
src = fetchgit {
2020-09-02 17:03:02 -07:00
inherit url;
inherit (settings) rev sha256;
2020-04-06 16:51:17 -07:00
};
2020-09-02 17:03:02 -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 "";
2020-04-06 16:51:17 -07:00
builder = ./builder.sh;
converter = ./convert.rb;
buildInputs = [ hugo requiredPackages.katex (ruby.withPackages (ps: [ ps.nokogiri ])) ];
2020-09-02 17:03:02 -07:00
};
rev = "b921ddfc8de1282cc82a0d90b2927bf2a5c0ee68";
sha256 = "1gg7dq9y1hg14qjlj2w1rn0xjgqw58s8kpd5x6c0wfpwszcm87ji";
localizationRev = "cd574b43fdddf8b6777610f94897d70697533af9";
localizationSha256 = "1lv65bllrc605lda5gqgpk4ihhg77qgh1zg60swsllmhh5vawgbn";
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";
};
};
};
2020-04-06 16:51:17 -07:00
}