2014-02-20 18:34:54 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2014-07-25 10:54:00 +02:00
|
|
|
with lib;
|
2014-02-20 18:34:54 +01:00
|
|
|
|
2014-07-25 10:54:00 +02:00
|
|
|
{
|
2014-02-20 18:34:54 +01:00
|
|
|
options = {
|
|
|
|
nix.sshServe = {
|
|
|
|
enable = mkOption {
|
2014-07-25 10:54:00 +02:00
|
|
|
description = "Whether to enable serving the Nix store as a binary cache via SSH.";
|
2014-02-20 18:34:54 +01:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.nix.sshServe.enable {
|
|
|
|
users.extraUsers.nix-ssh = {
|
2014-07-25 10:54:00 +02:00
|
|
|
description = "Nix SSH substituter user";
|
2014-02-20 18:34:54 +01:00
|
|
|
uid = config.ids.uids.nix-ssh;
|
|
|
|
shell = pkgs.stdenv.shell;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh.enable = true;
|
|
|
|
|
|
|
|
services.openssh.extraConfig = ''
|
|
|
|
Match User nix-ssh
|
|
|
|
AllowAgentForwarding no
|
|
|
|
AllowTcpForwarding no
|
|
|
|
PermitTTY no
|
|
|
|
PermitTunnel no
|
|
|
|
X11Forwarding no
|
2014-07-25 10:54:00 +02:00
|
|
|
ForceCommand ${config.nix.package}/bin/nix-store --serve
|
2014-02-20 18:34:54 +01:00
|
|
|
Match All
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|