mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 14:22:50 +03:00
Add module to enable the server for the ssh substituter
This commit is contained in:
parent
83c98e4dd6
commit
fefc0d9917
@ -112,6 +112,7 @@
|
|||||||
cgminer = 101;
|
cgminer = 101;
|
||||||
munin = 102;
|
munin = 102;
|
||||||
logcheck = 103;
|
logcheck = 103;
|
||||||
|
nix-ssh = 104;
|
||||||
|
|
||||||
# When adding a uid, make sure it doesn't match an existing gid.
|
# When adding a uid, make sure it doesn't match an existing gid.
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
./services/misc/gpsd.nix
|
./services/misc/gpsd.nix
|
||||||
./services/misc/nix-daemon.nix
|
./services/misc/nix-daemon.nix
|
||||||
./services/misc/nix-gc.nix
|
./services/misc/nix-gc.nix
|
||||||
|
./services/misc/nix-ssh-serve.nix
|
||||||
./services/misc/nixos-manual.nix
|
./services/misc/nixos-manual.nix
|
||||||
./services/misc/rogue.nix
|
./services/misc/rogue.nix
|
||||||
./services/misc/svnserve.nix
|
./services/misc/svnserve.nix
|
||||||
|
45
nixos/modules/services/misc/nix-ssh-serve.nix
Normal file
45
nixos/modules/services/misc/nix-ssh-serve.nix
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{ 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
|
||||||
|
'';
|
||||||
|
|
||||||
|
inherit (lib) mkIf mkOption types;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
nix.sshServe = {
|
||||||
|
enable = mkOption {
|
||||||
|
description = "Whether to enable serving the nix store over ssh.";
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf config.nix.sshServe.enable {
|
||||||
|
users.extraUsers.nix-ssh = {
|
||||||
|
description = "User for running nix-store --serve.";
|
||||||
|
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 ${serveOnly}
|
||||||
|
Match All
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user