1# NixOS module for atftpd TFTP server
2{
3 config,
4 pkgs,
5 lib,
6 ...
7}:
8let
9
10 cfg = config.services.atftpd;
11
12in
13
14{
15
16 options = {
17
18 services.atftpd = {
19
20 enable = lib.mkOption {
21 default = false;
22 type = lib.types.bool;
23 description = ''
24 Whether to enable the atftpd TFTP server. By default, the server
25 binds to address 0.0.0.0.
26 '';
27 };
28
29 extraOptions = lib.mkOption {
30 default = [ ];
31 type = lib.types.listOf lib.types.str;
32 example = lib.literalExpression ''
33 [ "--bind-address 192.168.9.1"
34 "--verbose=7"
35 ]
36 '';
37 description = ''
38 Extra command line arguments to pass to atftp.
39 '';
40 };
41
42 root = lib.mkOption {
43 default = "/srv/tftp";
44 type = lib.types.path;
45 description = ''
46 Document root directory for the atftpd.
47 '';
48 };
49
50 };
51
52 };
53
54 config = lib.mkIf cfg.enable {
55
56 systemd.services.atftpd = {
57 description = "TFTP Server";
58 after = [ "network.target" ];
59 wantedBy = [ "multi-user.target" ];
60 # runs as nobody
61 serviceConfig.ExecStart = "${pkgs.atftp}/sbin/atftpd --daemon --no-fork ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.root}";
62 };
63
64 };
65
66}