2015-05-13 18:54:25 +01: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 03:10:23 +01:00
|
|
|
secretKeyFile = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The path to the file used for signing derivation data.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-05-13 18:54:25 +01: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" ];
|
|
|
|
|
|
|
|
path = [ config.nix.package pkgs.bzip2 ];
|
|
|
|
environment.NIX_REMOTE = "daemon";
|
2015-06-18 03:10:23 +01:00
|
|
|
environment.NIX_SECRET_KEY_FILE = cfg.secretKeyFile;
|
2015-05-13 18:54:25 +01:00
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.nix-serve}/bin/nix-serve " +
|
|
|
|
"--port ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}";
|
2015-06-18 03:10:23 +01:00
|
|
|
User = "nix-serve";
|
2015-05-13 18:54:25 +01:00
|
|
|
Group = "nogroup";
|
|
|
|
};
|
|
|
|
};
|
2015-06-18 03:10:23 +01:00
|
|
|
|
|
|
|
users.extraUsers.nix-serve = {
|
|
|
|
description = "Nix-serve user";
|
|
|
|
uid = config.ids.uids.nix-serve;
|
|
|
|
};
|
2015-05-13 18:54:25 +01:00
|
|
|
};
|
|
|
|
}
|