Factor out building Agda HTML from building the blog
This saves a lot of time since typechecking Agda is slow. Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
36
lib.nix
36
lib.nix
@@ -5,18 +5,42 @@ with lib;
|
||||
|
||||
let
|
||||
protocol = ssl: if ssl then "https://" else "http://";
|
||||
gems = bundlerEnv {
|
||||
gems = settings: bundlerEnv {
|
||||
inherit ruby;
|
||||
|
||||
name = "blog-static-flake";
|
||||
gemfile = "${blog-source}/Gemfile";
|
||||
lockfile = "${blog-source}/Gemfile.lock";
|
||||
gemfile = "${settings.src}/Gemfile";
|
||||
lockfile = "${settings.src}/Gemfile.lock";
|
||||
gemset = ./gemset.nix;
|
||||
};
|
||||
|
||||
# --- 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}
|
||||
";
|
||||
};
|
||||
|
||||
website = settings: stdenv.mkDerivation {
|
||||
inherit (settings) src ssl host;
|
||||
inherit resume gems ruby;
|
||||
inherit resume ruby;
|
||||
name = "blog-static";
|
||||
version = settings.src.rev or "dirty";
|
||||
publicPath = settings.path;
|
||||
@@ -26,8 +50,10 @@ let
|
||||
);
|
||||
builder = ./build/builder.sh;
|
||||
webFiles = web-files;
|
||||
gems = gems settings;
|
||||
agdaHtml = agdaHtml settings;
|
||||
buildInputs = [
|
||||
hugo ruby stork (agda.withPackages [ agdaPackages.standard-library ])
|
||||
hugo ruby stork agdaEnv
|
||||
];
|
||||
};
|
||||
in
|
||||
|
||||
Reference in New Issue
Block a user