-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.nix
134 lines (117 loc) · 3.41 KB
/
site.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
{
styx,
styxLib ? import styx.lib styx,
extraConf ? {},
pkgs
} @ args:
rec {
inherit (
let
themes = with (import styx.themes { inherit pkgs; }); [
generic-templates
ghostwriter
themes/dermetfan
];
in
styxLib.themes.load {
inherit styxLib themes;
extraEnv = { inherit data pages pkgs; };
extraConf = [ ./conf.nix extraConf ];
}
) conf lib files templates env;
data = with lib; {
about = loadFile {
file = ./data/pages/about.md;
inherit env;
};
posts = sortBy "date" "dsc" (loadDir {
dir = ./data/posts;
inherit env;
});
tags = mkTaxonomyData {
data = pages.posts.list;
taxonomies = [ "tags" ];
};
menu = with pages; [
(lib.head index)
{
title = "Tags";
path = lib.mkTaxonomyPath "tags";
}
about
];
author = {
name = "dermetfan";
url = conf.siteUrl;
};
};
pages = with lib; rec {
index = mkSplit {
title = "Home";
basePath = "/index";
itemsPerPage = conf.theme.itemsPerPage;
template = templates.index;
data = posts.list;
};
feed = {
path = "/feed.xml";
template = templates.feed.atom;
layout = id;
items = take conf.theme.itemsPerPage posts.list;
};
about = {
path = "/about/index.html";
template = templates.page.full;
} // data.about;
posts = mkPageList {
data = data.posts;
pathPrefix = "/posts/";
template = templates.post.full;
author = data.author;
};
tags = mkTaxonomyPages {
data = data.tags;
taxonomyTemplate = templates.taxonomy.full;
termTemplate = templates.taxonomy.term.full;
taxonomyPageFn = taxonomy: {
title = lib.theme.dermetfan.capitalize taxonomy;
};
termPageFn = taxonomy: tag: {
title =
(lib.strings.removeSuffix "s" (
lib.theme.dermetfan.capitalize taxonomy
)) +
": ${tag}";
};
};
};
site = (with lib; mkSite {
inherit files;
pageList = pagesToList {
inherit pages;
default = { layout = templates.layout; };
};
substitutions = {
inherit (conf) siteUrl;
};
postGen = let
libPkgs = lib.theme.dermetfan.pkgs {
inherit pkgs;
inherit (conf.data) secrets hashes;
};
in ''
asciidoctor_css=$(dirname $(realpath ${pkgs.asciidoctor}/bin/asciidoctor))/../lib/ruby/gems/*/gems/${pkgs.asciidoctor.meta.name}/data/stylesheets/asciidoctor-default.css
head -n 185 $asciidoctor_css | tail -n 3 > $out/styles/asciidoctor-default-anchor.css
cd $out/posts/zig-with-c-web-servers
tar -chaf h2o.tar.gz h2o
tar -chaf facil.io.tar.gz facil.io
mkdir $out/posts/distributed-tracing-and-opentelemetry
cd $out/posts/distributed-tracing-and-opentelemetry
cp ${libPkgs.fetchurlCentral rec { url = "https://get.uptrace.dev/opentelemetry-and-uptrace/${name}.png"; name = "tracing-graph"; }} tracing-graph.png
cp ${libPkgs.fetchurlCentral rec { url = "https://get.uptrace.dev/opentelemetry-and-uptrace/${name}.png"; name = "trace-graph"; }} trace-graph.png
cp ${libPkgs.fetchurlCentral rec { url = "https://get.uptrace.dev/opentelemetry-and-uptrace/${name}.png"; name = "uptrace"; }} uptrace.png
'';
}) // {
overrideArgs = f: (import ./site.nix (args // (f args))).site;
};
}