Skip to content

Commit 1da4e62

Browse files
committed
Change from stack to nix
1 parent b9fa4bf commit 1da4e62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+166
-43
lines changed

README.org

Lines changed: 1 addition & 13 deletions

deploy

Lines changed: 0 additions & 7 deletions
This file was deleted.

deploy.bat

Lines changed: 0 additions & 8 deletions
This file was deleted.

flake.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
description = "hakyll-nix-template";
3+
4+
nixConfig.bash-prompt = "[nix]λ ";
5+
6+
inputs = {
7+
nixpkgs.url = "nixpkgs/nixos-21.05";
8+
9+
flake-utils = {
10+
url = "github:numtide/flake-utils";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
};
13+
};
14+
15+
outputs = { flake-utils, nixpkgs, self }:
16+
flake-utils.lib.eachDefaultSystem (system:
17+
let
18+
config = {};
19+
overlays = [ (import ./haskell-overlay.nix) ];
20+
pkgs = import nixpkgs { inherit config overlays system; };
21+
in rec {
22+
defaultPackage = packages.website;
23+
defaultApp = apps.hakyll-site;
24+
25+
packages = with pkgs.myHaskellPackages; { inherit ssg website; };
26+
27+
apps.hakyll-site = flake-utils.lib.mkApp {
28+
drv = packages.ssg;
29+
exePath = "/bin/hakyll-site";
30+
};
31+
32+
devShell = pkgs.myHaskellPackages.shellFor {
33+
packages = p: [ p.ssg ];
34+
35+
buildInputs = with pkgs.myHaskellPackages; [
36+
ssg
37+
38+
# Helpful tools for `nix develop` shells
39+
#
40+
#ghcid # https://github.com/ndmitchell/ghcid
41+
#haskell-language-server # https://github.com/haskell/haskell-language-server
42+
#hlint # https://github.com/ndmitchell/hlint
43+
#ormolu # https://github.com/tweag/ormolu
44+
];
45+
46+
withHoogle = true;
47+
};
48+
}
49+
);
50+
}

haskell-overlay.nix

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
final: prev:
2+
let
3+
inherit (prev.stdenv) mkDerivation;
4+
inherit (prev.lib.trivial) flip pipe;
5+
inherit (prev.haskell.lib)
6+
appendPatch
7+
appendConfigureFlags
8+
dontCheck
9+
doJailbreak;
10+
11+
withPatch = flip appendPatch;
12+
withFlags = flip appendConfigureFlags;
13+
14+
haskellCompiler = "ghc884";
15+
in {
16+
myHaskellPackages = prev.haskell.packages.${haskellCompiler}.override {
17+
overrides = hpFinal: hpPrev:
18+
let
19+
hakyll-src = hpPrev.callHackage "hakyll" "4.14.0.0" {};
20+
pandoc-src = hpPrev.callHackage "pandoc" "2.11.4" {}; # version specified by hayll 4.14.0.0
21+
slugger-src = hpPrev.callHackageDirect {
22+
pkg = "slugger";
23+
ver = "0.1.0.1";
24+
sha256 = "sha256-ggeo5TcbI4UlK/CtG4878USX9Cm7Faz16phdjlDOGaI=";
25+
} {}; # not available yet because it's so new
26+
in rec {
27+
hakyll = pipe hakyll-src [
28+
doJailbreak
29+
dontCheck
30+
(withPatch ./hakyll.patch)
31+
(withFlags [ "-f" "watchServer" "-f" "previewServer" ])
32+
];
33+
34+
pandoc = pipe pandoc-src [
35+
doJailbreak
36+
dontCheck
37+
];
38+
39+
slugger = slugger-src;
40+
41+
ssg = hpPrev.callCabal2nix "ssg" ./ssg {};
42+
43+
website = prev.stdenv.mkDerivation {
44+
#__contentAddressed = true; # uncomment if using cas: https://www.tweag.io/blog/2020-09-10-nix-cas/
45+
name = "website";
46+
buildInputs = [ ssg ];
47+
src = prev.nix-gitignore.gitignoreSourcePure [
48+
./.gitignore
49+
".git"
50+
".github"
51+
] ./.;
52+
53+
# LANG and LOCALE_ARCHIVE are fixes pulled from the community:
54+
# https://github.com/jaspervdj/hakyll/issues/614#issuecomment-411520691
55+
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
56+
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
57+
LANG = "en_US.UTF-8";
58+
LOCALE_ARCHIVE = prev.lib.optionalString
59+
(prev.buildPlatform.libc == "glibc")
60+
"${prev.glibcLocales}/lib/locale/locale-archive";
61+
62+
buildPhase = ''
63+
hakyll-site build --verbose
64+
'';
65+
66+
installPhase = ''
67+
mkdir -p "$out/dist"
68+
cp -r dist/* "$out/dist"
69+
'';
70+
};
71+
};
72+
};
73+
}

rundev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
nix run . clean && nix run . watch

CNAME renamed to src/CNAME

File renamed without changes.

src/_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: []
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow:
File renamed without changes.
File renamed without changes.

site.hs renamed to ssg/src/Main.hs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@ main :: IO ()
1414
main = do
1515
E.setLocaleEncoding E.utf8
1616
hakyllWith config $ do
17-
match "images/*" $ do
18-
route idRoute
19-
compile copyFileCompiler
20-
21-
match "exercises/*" $ do
22-
route idRoute
23-
compile copyFileCompiler
17+
forM_
18+
[ "CNAME"
19+
, "favicon.ico"
20+
, "robots.txt"
21+
, "_config.yml"
22+
, "images/*"
23+
, "js/*"
24+
, "fonts/*"
25+
, "exercises/*"
26+
]
27+
$ \f -> match f $ do
28+
route idRoute
29+
compile copyFileCompiler
2430

2531
match "css/*" $ do
2632
route idRoute
2733
compile compressCssCompiler
2834

29-
match (fromList ["CNAME"]) $ do
30-
route idRoute
31-
compile copyFileCompiler
32-
3335
match (fromList ["preface.org"]) $ do
3436
route $ (gsubRoute "preface.org" (const "index")) `composeRoutes` (setExtension "html")
3537
compile $ do
@@ -68,7 +70,12 @@ main = do
6870
--------------------------------------------------------------------------------
6971
config :: Configuration
7072
config = defaultConfiguration
71-
{ destinationDirectory = "docs"
73+
{ destinationDirectory = "dist"
74+
, previewHost = "127.0.0.1"
75+
, previewPort = 8000
76+
, providerDirectory = "src"
77+
, storeDirectory = "ssg/_cache"
78+
, tmpDirectory = "ssg/_tmp"
7279
}
7380

7481
withTOC :: Pandoc.WriterOptions

ssg/ssg.cabal

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cabal-version: 2.4
2+
3+
name: ssg
4+
version: 0.1.0.0
5+
build-type: Simple
6+
license: BSD-3-Clause
7+
license-file: LICENSE
8+
9+
executable hakyll-site
10+
main-is: Main.hs
11+
hs-source-dirs: src
12+
build-depends: base >= 4.8
13+
, hakyll >= 4.14
14+
, pandoc == 2.11.*
15+
, slugger >= 0.1.0.1
16+
, text >= 1.2
17+
ghc-options: -Wall -threaded
18+
default-language: Haskell2010

watch

Lines changed: 0 additions & 2 deletions
This file was deleted.

watch.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)