Generate static files as part of the build process
This commit is contained in:
34
lib.nix
34
lib.nix
@@ -1,23 +1,24 @@
|
||||
{ blog-source, blog-source-localized, pkgs, katex-html }:
|
||||
{ blog-source, pkgs, katex-html }:
|
||||
|
||||
with pkgs;
|
||||
with lib;
|
||||
|
||||
let
|
||||
protocol = ssl: if ssl then "https://" else "http://";
|
||||
website = settings: stdenv.mkDerivation {
|
||||
inherit (settings) src ssl host;
|
||||
name = "blog-static";
|
||||
version = settings.src.rev;
|
||||
postPatch = with settings.replaceUrl; ''
|
||||
substituteInPlace config.toml --replace ${from} ${to}
|
||||
'';
|
||||
version = settings.src.rev or "dirty";
|
||||
publicPath = settings.path;
|
||||
extraFlags = (if settings.drafts then " -D " else "") + settings.extraFlags;
|
||||
hugoFlags = concatStringsSep " " (
|
||||
optionals settings.drafts (singleton "-D") ++
|
||||
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
|
||||
);
|
||||
builder = ./build/builder.sh;
|
||||
buildInputs = [
|
||||
hugo katex-html
|
||||
hugo ruby stork katex-html
|
||||
];
|
||||
};
|
||||
wrapHost = ssl: host: (if ssl then "https" else "http") + "://${host}";
|
||||
in
|
||||
{
|
||||
english = settings: website {
|
||||
@@ -26,22 +27,5 @@ in
|
||||
drafts = settings.drafts or false;
|
||||
src = blog-source;
|
||||
path = ".";
|
||||
extraFlags = "--config=config.toml,config-gen.toml";
|
||||
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";
|
||||
extraFlags = "";
|
||||
replaceUrl = {
|
||||
from = "https://ru.danilafe.com";
|
||||
to = wrapHost (settings.ssl or false) settings.host;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user