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