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