summary refs log tree commit diff
path: root/nixos/modules/services/networking/atftpd.nix
blob: da5e305201f865137344b02a3666bb5b1ae74ac0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# NixOS module for atftpd TFTP server

{ config, pkgs, lib, ... }:

with lib;

let

  cfg = config.services.atftpd;

in

{

  options = {

    services.atftpd = {

      enable = mkOption {
        default = false;
        type = types.bool;
        description = ''
          Whether to enable the atftpd TFTP server. By default, the server
          binds to address 0.0.0.0.
        '';
      };

      extraOptions = mkOption {
        default = [];
        type = types.listOf types.str;
        example = literalExpression ''
          [ "--bind-address 192.168.9.1"
            "--verbose=7"
          ]
        '';
        description = ''
          Extra command line arguments to pass to atftp.
        '';
      };

      root = mkOption {
        default = "/srv/tftp";
        type = types.path;
        description = ''
          Document root directory for the atftpd.
        '';
      };

    };

  };

  config = mkIf cfg.enable {

    systemd.services.atftpd = {
      description = "TFTP Server";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      # runs as nobody
      serviceConfig.ExecStart = "${pkgs.atftp}/sbin/atftpd --daemon --no-fork ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.root}";
    };

  };

}