Add convenience option nix.sshServe.keys

This is equivalent to setting
users.extraUsers.nix-cache.openssh.authorizedKeys.keys.

Changed files
+17 -2
nixos
modules
services
+17 -2
nixos/modules/services/misc/nix-ssh-serve.nix
···
{
options = {
+
nix.sshServe = {
+
enable = mkOption {
+
type = types.bool;
+
default = false;
description = "Whether to enable serving the Nix store as a binary cache via SSH.";
-
default = false;
-
type = types.bool;
+
};
+
+
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.";
};
+
};
+
};
config = mkIf config.nix.sshServe.enable {
+
users.extraUsers.nix-ssh = {
description = "Nix SSH substituter user";
uid = config.ids.uids.nix-ssh;
···
ForceCommand ${config.nix.package}/bin/nix-store --serve
Match All
'';
+
+
users.extraUsers.nix-ssh.openssh.authorizedKeys.keys = config.nix.sshServe.keys;
+
};
}