blob: 56f5b02cc89d55f1050f68659b52b3a4877b8824 (
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
|
{ pkgs, depot, ... }:
let
inherit (builtins) readFile;
inherit (depot.users) wpcarro;
domain = "billandhiscomputer.com";
globalVars = {
inherit domain;
homepage = "https://${domain}/";
blog = "https://${domain}/blog";
habits = "https://${domain}/habits";
github = "https://github.com/wpcarro";
linkedin = "https://linkedin.com/in/williampatrickcarroll";
depotWork = "https://cs.tvl.fyi/depot/-/blob/users/wpcarro";
};
renderTemplate = src: vars: pkgs.substituteAll (globalVars // vars // {
inherit src;
});
withBrand = contentHtml: renderTemplate ./fragments/template.html {
inherit contentHtml;
};
# Create a simple static file server using nginx to serve `content`.
nginxCfgFor = content: pkgs.writeText "nginx.conf" ''
user nobody nobody;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
server {
listen 8080;
location / {
root ${content};
}
}
}
'';
in
rec {
inherit domain renderTemplate withBrand;
content = pkgs.runCommand "wpcarro.dev" { } ''
mkdir -p $out
# /
cp ${withBrand (readFile (renderTemplate ./fragments/homepage.html {}))} $out/index.html
# /habits
mkdir -p $out/habits
cp -r ${wpcarro.website.habit-screens} $out/habits/index.html
# /blog
cp -r ${wpcarro.website.blog} $out/blog
'';
# Create a docker image suitable for Google Cloud Run (to save costs).
image = pkgs.dockerTools.buildLayeredImage {
name = "website";
tag = "latest";
contents = [ pkgs.fakeNss ];
extraCommands = ''
mkdir -p tmp/nginx_client_body
mkdir -p var/log/nginx
'';
config = {
Cmd = [ "${pkgs.nginx}/bin/nginx" "-c" (nginxCfgFor content) ];
ExposedPorts = { "8080/tcp" = { }; };
};
};
meta.ci.targets = [ "root" "image" ];
}
|