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J3MQ32QO5ECHTE6US7KZF37CC3PVKIGFYV6WAFP5RCCNOBEG6E6AC
T6Z32P5ICWE36YHPK6NLH23JBHKKF777L3M27SNDHM46NTUOGQ3AC
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1664029467,
"narHash": "sha256-ir7JbsLp2mqseCs3qI+Z/pkt+Gh+GfANbYcI5I+Gvnk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "893b6b9f6c4ed0c7efdb84bd300a499a2da9fa51",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-22.05",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
{
description = "hakyll-nix-template";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
};
outputs = { flake-utils, nixpkgs, self }:
flake-utils.lib.eachDefaultSystem (system:
let
config = {};
overlays = [ (import ./haskell-overlay.nix) ];
pkgs = import nixpkgs { inherit config overlays system; };
in rec {
packages = with pkgs.myHaskellPackages; { inherit blog blog-nix; };
defaultPackage = packages.blog-nix;
apps.default = flake-utils.lib.mkApp {
drv = packages.blog;
exePath = "/bin/hakyll-site";
};
devShell = pkgs.myHaskellPackages.shellFor {
packages = p: [ p.blog ];
buildInputs = with pkgs.myHaskellPackages; [
blog
# Helpful tools for `nix develop` shells
#ghcid # https://github.com/ndmitchell/ghcid
#haskell-language-server # https://github.com/haskell/haskell-language-server
# hlint # https://github.com/ndmitchell/hlint
#ormolu # https://github.com/tweag/ormolu
];
};
}
);
}
flake-utils.url = "github:numtide/flake-utils";
-- Don't forget to set the path to temporary files
match "genetique.html" $ do
route idRoute
compile $ do
posts <- loadAll "genetique/*.org"
let indexCtx = listField "notes" defaultContext (return posts)
`mappend` defaultContext
-- -- Don't forget to set the path to temporary files
-- match "genetique.html" $ do
-- route idRoute
-- compile $ do
-- posts <- loadAll "../genetique/*.org"
-- let indexCtx = listField "notes" defaultContext (return posts)
-- `mappend` defaultContext
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" indexCtx
>>= relativizeUrls
-- getResourceBody
-- >>= applyAsTemplate indexCtx
-- >>= loadAndApplyTemplate "templates/default.html" indexCtx
-- >>= relativizeUrls
A blog with [Hakyll](https://jaspervdj.be/hakyll/) + [Nix](https://nixos.org), with the template from [rpearce template](https://github.com/rpearce/hakyll-nix-template).
# 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
# How to use it
* [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
Make it local :
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.
# Structure
- [](blog) contains the rules for Hakyll to generate the static content
- [](posts) contains a list of post in org-mode. Blog posts need a date in their title !
- Nix configuration :
- [](flake.nix) : create an application to run the blog
- [](haskell-overlay.nix) : define a derivation to build the blog
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
The `./.github/workflows/main.yml` file builds with help from
[cachix](https://app.cachix.org), so you'll need to generate a signing key to be
able to do this.
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
# Rebuild must be done twice due to a limitation of Hakyll with org metadata (see code)
local:
nix run . rebuild
nix run . rebuild
# # Rebuild must be done twice due to a limitation of Hakyll with org metadata (see code)
# local:
# nix run . rebuild
# nix run . 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
dist:
ncftpput -z -f login.cfg -R . _site/*
# # z option is important to avoid re-uploading everything
# # it must be at the beginning
# # We need a wilcard to avoid an html folder
# dist:
# ncftpput -z -f login.cfg -R . _site/*
BSD 3-Clause License
Copyright (c) 2020, Robert Pearce
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.