-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
156 lines (140 loc) · 4.16 KB
/
flake.nix
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
description = "My blog";
nixConfig = {
extra-substituters = [
"https://cache.iog.io"
"https://aciceri-blog.cachix.org"
];
extra-trusted-public-keys = [
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"aciceri-blog.cachix.org-1:RsBUsFem/Lr0ItecDFfhmXvxvs3WRqVlCQlxNqRXgWw="
];
allow-import-from-derivation = "true";
};
inputs = {
flake-utils.url = "github:numtide/flake-utils";
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
katex = {
url = "https://github.com/KaTeX/KaTeX/releases/download/v0.16.0/katex.tar.gz";
flake = false;
};
latin-modern = {
url = "github:aaaakshat/cm-web-fonts";
flake = false;
};
fira-code = {
url = "https://github.com/tonsky/FiraCode/releases/download/6.2/Fira_Code_v6.2.zip";
type = "file";
flake = false;
};
hyphenopoly = {
url = "https://github.com/mnater/Hyphenopoly/archive/refs/tags/v4.12.0.zip";
flake = false;
};
asciinema = {
url = "https://registry.npmjs.org/asciinema-player/-/asciinema-player-3.0.1.tgz";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
haskellNix,
...
} @ inputs:
(flake-utils.lib.eachDefaultSystem (
system: let
overlays = [
haskellNix.overlay
(final: _: {
blogGeneratorProject = final.haskell-nix.project' {
src = ./generator;
compiler-nix-name = "ghc925";
shell.tools = {
cabal = {};
haskell-language-server = {};
};
};
})
];
pkgs = import nixpkgs {
inherit system overlays;
inherit (haskellNix) config;
};
flake = pkgs.blogGeneratorProject.flake {};
thirdpartyFarm = with inputs; let
fira-code-unzipped = pkgs.runCommand "extract-fira-code" {} ''
mkdir $out
cd $out
${pkgs.unzip}/bin/unzip ${fira-code};
'';
in
pkgs.linkFarm "thirdparty" [
{
name = "katex";
path = katex;
}
{
name = "latin-modern";
path = "${latin-modern}/font";
}
{
name = "firacode";
path = "${fira-code-unzipped}/woff2";
}
{
name = "hyphenopoly";
path = hyphenopoly;
}
{
name = "asciinema";
path = "${asciinema}/dist/bundle";
}
];
generator = flake.packages."blog:exe:generator".overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs or [] ++ [pkgs.makeWrapper];
installPhase =
old.installPhase
+ "\n"
+ ''
wrapProgram $out/bin/generator --set THIRDPARTY ${thirdpartyFarm}
'';
});
blog = pkgs.stdenv.mkDerivation {
name = "blog";
src = self; # TODO: use `builtins.filterSource`
buildInputs = [pkgs.git];
# The `sed` hack is necessary until we got https://github.com/jaspervdj/hakyll/issues/700
buildPhase = ''
sed -i '/^#+title.*/i ----' posts/*.org
sed -i '/^#+language.*/a ----' posts/*.org
sed -ri 's/\#\+(title|tags|date|language)\:/\1:/g' posts/*.org
mkdir -p generator/thirdparty/
ln -sfn ${thirdpartyFarm}/* generator/thirdparty/
${generator}/bin/generator build
'';
installPhase = ''
mkdir $out
cp -r out/* $out
'';
dontFixup = true;
};
in
nixpkgs.lib.recursiveUpdate flake {
packages = {
inherit generator thirdpartyFarm blog;
default = blog;
};
apps = {
default = flake-utils.lib.mkApp {
drv = generator;
exePath = "/bin/generator";
};
};
}
)) // {
herculesCI.ciSystems = [ "x86_64-linux" ];
};
}