blog-static-flake/lib.nix

46 lines
1.1 KiB
Nix
Raw Permalink Normal View History

{ pkgs, blog-source, web-files, katex-html, resume }:
2021-10-21 23:00:13 -07:00
with pkgs;
with lib;
2020-04-06 16:51:17 -07:00
let
protocol = ssl: if ssl then "https://" else "http://";
2020-09-02 17:25:52 -07:00
website = settings: stdenv.mkDerivation {
2021-10-23 00:51:13 -07:00
inherit (settings) src ssl host;
2023-02-19 21:49:59 -08:00
inherit resume;
2020-09-02 17:25:52 -07:00
name = "blog-static";
version = settings.src.rev or "dirty";
2020-09-02 17:25:52 -07:00
publicPath = settings.path;
hugoFlags = concatStringsSep " " (
2023-04-10 19:54:30 -07:00
optionals settings.drafts (singleton "-D") ++
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
);
builder = ./build/builder.sh;
webFiles = web-files;
buildInputs = [
hugo ruby stork katex-html
];
2020-09-02 17:25:52 -07:00
};
2020-09-02 17:03:02 -07:00
in
2021-10-23 00:33:22 -07:00
{
english = settings: website {
2021-10-23 00:51:13 -07:00
inherit (settings) host;
ssl = settings.ssl or false;
2021-10-23 00:33:22 -07:00
drafts = settings.drafts or false;
2021-10-23 00:51:13 -07:00
src = blog-source;
2020-09-02 17:25:52 -07:00
path = ".";
};
virtualHostFor = package:
{
"${package.host}" = mkMerge [
{
root = package;
}
(mkIf (package.ssl) {
forceSSL = true;
enableACME = true;
})
];
};
2021-10-23 00:33:22 -07:00
}