nixos/atftpd: various improvements

* Add extraOptions option, to pass arbitrary command line options to
  atftp. Especially useful to specify which address to bind to
  (--bind-addres ...).
* Improve descriptions (fix a typo, document default bind address,
  don't repeat service name in systemd description + capitalize)
* Change default server directory from /var/empty to /srv/tftp, and
  change types.str to types.path.
This commit is contained in:
Bjørn Forsman 2016-10-16 17:54:49 +02:00
parent 953fd050c0
commit f3876cbba0
1 changed files with 19 additions and 5 deletions

View File

@ -20,13 +20,27 @@ in
default = false; default = false;
type = types.bool; type = types.bool;
description = '' description = ''
Whenever to enable the atftpd TFTP server. 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 = literalExample ''
[ "--bind-address 192.168.9.1"
"--verbose=7"
]
'';
description = ''
Extra command line arguments to pass to atftp.
''; '';
}; };
root = mkOption { root = mkOption {
default = "/var/empty"; default = "/srv/tftp";
type = types.str; type = types.path;
description = '' description = ''
Document root directory for the atftpd. Document root directory for the atftpd.
''; '';
@ -39,11 +53,11 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
systemd.services.atftpd = { systemd.services.atftpd = {
description = "atftpd TFTP server"; description = "TFTP Server";
after = [ "network.target" ]; after = [ "network.target" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
# runs as nobody # runs as nobody
serviceConfig.ExecStart = "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address 0.0.0.0 ${cfg.root}"; serviceConfig.ExecStart = "${pkgs.atftp}/sbin/atftpd --daemon --no-fork ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.root}";
}; };
}; };