1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/nixos/modules/services/misc/nix-ssh-serve.nix

62 lines
1.4 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
with lib;
2018-02-28 21:55:00 +00:00
let cfg = config.nix.sshServe;
command =
if cfg.protocol == "ssh"
then "nix-store --serve"
else "nix-daemon --stdio";
in {
options = {
nix.sshServe = {
enable = mkOption {
type = types.bool;
default = false;
2018-02-28 21:55:00 +00:00
description = "Whether to enable serving the Nix store as a remote store via SSH.";
};
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.";
};
2018-02-28 21:55:00 +00:00
protocol = mkOption {
type = types.enum [ "ssh" "ssh-ng" ];
default = "ssh";
description = "The specific Nix-over-SSH protocol to use.";
};
};
};
2018-02-28 21:55:00 +00:00
config = mkIf cfg.enable {
users.users.nix-ssh = {
2018-02-28 21:55:00 +00:00
description = "Nix SSH store user";
uid = config.ids.uids.nix-ssh;
useDefaultShell = true;
};
services.openssh.enable = true;
services.openssh.extraConfig = ''
Match User nix-ssh
AllowAgentForwarding no
AllowTcpForwarding no
PermitTTY no
PermitTunnel no
X11Forwarding no
2018-02-28 21:55:00 +00:00
ForceCommand ${config.nix.package.out}/bin/${command}
Match All
'';
users.users.nix-ssh.openssh.authorizedKeys.keys = cfg.keys;
};
}