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 = {
|
2014-07-25 11:00:32 +02:00
|
|
|
|
2014-02-20 18:34:54 +01:00
|
|
|
nix.sshServe = {
|
2014-07-25 11:00:32 +02:00
|
|
|
|
2014-02-20 18:34:54 +01:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
2014-07-25 11:00:32 +02:00
|
|
|
default = false;
|
|
|
|
description = "Whether to enable serving the Nix store as a binary cache via SSH.";
|
2014-02-20 18:34:54 +01:00
|
|
|
};
|
2014-07-25 11:00:32 +02: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 18:34:54 +01:00
|
|
|
};
|
2014-07-25 11:00:32 +02:00
|
|
|
|
2014-02-20 18:34:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.nix.sshServe.enable {
|
2014-07-25 11:00:32 +02:00
|
|
|
|
2014-02-20 18:34:54 +01:00
|
|
|
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;
|
2014-07-25 13:42:44 +02:00
|
|
|
useDefaultShell = true;
|
2014-02-20 18:34:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh.enable = true;
|
|
|
|
|
|
|
|
services.openssh.extraConfig = ''
|
|
|
|
Match User nix-ssh
|
|
|
|
AllowAgentForwarding no
|
|
|
|
AllowTcpForwarding no
|
|
|
|
PermitTTY no
|
|
|
|
PermitTunnel no
|
|
|
|
X11Forwarding no
|
2016-04-24 12:57:19 +02:00
|
|
|
ForceCommand ${config.nix.package.out}/bin/nix-store --serve
|
2014-02-20 18:34:54 +01:00
|
|
|
Match All
|
|
|
|
'';
|
2014-07-25 11:00:32 +02:00
|
|
|
|
|
|
|
users.extraUsers.nix-ssh.openssh.authorizedKeys.keys = config.nix.sshServe.keys;
|
|
|
|
|
2014-02-20 18:34:54 +01:00
|
|
|
};
|
|
|
|
}
|