tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
Add module to enable the server for the ssh substituter
Shea Levy
12 years ago
fefc0d99
83c98e4d
+47
3 changed files
expand all
collapse all
unified
split
nixos
modules
misc
ids.nix
module-list.nix
services
misc
nix-ssh-serve.nix
+1
nixos/modules/misc/ids.nix
···
112
112
cgminer = 101;
113
113
munin = 102;
114
114
logcheck = 103;
115
115
+
nix-ssh = 104;
115
116
116
117
# When adding a uid, make sure it doesn't match an existing gid.
117
118
+1
nixos/modules/module-list.nix
···
125
125
./services/misc/gpsd.nix
126
126
./services/misc/nix-daemon.nix
127
127
./services/misc/nix-gc.nix
128
128
+
./services/misc/nix-ssh-serve.nix
128
129
./services/misc/nixos-manual.nix
129
130
./services/misc/rogue.nix
130
131
./services/misc/svnserve.nix
+45
nixos/modules/services/misc/nix-ssh-serve.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
let
4
4
+
serveOnly = pkgs.writeScript "nix-store-serve" ''
5
5
+
#!${pkgs.stdenv.shell}
6
6
+
if [ "$SSH_ORIGINAL_COMMAND" != "nix-store --serve" ]; then
7
7
+
echo 'Error: You are only allowed to run `nix-store --serve'\'''!' >&2
8
8
+
exit 1
9
9
+
fi
10
10
+
exec /run/current-system/sw/bin/nix-store --serve
11
11
+
'';
12
12
+
13
13
+
inherit (lib) mkIf mkOption types;
14
14
+
in {
15
15
+
options = {
16
16
+
nix.sshServe = {
17
17
+
enable = mkOption {
18
18
+
description = "Whether to enable serving the nix store over ssh.";
19
19
+
default = false;
20
20
+
type = types.bool;
21
21
+
};
22
22
+
};
23
23
+
};
24
24
+
25
25
+
config = mkIf config.nix.sshServe.enable {
26
26
+
users.extraUsers.nix-ssh = {
27
27
+
description = "User for running nix-store --serve.";
28
28
+
uid = config.ids.uids.nix-ssh;
29
29
+
shell = pkgs.stdenv.shell;
30
30
+
};
31
31
+
32
32
+
services.openssh.enable = true;
33
33
+
34
34
+
services.openssh.extraConfig = ''
35
35
+
Match User nix-ssh
36
36
+
AllowAgentForwarding no
37
37
+
AllowTcpForwarding no
38
38
+
PermitTTY no
39
39
+
PermitTunnel no
40
40
+
X11Forwarding no
41
41
+
ForceCommand ${serveOnly}
42
42
+
Match All
43
43
+
'';
44
44
+
};
45
45
+
}