2014-06-12 06:36:16 +01:00
|
|
|
# NixOS module for atftpd TFTP server
|
|
|
|
|
2014-09-29 14:45:59 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2014-06-12 06:36:16 +01:00
|
|
|
|
2014-09-29 14:45:59 +01:00
|
|
|
with lib;
|
2014-06-12 06:36:16 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.atftpd;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.atftpd = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2015-06-15 17:10:26 +01:00
|
|
|
type = types.bool;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2016-10-16 16:54:49 +01:00
|
|
|
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;
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression ''
|
2016-10-16 16:54:49 +01:00
|
|
|
[ "--bind-address 192.168.9.1"
|
|
|
|
"--verbose=7"
|
|
|
|
]
|
|
|
|
'';
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2016-10-16 16:54:49 +01:00
|
|
|
Extra command line arguments to pass to atftp.
|
2014-06-12 06:36:16 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
root = mkOption {
|
2016-10-16 16:54:49 +01:00
|
|
|
default = "/srv/tftp";
|
|
|
|
type = types.path;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2014-06-12 06:36:16 +01:00
|
|
|
Document root directory for the atftpd.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.atftpd = {
|
2016-10-16 16:54:49 +01:00
|
|
|
description = "TFTP Server";
|
2014-06-12 06:36:16 +01:00
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
# runs as nobody
|
2016-10-16 16:54:49 +01:00
|
|
|
serviceConfig.ExecStart = "${pkgs.atftp}/sbin/atftpd --daemon --no-fork ${lib.concatStringsSep " " cfg.extraOptions} ${cfg.root}";
|
2014-06-12 06:36:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|