-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathblog-updater.nix
78 lines (66 loc) · 1.76 KB
/
blog-updater.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
{ config, pkgs, lib ? pkgs.lib, ... }:
with lib;
let
cfg = config.services.blog-updater;
in
{
# interface
options = {
services.blog-updater = rec {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to run the blog updating service
'';
};
virtualHost = mkOption {
type = types.str;
default = "blog.qfpl.io";
description = ''
The virtual host to serve the blog content from
'';
};
hydraJob = mkOption {
type = types.str;
default = "http://hydra.qfpl.io/job/team-blog/blog/blog";
description = ''
The url to the hydra job for the blog content
'';
};
blogProfile = mkOption {
type = types.str;
default = "blog";
description = ''
The profile to run hail from
'';
};
};
};
# implementation
config = mkIf cfg.enable {
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."${cfg.virtualHost}" = {
forceSSL = true;
enableACME = true;
locations."/".root = "/nix/var/nix/profiles/${cfg.blogProfile}/blog";
};
};
systemd.services.blog-updater = {
description = "Team blog updater";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.nix ];
environment = { HOME = "/var/lib/empty"; };
stopIfChanged = false;
serviceConfig = {
ExecStart = "${pkgs.haskellPackages.hail}/bin/hail --profile ${cfg.blogProfile} --job-uri ${cfg.hydraJob}";
};
};
};
}