main
1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9let
10 cfg = config.services.govanityurl;
11in
12{
13 options = {
14 services.govanityurl = {
15 enable = mkEnableOption ''
16 govanityurl is a go canonical path server
17 '';
18 package = mkOption {
19 type = types.package;
20 default = pkgs.govanityurl;
21 description = ''
22 govanityurl package to use.
23 '';
24 };
25
26 user = mkOption {
27 type = types.str;
28 };
29
30 host = mkOption {
31 type = types.str;
32 };
33
34 config = mkOption {
35 type = types.lines;
36 };
37 };
38 };
39 config = mkIf cfg.enable {
40 systemd.packages = [ cfg.package ];
41 environment.etc."govanityurl/config.yaml".text = ''
42 host: ${cfg.host}
43 ${cfg.config}
44 '';
45 systemd.services.govanityurl = {
46 description = "Govanity service";
47 after = [ "network.target" ];
48 wantedBy = [ "multi-user.target" ];
49 serviceConfig = {
50 User = cfg.user;
51 Restart = "on-failure";
52 ExecStart = ''
53 ${cfg.package}/bin/vanityurl /etc/govanityurl/config.yaml
54 '';
55 };
56 path = [ cfg.package ];
57 };
58 };
59}