2015-05-13 19:54:25 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.nix-serve;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.nix-serve = {
|
|
|
|
enable = mkEnableOption "nix-serve, the standalone Nix binary cache server";
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 5000;
|
|
|
|
description = ''
|
|
|
|
Port number where nix-serve will listen on.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bindAddress = mkOption {
|
|
|
|
type = types.string;
|
|
|
|
default = "0.0.0.0";
|
|
|
|
description = ''
|
|
|
|
IP address where nix-serve will bind its listening socket.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-06-18 04:10:23 +02:00
|
|
|
secretKeyFile = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The path to the file used for signing derivation data.
|
2019-02-18 19:33:36 +01:00
|
|
|
Generate with:
|
|
|
|
|
|
|
|
```
|
|
|
|
nix-store --generate-binary-cache-key key-name secret-key-file public-key-file
|
|
|
|
```
|
|
|
|
|
|
|
|
Make sure user `nix-serve` has read access to the private key file.
|
|
|
|
|
|
|
|
For more details see <citerefentry><refentrytitle>nix-store</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
|
2015-06-18 04:10:23 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-05-13 19:54:25 +02:00
|
|
|
extraParams = mkOption {
|
|
|
|
type = types.string;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Extra command line parameters for nix-serve.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.nix-serve = {
|
|
|
|
description = "nix-serve binary cache server";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
2016-04-24 13:06:04 +02:00
|
|
|
path = [ config.nix.package.out pkgs.bzip2.bin ];
|
2015-05-13 19:54:25 +02:00
|
|
|
environment.NIX_REMOTE = "daemon";
|
2015-06-18 04:10:23 +02:00
|
|
|
environment.NIX_SECRET_KEY_FILE = cfg.secretKeyFile;
|
2015-05-13 19:54:25 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
2018-03-05 20:32:42 +01:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "5s";
|
2015-05-13 19:54:25 +02:00
|
|
|
ExecStart = "${pkgs.nix-serve}/bin/nix-serve " +
|
2015-11-13 14:25:50 +01:00
|
|
|
"--listen ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}";
|
2015-06-18 04:10:23 +02:00
|
|
|
User = "nix-serve";
|
2015-05-13 19:54:25 +02:00
|
|
|
Group = "nogroup";
|
|
|
|
};
|
|
|
|
};
|
2015-06-18 04:10:23 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.nix-serve = {
|
2015-06-18 04:10:23 +02:00
|
|
|
description = "Nix-serve user";
|
|
|
|
uid = config.ids.uids.nix-serve;
|
|
|
|
};
|
2015-05-13 19:54:25 +02:00
|
|
|
};
|
|
|
|
}
|