Run bash ./build.sh.
2ZULESGU4H6GRQUHINYMYXW2FR33QNNA5OWBCCRAD26CX7WHT57QC
RWZ457JG7GN4JJKPRNLB22OHOGYSKR756OQUWLJDAEXRCHFBK42AC
CITWHSGYZUZTEAS2OR566P67LCIOGQ5LDNCZNNF7PV567U5QR5BAC
JGMCSDW663DQSK7XSWDBPVYQE57ZBP7ZVZLSEXUJOQVE7KY6BB4QC
YW6L24ISNOHNZWFUPTUGCKGAGGOQO2H5IYZARK6ST35VGLVXUYDAC
FQIAPE35VPZEZSCZO6PN6VJSXLB5TBZNGDXRIWJSS5MS2TJHK6MAC
J3MQ32QO5ECHTE6US7KZF37CC3PVKIGFYV6WAFP5RCCNOBEG6E6AC
5FGYXNYOVPFR3WMOQTQTGM5FR3O22RABREDIZ6K3EYU266VJ276AC
BE2K3MCTTASVRK2KXWMKUA6JNI27EMX6EM3TU35FF777Z2KJCSSQC
MG6QNY2AZM3YPWL2PTIQ6NNWFFO6BRKWL3MLYJOSOAMNW6HELHEQC
GVZHJUHQDTV5P2U5YHHQRDGP3Y7FE6337OIKLGXN2PJETJP5NKQQC
QZSQEAJE6R2V5ABFIHYBTSDPEY2OW7RN5SQ7QXTVKB4T6PESENZQC
RHWQQAAHNHFO3FLCGVB3SIDKNOUFJGZTDNN57IQVBMXXCWX74MKAC
DZ6GQN2ERJAZG3PWZC34EN32YZOAPVFNGVCMJQNMFZVK4TR57UTAC
DLJPWVRPZ5E4TC7IXF4DBPN3KQZCC4F5GBT222Q4W4FAJSAIHBFQC
H6SY4TCOYCGKYC77SWG4EUEW225SPJT4JGG4YEM2Z4JI2WHWVPYAC
ACCYRHVSXL6HQPJEPV7ORGYKEQTCG5B2M3DPJ5DBTWMW4CS3ZTWAC
watch:
cabal run hakyll-site watch
rebuild:
# z option is important to avoid re-uploading everything
# it must be at the beginning
# We need a wilcard to avoid an html folder
ncftpput -z -f login.cfg -R . _site/*
ncftpput -z -f login.cfg -R . files/*
dist: hut #free
hut:
cd _site ; tar cvzf site.tar.gz * ; hut pages publish site.tar.gz -d scut.srht.site
free:
cabal build
build:
cabal run hakyll-site build
all: build dist
#!/bin/sh
mkdir -p _shake
ghc --make Shakefile.hs -rtsopts -threaded -with-rtsopts=-I0 -outputdir=_shake -o _shake/build && _shake/build "$@"
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
siteExe :: String
siteExe = "_build/hakyll-site"
-- This only works in Gentoo with packages installed globally
-- TODO: add a switch to use cabal (cabal build and cabal run) outside gentoo
-- Note: nix-build fails with some encoding issues (hGetConts).
-- Nix flakes builds several GHC version...
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles="_build"} $ do
want [siteExe , "_site/index.html", "hut"]
siteExe %> \out -> do
let src = ["src/Main.hs"]
need src
cmd_ "ghc --make -o" [out] src
-- Shake cannot use directories
"_site/index.html" %> \out -> do
cmd_ siteExe "build"
phony "clean" $ do
putInfo "Cleaning site "
cmd_ siteExe "clean"
putInfo "Cleaning files in _build"
removeFilesAfter "_build" ["//*"]
phony "hut" $ do
putInfo "Upload to blog hosted by sourcehut"
need ["_build/site.tar.gz"]
cmd_ "hut pages publish _build/site.tar.gz -d scut.srht.site"
"_build/site.tar.gz" %> \out -> do
cmd_ "tar cvzf " [out] "-C _site ."
-- z option is important to avoid re-uploading everything
phony "free" $ do
putInfo "Upload to blog hosted by Free"
cmd_ "ncftpput -z -f login.cfg -R . _site/*"
cmd_ "ncftpput -z -f login.cfg -R . files/*"
phony "watch" $ do
putInfo "Generate site locally"
cmd_ "_build/hakyll-site watch"
# hakyll-nix-template
[Hakyll](https://jaspervdj.be/hakyll/) + [Nix](https://nixos.org) template
## Quick tips
* Read the tutorial to get started! https://robertwpearce.com/the-hakyll-nix-template-tutorial.html
* If you make changes to anything inside of `ssg/`, you'll need to clean the
hakyll cache and rebuild. This is the preferred series of commands for
rebuilding (with logs), cleaning the cache, and re-running the dev server:
```default
nix build --print-build-logs && \
nix run . clean && \
nix run . watch
```
## Features
* Build your site into the `./result/dist` folder:
```
λ nix build
```
* Start hakyll's dev server that reloads when changes are made:
```
λ nix run . watch
Listening on http://127.0.0.1:8000
...more logs
```
* Run any hakyll command through `nix run .`!
```
λ nix run . clean
Removing dist...
Removing ssg/_cache...
Removing ssg/_tmp...
```
* Start a development environment that
* has your shell environment
* has `hakyll-site` (for building/watching/cleaning hakyll projects)
* has `hakyll-init` (for generating new projects)
* can have anything else you put in the `shell.buildInputs` of the
`hakyllProject` in `flake.nix`
* is set up to run `ghci` with some defaults and the modules loaded so you can
make your own changes and test them out in the ghci REPL
```
λ nix develop
[hakyll-nix]λ hakyll-site build
...
Success
[hakyll-nix]λ ghci
...
[1 of 1] Compiling Main ( ssg/src/Main.hs, interpreted )
...
λ >
```
### hakyll
All of this is custmomizable, and here are some things that are already done for
you:
* [pandoc](https://github.com/jgm/pandoc/) markdown customization to make it as
close to GitHub's markdown style as possible
* [`slugger`](https://hackage.haskell.org/package/slugger) module is included that makes nice link URIs based on post titles
* RSS & Atom XML feed generation
* Sitemap generation
* Code syntax highlighting customization
* ...other reasonable defaults
Configure the dev server, cache & tmp directories, and more in
`./ssg/src/Main.hs`.
### Deployment
Deployment is set up through a [GitHub
Action](https://github.com/features/actions) with [cachix](https://cachix.org),
and it deploys to a [GitHub Pages](https://pages.github.com/) branch,
`gh-pages`, when you merge code into your main branch.
Setup information can be found below in the "Cachix" section.
Note: If your main branch's name isn't `main`, ensure `'refs/heads/main'` gets
updated to `'refs/heads/my-main-branch'` in `./github/workflows/main.yml`.
## Setup
### Nix & Flakes
If you don't have [nix](https://nixos.org), follow [the nix installation
instructions](https://nixos.org/download.html).
Once you have nix installed, follow the instructions here to get access to
flakes: https://nixos.wiki/wiki/Flakes.
### Cachix
1. Create a cache on cachix for your project
1. Follow cachix's instructions to generate a signing keypair
1. Copy the signing keypair value to a new `CACHIX_SIGNING_KEY` secret on
https://github.com/settings/secrets
_shake/build watch
Note: assume Haskell packages have been installed locally