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
|
diff --git a/module/default.nix b/module/default.nix
index 7fd054329c1190cb1434b6d547ac5b4f64377e1b..f183a9d217ccd6b665721906ecdc5ebe46ccd90e 100644
--- a/module/default.nix
+++ b/module/default.nix
@@ -3,25 +3,31 @@ config,
lib,
pkgs,
...
-}: let
+}:
+let
cfg = config.services.git-pr;
- pkg = pkgs.callPackage ../pkg {inherit pkgs;};
- tomlFormat = pkgs.formats.toml {};
- configFile = tomlFormat.generate "git-pr-config" (lib.recursiveUpdate {
- inherit (cfg) url admins host theme;
+ pkg = pkgs.callPackage ../pkg { inherit pkgs; };
+ tomlFormat = pkgs.formats.toml { };
+ configFile = tomlFormat.generate "git-pr-config" (
+ lib.recursiveUpdate {
+ inherit (cfg)
+ url
+ admins
+ host
+ theme
+ ;
data_dir = cfg.dataDir;
ssh_port = cfg.sshPort;
web_port = cfg.webPort;
time_format = cfg.timeFormat;
- repo =
- builtins.map (repo: {
- inherit (repo) id desc;
- clone_addr = repo.cloneAddr;
- })
- cfg.repos;
- }
- cfg.extraConfig);
-in {
+ repo = builtins.map (repo: {
+ inherit (repo) id desc;
+ clone_addr = repo.cloneAddr;
+ }) cfg.repos;
+ } cfg.extraConfig
+ );
+in
+{
options.services.git-pr = {
enable = lib.mkEnableOption "Git PR service";
@@ -45,7 +51,7 @@ };
admins = lib.mkOption {
type = lib.types.listOf lib.types.str;
- default = [];
+ default = [ ];
description = "List of admin SSH public keys";
};
@@ -76,23 +82,25 @@ description = "Theme for the web interface";
};
repos = lib.mkOption {
- type = lib.types.listOf (lib.types.submodule {
- options = {
- id = lib.mkOption {
- type = lib.types.str;
- description = "Repository ID";
- };
- cloneAddr = lib.mkOption {
- type = lib.types.str;
- description = "Git clone address";
+ type = lib.types.listOf (
+ lib.types.submodule {
+ options = {
+ id = lib.mkOption {
+ type = lib.types.str;
+ description = "Repository ID";
+ };
+ cloneAddr = lib.mkOption {
+ type = lib.types.str;
+ description = "Git clone address";
+ };
+ desc = lib.mkOption {
+ type = lib.types.str;
+ description = "Repository description";
+ };
};
- desc = lib.mkOption {
- type = lib.types.str;
- description = "Repository description";
- };
- };
- });
- default = [];
+ }
+ );
+ default = [ ];
description = "List of repositories to manage";
};
@@ -104,7 +112,7 @@ };
extraConfig = lib.mkOption {
type = lib.types.attrs;
- default = {};
+ default = { };
description = "Additional configuration options to be added to the TOML file";
};
@@ -119,8 +127,8 @@ config = lib.mkIf cfg.enable {
# SSH service
systemd.services.git-pr-ssh = {
description = "Git PR SSH Service";
- after = ["network.target"];
- wantedBy = ["multi-user.target"];
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/ssh --config ${configFile}";
@@ -133,8 +141,8 @@
# Web service
systemd.services.git-pr-web = {
description = "Git PR Web Service";
- after = ["network.target"];
- wantedBy = ["multi-user.target"];
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/web --config ${configFile}";
@@ -152,10 +160,13 @@ home = cfg.dataDir;
createHome = true;
};
- users.groups.git-pr = {};
+ users.groups.git-pr = { };
networking.firewall = lib.mkIf cfg.openFirewall {
- allowedTCPPorts = [cfg.webPort cfg.sshPort];
+ allowedTCPPorts = [
+ cfg.webPort
+ cfg.sshPort
+ ];
};
};
}
|