blob: 414e2332a8cf30a17669ce9f323fc50f1c09accb (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
let
pkgsUnstable = import <nixpkgs> { };
pkgsPinned = import (pkgsUnstable.fetchzip {
url = "https://github.com/NixOS/nixpkgs/archive/18.03.zip";
sha256 = "0hk4y2vkgm1qadpsm4b0q1vxq889jhxzjx3ragybrlwwg54mzp4f";
}) { };
pkgs = pkgsUnstable;
# Taken from:
# http://www.cs.yale.edu/homes/lucas.paul/posts/2017-04-10-hakyll-on-nix.html
websiteBuilder = pkgs.stdenv.mkDerivation {
name = "website-builder";
src = ./hakyll;
phases = "unpackPhase buildPhase";
buildInputs =
[ (pkgsPinned.haskellPackages.ghcWithPackages (p: [ p.hakyll ])) ];
buildPhase = ''
mkdir -p $out/bin
ghc -O2 -dynamic --make Main.hs -o $out/bin/build-site
'';
};
in rec {
utils = import ./utils.nix {
pkgs = pkgs;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
baseName = "website";
};
subtasks = rec {
perlPodCheck = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-perl-podcheck";
buildInputs = baseAttrs.buildInputs ++ [ pkgs.perl ];
buildPhase = ''
podchecker website pastebin/website-pastebin slides/website-slides
touch $out
'';
});
batsTest = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-bats-test";
buildInputs = baseAttrs.buildInputs ++ [ pkgs.bats pkgs.perl ];
buildPhase = ''
patchShebangs .
./t/website.bats
touch $out
'';
});
perlInternalTest = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-perl-test";
buildInputs = baseAttrs.buildInputs ++ [ pkgs.perl ];
buildPhase = ''
patchShebangs .
./website test
touch $out
'';
});
hunspellCheck = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-hunspell";
buildInputs = baseAttrs.buildInputs
++ [ (pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ])) ];
buildPhase = ''
patchShebangs .
./spelling/check-spelling.sh "${subtasks.docs}"
touch $out
'';
});
docs = utils.baseTask.overrideAttrs (baseAttrs: {
name = "${baseAttrs.name}-docs";
src = ./site;
buildInputs = [ websiteBuilder ];
buildPhase = ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive";
export LANG=en_US.UTF-8
build-site build
mkdir $out
cp -r _site/* $out
'';
});
};
test = utils.test [
utils.formatNix
(utils.shellcheck null)
(utils.fixme [ "pastebin/skeleton.org" "utils.nix" ])
subtasks.perlPodCheck
subtasks.batsTest
subtasks.perlInternalTest
subtasks.hunspellCheck
];
shell = pkgs.mkShell rec {
name = "website-shell";
buildInputs = [
websiteBuilder
(pkgs.haskellPackages.ghcWithPackages (p: with p; [ hakyll ]))
(pkgs.hunspellWithDicts (with pkgs.hunspellDicts; [ en-us ]))
];
};
publishScript = utils.overwritingPublishScript {
docsDerivation = subtasks.docs;
overwrite = false;
};
}
|