-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmodule.nix
More file actions
61 lines (50 loc) · 1.46 KB
/
Copy pathmodule.nix
File metadata and controls
61 lines (50 loc) · 1.46 KB
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
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.nixos-image-proxy-server;
nixos-image-proxy-server = pkgs.nixos-image-proxy-server;
format = pkgs.formats.json {};
in
{
options = {
services.nixos-image-proxy-server = {
enable = mkEnableOption "nixos-image-proxy-server";
/* port = mkOption {
description = "Port to listen at";
type = types.int;
default = 3333;
};
token = mkOption {
description = "GitHub Token";
type = types.str;
}; */
config = mkOption {
description = "configuration";
type = format.type;
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = "Open ports in the firewall for nixos-image-proxy-server.";
};
};
};
config = mkIf (cfg.enable) {
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.config.port ];
};
systemd.services.nixos-image-proxy-server = with pkgs; {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
requires = [ "network-online.target" ];
description = "nixos-image-proxy-server";
environment.CONFIG = with builtins; format.generate "config.json" cfg.config;
serviceConfig = {
Type = "simple";
DynamicUser = true;
User = "nixos-image";
ExecStart = "${nixos-image-proxy-server}/bin/nixos-image-proxy-server";
};
};
};
}