1 { config, lib, pkgs, ... }:
6 cfg = config.services.distccd;
11 enable = mkEnableOption (lib.mdDoc "distccd");
13 allowedClients = mkOption {
14 type = types.listOf types.str;
15 default = [ "127.0.0.1" ];
16 example = [ "127.0.0.1" "192.168.0.0/24" "10.0.0.0/24" ];
17 description = lib.mdDoc ''
18 Client IPs which are allowed to connect to distccd in CIDR notation.
20 Anyone who can connect to the distccd server can run arbitrary
21 commands on that system as the distcc user, therefore you should use
26 jobTimeout = mkOption {
27 type = types.nullOr types.int;
29 description = lib.mdDoc ''
30 Maximum duration, in seconds, of a single compilation request.
35 type = types.nullOr (types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]);
37 description = lib.mdDoc ''
38 Set the minimum severity of error that will be included in the log
39 file. Useful if you only want to see error messages rather than an
40 entry for each connection.
45 type = types.nullOr types.int;
47 description = lib.mdDoc ''
48 Maximum number of tasks distccd should execute at any time.
54 type = types.nullOr types.int;
56 description = lib.mdDoc ''
57 Niceness of the compilation tasks.
61 openFirewall = mkOption {
64 description = lib.mdDoc ''
65 Opens the specified TCP port for distcc.
71 default = pkgs.distcc;
72 defaultText = literalExpression "pkgs.distcc";
73 description = lib.mdDoc ''
74 The distcc package to use.
81 description = lib.mdDoc ''
82 The TCP port which distccd will listen on.
87 enable = mkEnableOption (lib.mdDoc "statistics reporting via HTTP server");
91 description = lib.mdDoc ''
92 The TCP port which the distccd statistics HTTP server will listen
101 description = lib.mdDoc ''
102 Whether to register via mDNS/DNS-SD
108 config = mkIf cfg.enable {
109 networking.firewall = mkIf cfg.openFirewall {
110 allowedTCPPorts = [ cfg.port ]
111 ++ optionals cfg.stats.enable [ cfg.stats.port ];
114 systemd.services.distccd = {
115 after = [ "network.target" ];
116 wantedBy = [ "multi-user.target" ];
118 description = "Distributed C, C++ and Objective-C compiler";
119 documentation = [ "man:distccd(1)" ];
124 # FIXME: I'd love to get rid of `--enable-tcp-insecure` here, but I'm
125 # not sure how I'm supposed to get distccd to "accept" running a binary
126 # (the compiler) that's outside of /usr/lib.
127 ExecStart = pkgs.writeShellScript "start-distccd" ''
128 export PATH="${pkgs.distccMasquerade}/bin"
129 ${cfg.package}/bin/distccd \
132 --enable-tcp-insecure \
133 --port ${toString cfg.port} \
134 ${optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \
135 ${optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \
136 ${optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \
137 ${optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \
138 ${optionalString cfg.stats.enable "--stats"} \
139 ${optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \
140 ${optionalString cfg.zeroconf "--zeroconf"} \
141 ${concatMapStrings (c: "--allow ${c} ") cfg.allowedClients}
147 groups.distcc.gid = config.ids.gids.distcc;
149 description = "distccd user";
151 uid = config.ids.uids.distcc;