1 { config, lib, pkgs, ... }:
3 cfg = config.services.distccd;
8 enable = lib.mkEnableOption "distccd, a distributed C/C++ compiler";
10 allowedClients = lib.mkOption {
11 type = lib.types.listOf lib.types.str;
12 default = [ "127.0.0.1" ];
13 example = [ "127.0.0.1" "192.168.0.0/24" "10.0.0.0/24" ];
15 Client IPs which are allowed to connect to distccd in CIDR notation.
17 Anyone who can connect to the distccd server can run arbitrary
18 commands on that system as the distcc user, therefore you should use
23 jobTimeout = lib.mkOption {
24 type = lib.types.nullOr lib.types.int;
27 Maximum duration, in seconds, of a single compilation request.
31 logLevel = lib.mkOption {
32 type = lib.types.nullOr (lib.types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]);
35 Set the minimum severity of error that will be included in the log
36 file. Useful if you only want to see error messages rather than an
37 entry for each connection.
41 maxJobs = lib.mkOption {
42 type = lib.types.nullOr lib.types.int;
45 Maximum number of tasks distccd should execute at lib.any time.
51 type = lib.types.nullOr lib.types.int;
54 Niceness of the compilation tasks.
58 openFirewall = lib.mkOption {
59 type = lib.types.bool;
62 Opens the specified TCP port for distcc.
66 package = lib.mkPackageOption pkgs "distcc" { };
69 type = lib.types.port;
72 The TCP port which distccd will listen on.
77 enable = lib.mkEnableOption "statistics reporting via HTTP server";
79 type = lib.types.port;
82 The TCP port which the distccd statistics HTTP server will listen
88 zeroconf = lib.mkOption {
89 type = lib.types.bool;
92 Whether to register via mDNS/DNS-SD
98 config = lib.mkIf cfg.enable {
99 networking.firewall = lib.mkIf cfg.openFirewall {
100 allowedTCPPorts = [ cfg.port ]
101 ++ lib.optionals cfg.stats.enable [ cfg.stats.port ];
104 systemd.services.distccd = {
105 after = [ "network.target" ];
106 wantedBy = [ "multi-user.target" ];
108 description = "Distributed C, C++ and Objective-C compiler";
109 documentation = [ "man:distccd(1)" ];
114 # FIXME: I'd love to get rid of `--enable-tcp-insecure` here, but I'm
115 # not sure how I'm supposed to get distccd to "accept" running a binary
116 # (the compiler) that's outside of /usr/lib.
117 ExecStart = pkgs.writeShellScript "start-distccd" ''
118 export PATH="${pkgs.distccMasquerade}/bin"
119 ${cfg.package}/bin/distccd \
122 --enable-tcp-insecure \
123 --port ${toString cfg.port} \
124 ${lib.optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \
125 ${lib.optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \
126 ${lib.optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \
127 ${lib.optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \
128 ${lib.optionalString cfg.stats.enable "--stats"} \
129 ${lib.optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \
130 ${lib.optionalString cfg.zeroconf "--zeroconf"} \
131 ${lib.concatMapStrings (c: "--allow ${c} ") cfg.allowedClients}
137 groups.distcc.gid = config.ids.gids.distcc;
139 description = "distccd user";
141 uid = config.ids.uids.distcc;