summary refs log tree commit diff
path: root/nixos/modules/services/networking/atftpd.nix
blob: 47465ba948a9d569bef26583a5d236e96f21c37f (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
# 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.uniq types.bool;
        description = ''
          Whenever to enable the atftpd TFTP server.
        '';
      };

      root = mkOption {
        default = "/var/empty";
        type = types.uniq types.string;
        description = ''
          Document root directory for the atftpd.
        '';
      };

    };

  };

  config = mkIf cfg.enable {

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

  };

}