3e9c2bf4b5
ForceCommand ensures that we always run nix-store --serve, so there is no need to check SSH_ORIGINAL_COMMAND.
37 lines
801 B
Nix
37 lines
801 B
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
options = {
|
|
nix.sshServe = {
|
|
enable = mkOption {
|
|
description = "Whether to enable serving the Nix store as a binary cache via SSH.";
|
|
default = false;
|
|
type = types.bool;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf config.nix.sshServe.enable {
|
|
users.extraUsers.nix-ssh = {
|
|
description = "Nix SSH substituter user";
|
|
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
|
|
ForceCommand ${config.nix.package}/bin/nix-store --serve
|
|
Match All
|
|
'';
|
|
};
|
|
}
|