1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7let
8 cfg = config.services.u9fs;
9in
10{
11
12 options = {
13
14 services.u9fs = {
15
16 enable = lib.mkOption {
17 type = lib.types.bool;
18 default = false;
19 description = "Whether to run the u9fs 9P server for Unix.";
20 };
21
22 listenStreams = lib.mkOption {
23 type = lib.types.listOf lib.types.str;
24 default = [ "564" ];
25 example = [ "192.168.16.1:564" ];
26 description = ''
27 Sockets to listen for clients on.
28 See {command}`man 5 systemd.socket` for socket syntax.
29 '';
30 };
31
32 user = lib.mkOption {
33 type = lib.types.str;
34 default = "nobody";
35 description = "User to run u9fs under.";
36 };
37
38 extraArgs = lib.mkOption {
39 type = lib.types.str;
40 default = "";
41 example = "-a none";
42 description = ''
43 Extra arguments to pass on invocation,
44 see {command}`man 4 u9fs`
45 '';
46 };
47
48 };
49
50 };
51
52 config = lib.mkIf cfg.enable {
53
54 systemd = {
55 sockets.u9fs = {
56 description = "U9fs Listening Socket";
57 wantedBy = [ "sockets.target" ];
58 after = [ "network.target" ];
59 inherit (cfg) listenStreams;
60 socketConfig.Accept = "yes";
61 };
62 services."u9fs@" = {
63 description = "9P Protocol Server";
64 reloadIfChanged = true;
65 requires = [ "u9fs.socket" ];
66 serviceConfig = {
67 ExecStart = "-${pkgs.u9fs}/bin/u9fs ${cfg.extraArgs}";
68 StandardInput = "socket";
69 StandardError = "journal";
70 User = cfg.user;
71 AmbientCapabilities = "cap_setuid cap_setgid";
72 };
73 };
74 };
75
76 };
77
78}