@@ -1,150 +0,0 @@
1−{ config, lib, pkgs, ... }:
2−
3−with lib;
4−
5−let
6− cfg = config.services.fleet;
7−
8−in {
9−
10− ##### Interface
11− options.services.fleet = {
12− enable = mkOption {
13− type = types.bool;
14− default = false;
15− description = ''
16− Whether to enable fleet service.
17− '';
18− };
19−
20− listen = mkOption {
21− type = types.listOf types.str;
22− default = [ "/var/run/fleet.sock" ];
23− example = [ "/var/run/fleet.sock" "127.0.0.1:49153" ];
24− description = ''
25− Fleet listening addresses.
26− '';
27− };
28−
29− etcdServers = mkOption {
30− type = types.listOf types.str;
31− default = [ "http://127.0.0.1:2379" ];
32− description = ''
33− Fleet list of etcd endpoints to use.
34− '';
35− };
36−
37− publicIp = mkOption {
38− type = types.nullOr types.str;
39− default = "";
40− description = ''
41− Fleet IP address that should be published with the local Machine's
42− state and any socket information. If not set, fleetd will attempt
43− to detect the IP it should publish based on the machine's IP
44− routing information.
45− '';
46− };
47−
48− etcdCafile = mkOption {
49− type = types.nullOr types.path;
50− default = null;
51− description = ''
52− Fleet TLS ca file when SSL certificate authentication is enabled
53− in etcd endpoints.
54− '';
55− };
56−
57− etcdKeyfile = mkOption {
58− type = types.nullOr types.path;
59− default = null;
60− description = ''
61− Fleet TLS key file when SSL certificate authentication is enabled
62− in etcd endpoints.
63− '';
64− };
65−
66− etcdCertfile = mkOption {
67− type = types.nullOr types.path;
68− default = null;
69− description = ''
70− Fleet TLS cert file when SSL certificate authentication is enabled
71− in etcd endpoints.
72− '';
73− };
74−
75− metadata = mkOption {
76− type = types.attrsOf types.str;
77− default = {};
78− apply = attrs: concatMapStringsSep "," (n: "${n}=${attrs."${n}"}") (attrNames attrs);
79− example = literalExample ''
80− {
81− region = "us-west";
82− az = "us-west-1";
83− }
84− '';
85− description = ''
86− Key/value pairs that are published with the local to the fleet registry.
87− This data can be used directly by a client of fleet to make scheduling decisions.
88− '';
89− };
90−
91− extraConfig = mkOption {
92− type = types.attrsOf types.str;
93− apply = mapAttrs' (n: v: nameValuePair ("FLEET_" + n) v);
94− default = {};
95− example = literalExample ''
96− {
97− VERBOSITY = 1;
98− ETCD_REQUEST_TIMEOUT = "2.0";
99− AGENT_TTL = "40s";
100− }
101− '';
102− description = ''
103− Fleet extra config. See
104− <link xlink:href="https://github.com/coreos/fleet/blob/master/Documentation/deployment-and-configuration.md"/>
105− for configuration options.
106− '';
107− };
108−
109− };
110−
111− ##### Implementation
112− config = mkIf cfg.enable {
113− systemd.services.fleet = {
114− description = "Fleet Init System Daemon";
115− wantedBy = [ "multi-user.target" ];
116− after = [ "network.target" "fleet.socket" "etcd.service" "docker.service" ];
117− requires = [ "fleet.socket" ];
118− environment = {
119− FLEET_ETCD_SERVERS = concatStringsSep "," cfg.etcdServers;
120− FLEET_PUBLIC_IP = cfg.publicIp;
121− FLEET_ETCD_CAFILE = cfg.etcdCafile;
122− FLEET_ETCD_KEYFILE = cfg.etcdKeyfile;
123− FLEET_ETCD_CERTFILE = cfg.etcdCertfile;
124− FLEET_METADATA = cfg.metadata;
125− } // cfg.extraConfig;
126− serviceConfig = {
127− ExecStart = "${pkgs.fleet}/bin/fleetd";
128− Group = "fleet";
129− };
130− };
131−
132− systemd.sockets.fleet = {
133− description = "Fleet Socket for the API";
134− wantedBy = [ "sockets.target" ];
135− listenStreams = cfg.listen;
136− socketConfig = {
137− ListenStream = "/var/run/fleet.sock";
138− SocketMode = "0660";
139− SocketUser = "root";
140− SocketGroup = "fleet";
141− };
142− };
143−
144− services.etcd.enable = mkDefault true;
145− virtualisation.docker.enable = mkDefault true;
146−
147− environment.systemPackages = [ pkgs.fleet ];
148− users.extraGroups.fleet.gid = config.ids.gids.fleet;
149− };
150−}