From ee116b138fc68c71744eff91e0c9ce0106268531 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 23 May 2024 07:37:52 +0000 Subject: [PATCH] Add building and linking Agda as build step Signed-off-by: Danila Fedorin --- build/builder.sh | 10 +++++++++- flake.lock | 8 ++++---- gemset.nix | 33 +++++++++++++++++++++++++++++++++ lib.nix | 13 +++++++++++-- 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 gemset.nix diff --git a/build/builder.sh b/build/builder.sh index 2d875ce..27f37f8 100644 --- a/build/builder.sh +++ b/build/builder.sh @@ -25,6 +25,12 @@ cp -r $webFiles/* static/ # Build site with Hugo hugo $hugoFlags --config=config.toml,config-urls.toml +# Run Agda to generate HTML files for all Agda projects +# Agda will write interface files, so make .code/ writable +chmod -R u+w code +agdaCommand="agda -l standard-library -i . " +ruby ./build-agda-html.rb "$agdaCommand" + # Create generated files # Can't do submodules because nix flake inputs get their .git deleted mkdir -p static/graph && ruby ./analyze.rb > static/graph/graph.gen.js # Graph files @@ -39,4 +45,6 @@ mkdir $out cp -r public/$publicPath/* $out/ # Render math in HTML and XML files. -find $out/ -regex "$out/.*\.html" | xargs katex-html +htmlfiles=$(find $out/ -regex "$out/.*\.html") +echo $htmlfiles | xargs katex-html +echo $htmlfiles | xargs ${gems}/bin/bundle exec ${ruby}/bin/ruby ./agda.rb diff --git a/flake.lock b/flake.lock index 6ea315a..1db6516 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ "blog-source": { "flake": false, "locked": { - "lastModified": 1716424472, - "narHash": "sha256-qutuqf3NvqnRGj7A0fbeQBUzapRithWBpsZPr9oNC00=", + "lastModified": 1716449496, + "narHash": "sha256-8Mt9X3rg17QNljfy7qwqPal/DooqTBx7R+UNm10xRb8=", "ref": "refs/heads/master", - "rev": "54844fb954d6ef5b397db4c4b2b9f07bce56d73d", - "revCount": 766, + "rev": "c027efa931b7a248b138467f4c7415d27f02a654", + "revCount": 775, "submodules": true, "type": "git", "url": "https://dev.danilafe.com/Web-Projects/blog-static.git" diff --git a/gemset.nix b/gemset.nix new file mode 100644 index 0000000..d7dcef5 --- /dev/null +++ b/gemset.nix @@ -0,0 +1,33 @@ +{ + mini_portile2 = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "149r94xi6b3jbp6bv72f8383b95ndn0p5sxnq11gs1j9jadv0ajf"; + type = "gem"; + }; + version = "2.8.6"; + }; + nokogiri = { + dependencies = ["mini_portile2" "racc"]; + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "023f2j0q8makgmmfj4pv2fhwgcbh9y8s678za1cb68ry9fdpkkkh"; + type = "gem"; + }; + version = "1.15.6"; + }; + racc = { + groups = ["default"]; + platforms = []; + source = { + remotes = ["https://rubygems.org"]; + sha256 = "021s7maw0c4d9a6s07vbmllrzqsj2sgmrwimlh8ffkvwqdjrld09"; + type = "gem"; + }; + version = "1.8.0"; + }; +} diff --git a/lib.nix b/lib.nix index 83dc1da..28ce1bd 100644 --- a/lib.nix +++ b/lib.nix @@ -5,9 +5,18 @@ with lib; let protocol = ssl: if ssl then "https://" else "http://"; + gems = bundlerEnv { + inherit ruby; + + name = "blog-static-flake"; + gemfile = "${blog-source}/Gemfile"; + lockfile = "${blog-source}/Gemfile.lock"; + gemset = ./gemset.nix; + }; + website = settings: stdenv.mkDerivation { inherit (settings) src ssl host; - inherit resume; + inherit resume gems ruby; name = "blog-static"; version = settings.src.rev or "dirty"; publicPath = settings.path; @@ -18,7 +27,7 @@ let builder = ./build/builder.sh; webFiles = web-files; buildInputs = [ - hugo ruby stork katex-html + hugo ruby stork katex-html (agda.withPackages [ agdaPackages.standard-library ]) ]; }; in