2024-05-23 21:23:25 -07:00
|
|
|
{ pkgs, blog-source, web-files, resume }:
|
2021-10-21 23:00:13 -07:00
|
|
|
|
|
|
|
with pkgs;
|
2022-12-30 15:41:50 -08:00
|
|
|
with lib;
|
2020-04-06 16:51:17 -07:00
|
|
|
|
|
|
|
let
|
2022-12-30 15:41:50 -08:00
|
|
|
protocol = ssl: if ssl then "https://" else "http://";
|
2024-05-24 13:33:34 -07:00
|
|
|
gems = settings: bundlerEnv {
|
2024-05-23 00:37:52 -07:00
|
|
|
inherit ruby;
|
|
|
|
|
|
|
|
name = "blog-static-flake";
|
2024-05-24 13:33:34 -07:00
|
|
|
gemfile = "${settings.src}/Gemfile";
|
|
|
|
lockfile = "${settings.src}/Gemfile.lock";
|
2024-05-23 00:37:52 -07:00
|
|
|
gemset = ./gemset.nix;
|
|
|
|
};
|
|
|
|
|
2024-05-24 13:33:34 -07:00
|
|
|
# --- Building Agda HTML ---
|
|
|
|
agdaEnv = agda.withPackages [ agdaPackages.standard-library ];
|
|
|
|
agdaHtml = settings:
|
|
|
|
let
|
|
|
|
# Create content-addresed versions of the scripts in the Nix store to
|
|
|
|
# avoid throwing off memoization for unrelated changes.
|
|
|
|
agdaBuildScript = builtins.toFile "build-agda-html.rb" (builtins.readFile "${settings.src}/build-agda-html.rb");
|
|
|
|
submoduleDataFile = builtins.toFile "submodules.json" (builtins.readFile "${settings.src}/data/submodules.json");
|
|
|
|
codeRoot = pkgs.lib.cleanSource "${settings.src}/code";
|
|
|
|
agdaCommand = pkgs.lib.escapeShellArg "agda -l standard-library -i . ";
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "blog-static-agda-html";
|
|
|
|
version = settings.src.rev or "dirty";
|
|
|
|
buildInputs = [ ruby agdaEnv ];
|
|
|
|
builder = builtins.toFile "builder.sh" "
|
|
|
|
source $stdenv/setup
|
|
|
|
mkdir -p code $out
|
|
|
|
cp -r ${codeRoot}/* code/
|
|
|
|
chmod -R u+w code
|
|
|
|
ruby ${agdaBuildScript} --data-file=${submoduleDataFile} --target-dir=$out ${agdaCommand}
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
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;
|
2024-05-24 13:33:34 -07:00
|
|
|
inherit resume ruby;
|
2020-09-02 17:25:52 -07:00
|
|
|
name = "blog-static";
|
2022-12-30 15:41:50 -08:00
|
|
|
version = settings.src.rev or "dirty";
|
2020-09-02 17:25:52 -07:00
|
|
|
publicPath = settings.path;
|
2022-12-30 15:41:50 -08:00
|
|
|
hugoFlags = concatStringsSep " " (
|
2023-04-10 19:54:30 -07:00
|
|
|
optionals settings.drafts (singleton "-D") ++
|
|
|
|
[ "--baseURL=${protocol settings.ssl + settings.host}" ]
|
2022-12-30 15:41:50 -08:00
|
|
|
);
|
2021-10-21 22:39:25 -07:00
|
|
|
builder = ./build/builder.sh;
|
2023-11-29 23:09:28 -08:00
|
|
|
webFiles = web-files;
|
2024-05-24 13:33:34 -07:00
|
|
|
gems = gems settings;
|
|
|
|
agdaHtml = agdaHtml settings;
|
2020-12-14 19:16:27 -08:00
|
|
|
buildInputs = [
|
2024-05-24 13:33:34 -07:00
|
|
|
hugo ruby stork agdaEnv
|
2020-12-14 19:16:27 -08:00
|
|
|
];
|
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
|
|
|
{
|
2021-10-23 00:27:43 -07:00
|
|
|
english = settings: website {
|
2021-10-23 00:51:13 -07:00
|
|
|
inherit (settings) host;
|
2021-10-23 00:27:43 -07:00
|
|
|
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 = ".";
|
|
|
|
};
|
2023-04-10 19:53:15 -07:00
|
|
|
virtualHostFor = package:
|
|
|
|
{
|
|
|
|
"${package.host}" = mkMerge [
|
|
|
|
{
|
|
|
|
root = package;
|
|
|
|
}
|
|
|
|
(mkIf (package.ssl) {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2021-10-23 00:33:22 -07:00
|
|
|
}
|