4 let cfg = config.nix.sshServe;
6 if cfg.protocol == "ssh"
7 then "nix-store --serve ${lib.optionalString cfg.write "--write"}"
8 else "nix-daemon --stdio";
17 description = lib.mdDoc "Whether to enable serving the Nix store as a remote store via SSH.";
23 description = lib.mdDoc "Whether to enable writing to the Nix store as a remote store via SSH. Note: the sshServe user is named nix-ssh and is not a trusted-user. nix-ssh should be added to the {option}`nix.settings.trusted-users` option in most use cases, such as allowing remote building of derivations.";
27 type = types.listOf types.str;
29 example = [ "ssh-dss AAAAB3NzaC1k... alice@example.org" ];
30 description = lib.mdDoc "A list of SSH public keys allowed to access the binary cache via SSH.";
34 type = types.enum [ "ssh" "ssh-ng" ];
36 description = lib.mdDoc "The specific Nix-over-SSH protocol to use.";
43 config = mkIf cfg.enable {
45 users.users.nix-ssh = {
46 description = "Nix SSH store user";
49 useDefaultShell = true;
51 users.groups.nix-ssh = {};
53 services.openssh.enable = true;
55 services.openssh.extraConfig = ''
57 AllowAgentForwarding no
62 ForceCommand ${config.nix.package.out}/bin/${command}
66 users.users.nix-ssh.openssh.authorizedKeys.keys = cfg.keys;