nix-ssh-serve.nix: Remove unnecessary check

ForceCommand ensures that we always run nix-store --serve, so there is
no need to check SSH_ORIGINAL_COMMAND.

Changed files
+5 -14
nixos
modules
services
+5 -14
nixos/modules/services/misc/nix-ssh-serve.nix
···
{ config, lib, pkgs, ... }:
-
let
-
serveOnly = pkgs.writeScript "nix-store-serve" ''
-
#!${pkgs.stdenv.shell}
-
if [ "$SSH_ORIGINAL_COMMAND" != "nix-store --serve" ]; then
-
echo 'Error: You are only allowed to run `nix-store --serve'\'''!' >&2
-
exit 1
-
fi
-
exec /run/current-system/sw/bin/nix-store --serve
-
'';
+
with lib;
-
inherit (lib) mkIf mkOption types;
-
in {
+
{
options = {
nix.sshServe = {
enable = mkOption {
-
description = "Whether to enable serving the nix store over ssh.";
+
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 = "User for running nix-store --serve.";
+
description = "Nix SSH substituter user";
uid = config.ids.uids.nix-ssh;
shell = pkgs.stdenv.shell;
};
···
PermitTTY no
PermitTunnel no
X11Forwarding no
-
ForceCommand ${serveOnly}
+
ForceCommand ${config.nix.package}/bin/nix-store --serve
Match All
'';
};