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