Mirror of my blog, powered by Hakyll and Haskell, hosted on GitHub Pages. https://blog.youwen.dev
Find a file
2024-11-01 06:07:13 +00:00
.github Merge 87c7f1f18d into 0aef4e7260 2024-11-01 06:07:13 +00:00
nix feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
src feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
ssg fix: explicitly set utf-8 encoding in haskell 2024-05-26 01:17:06 -07:00
.envrc add envrc 2024-05-23 23:14:08 -07:00
.ghci Initial commit 2024-05-22 22:17:41 -07:00
.gitignore feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
.prettierrc.toml feat: add theme switcher and themes 2024-05-24 21:55:11 -07:00
flake.lock Initial commit 2024-05-22 22:17:41 -07:00
flake.nix fix: remove node_modules symlink during buildPhase 2024-10-31 22:55:52 -07:00
LICENSE Initial commit 2024-05-22 22:17:41 -07:00
node_modules feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
package.json feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
README.md docs: update readme with new instructions 2024-10-31 22:51:28 -07:00
rollup.config.mjs feat: build site entirely in nix 2024-10-31 22:41:33 -07:00
tailwind.config.js feat: add font selector 2024-06-13 21:32:45 -07:00

gradient ascent - yet another developer blog

This repository hosts the source code for my blog, written in Haskell and powered by hakyll and pandoc. Builds are managed by nix.

This repo is merely the source code, the actual site is hosted at blog.youwen.dev.

To build locally, install nix and enable flakes. Additionally, install the direnv tool so that the provided binary utilities can be hooked into your shell. It is also possible to perform the following steps without direnv if you know what you are doing.

Allow the .envrc:

direnv allow

Wait for the build to finish. Now, you will have the rollup and hakyll-site binaries in your PATH.

We need to compile the site source code first, and then inject the bundled CSS and JS using rollup. This is done automatically by nix build, which is used for GitHub Pages deployment, but it is inconvenient for local development. Here's how to do it locally.

First, we need to build the site. Run

hakyll-site build

# sometimes, we need to ignore the cache if things aren't working
hakyll-site rebuild

# can also use `watch` for convenient development
hakyll-site watch
# starts dev server at localhost:8000

This will create ./dist, containing the static assets. However, the required CSS and JS is not in there yet! That is built by rollup, since we are using tailwindcss and postcss and some JS minifying tools.

First, we need the node_modules. We don't provide a package-lock.json since we don't use npm to manage node modules. Therefore, we need to obtain the node_modules used by the project.

In the directory, there is a node_modules symlink to result/lib/node_modules. If we build the nodeDeps package, the node_modules will be made available at this path. So, run the following:

nix build .#nodeDeps

This will install the node modules in the Nix store and create the result symlink. Keep in mind that if this result symlink is ever overwritten, you need to re-run the above command or else node_modules will not be accessible.

Finally, run the following to generate the bundled CSS and JS files.

rollup -c

You have to re-run this whenever you change the CSS and JS files in src/.

Keep in mind that if hakyll-site ever overwrites dist/out, you will also have to re-run this command.