2014-02-20 17:34:54 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2014-07-25 08:54:00 +00:00
|
|
|
with lib;
|
2014-02-20 17:34:54 +00:00
|
|
|
|
2014-07-25 08:54:00 +00:00
|
|
|
{
|
2014-02-20 17:34:54 +00:00
|
|
|
options = {
|
2014-07-25 09:00:32 +00:00
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
nix.sshServe = {
|
2014-07-25 09:00:32 +00:00
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
2014-07-25 09:00:32 +00:00
|
|
|
default = false;
|
|
|
|
description = "Whether to enable serving the Nix store as a binary cache via SSH.";
|
2014-02-20 17:34:54 +00:00
|
|
|
};
|
2014-07-25 09:00:32 +00:00
|
|
|
|
|
|
|
keys = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [];
|
|
|
|
example = [ "ssh-dss AAAAB3NzaC1k... alice@example.org" ];
|
|
|
|
description = "A list of SSH public keys allowed to access the binary cache via SSH.";
|
|
|
|
};
|
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
};
|
2014-07-25 09:00:32 +00:00
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.nix.sshServe.enable {
|
2014-07-25 09:00:32 +00:00
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
users.extraUsers.nix-ssh = {
|
2014-07-25 08:54:00 +00:00
|
|
|
description = "Nix SSH substituter user";
|
2014-02-20 17:34:54 +00: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 08:54:00 +00:00
|
|
|
ForceCommand ${config.nix.package}/bin/nix-store --serve
|
2014-02-20 17:34:54 +00:00
|
|
|
Match All
|
|
|
|
'';
|
2014-07-25 09:00:32 +00:00
|
|
|
|
|
|
|
users.extraUsers.nix-ssh.openssh.authorizedKeys.keys = config.nix.sshServe.keys;
|
|
|
|
|
2014-02-20 17:34:54 +00:00
|
|
|
};
|
|
|
|
}
|