about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-28 16:26:48 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-28 16:26:48 +0700
commitc111dacfdef7624bef023341b6f3a0b88b830ab3 (patch)
treee917cd7137d3385aa05e28a36b0936767152e507
parentf3add2dab78a997832db3cc63632ab2c5b2e2666 (diff)
downloadsite-c111dacfdef7624bef023341b6f3a0b88b830ab3.tar.gz
Use nix-shell
-rw-r--r--.build.yml13
-rw-r--r--config.md2
-rw-r--r--shell.nix12
3 files changed, 14 insertions, 13 deletions
diff --git a/.build.yml b/.build.yml
index 9884adf..80bd57b 100644
--- a/.build.yml
+++ b/.build.yml
@@ -2,24 +2,13 @@ image: nixos/unstable
 oauth: lists.sr.ht/EMAILS:RO pages.sr.ht/PAGES:RW
 packages:
   - nixos.jq
-  - nixos.julia-bin
-  - nixos.nodejs
-  - nixos.nodePackages.katex
   - nixos.openring
-  - nixos.python3
-  - nixos.python3Packages.bleach
-  - nixos.python3Packages.css-html-js-minify
-  - nixos.python3Packages.markdown
 sources:
   - https://git.sr.ht/~cnx/site
 environment:
   NODE: node
 tasks:
   - inject: |
-      npm install highlight.js
-      katex=$(nix-shell '<nixpkgs>' -A nodePackages.katex --run 'echo $out')
-      ln -s $katex/lib/node_modules/katex/dist site/_libs/katex
-      cp -r site/_libs/katex/{fonts,katex.min.css} site/_css
       curl https://fediring.net/ring.json |
         jq -r 'map(.host)|until(.[0]=="cnx.srht.site";.[1:]+.[:1])|.[-1,1]'\
         > site/_libs/fediring
@@ -28,7 +17,7 @@ tasks:
       acurl https://lists.sr.ht/query/list/5261.mbox -o site/_libs/formbox/mbox
   - build: |
       cd site
-      julia --project=@. .build.jl
+      nix-shell --run 'julia --project=@. .build.jl'
       rm -r __site/libs
   - deploy: |
       tar -cvzf site.tar.gz -C site/__site .
diff --git a/config.md b/config.md
index bd86517..077fcfb 100644
--- a/config.md
+++ b/config.md
@@ -8,7 +8,7 @@ date_format = "yyyy-mm-dd"
 mintoclevel = 2
 generate_rss = true
 ignore = [".build.jl", ".build.yml", "Manifest.toml", "Project.toml",
-          "node_modules/", "package-lock.json"]
+          "node_modules/", "package-lock.json", "shell.nix"]
 +++
 
 \newcommand{\R}{\mathbb R}
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..50d4e3e
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,12 @@
+with import <nixpkgs> {};
+mkShell {
+  nativeBuildInputs = [
+    julia-bin nodejs nodePackages.katex python3
+  ] ++ (with python3Packages; [ bleach css-html-js-minify markdown ]);
+
+  shellHook = ''
+    npm install highlight.js # https://github.com/NixOS/nixpkgs/issues/152201
+    ln -fns ${nodePackages.katex}/lib/node_modules/katex/dist _libs/katex
+    ln -fs _libs/katex/{fonts,katex.min.css} _css
+  '';
+}