at 25.11-pre 2.4 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 cfg = config.services.icecream.scheduler; 12in 13{ 14 15 ###### interface 16 17 options = { 18 19 services.icecream.scheduler = { 20 enable = mkEnableOption "Icecream Scheduler"; 21 22 netName = mkOption { 23 type = types.nullOr types.str; 24 default = null; 25 description = '' 26 Network name for the icecream scheduler. 27 28 Uses the default ICECREAM if null. 29 ''; 30 }; 31 32 port = mkOption { 33 type = types.port; 34 default = 8765; 35 description = '' 36 Server port to listen for icecream daemon requests. 37 ''; 38 }; 39 40 openFirewall = mkOption { 41 type = types.bool; 42 description = '' 43 Whether to automatically open the daemon port in the firewall. 44 ''; 45 }; 46 47 openTelnet = mkOption { 48 type = types.bool; 49 default = false; 50 description = '' 51 Whether to open the telnet TCP port on 8766. 52 ''; 53 }; 54 55 persistentClientConnection = mkOption { 56 type = types.bool; 57 default = false; 58 description = '' 59 Whether to prevent clients from connecting to a better scheduler. 60 ''; 61 }; 62 63 package = mkPackageOption pkgs "icecream" { }; 64 65 extraArgs = mkOption { 66 type = types.listOf types.str; 67 default = [ ]; 68 description = "Additional command line parameters"; 69 example = [ "-v" ]; 70 }; 71 }; 72 }; 73 74 ###### implementation 75 76 config = mkIf cfg.enable { 77 networking.firewall.allowedTCPPorts = mkMerge [ 78 (mkIf cfg.openFirewall [ cfg.port ]) 79 (mkIf cfg.openTelnet [ 8766 ]) 80 ]; 81 82 systemd.services.icecc-scheduler = { 83 description = "Icecream scheduling server"; 84 after = [ "network.target" ]; 85 wantedBy = [ "multi-user.target" ]; 86 87 serviceConfig = { 88 ExecStart = escapeShellArgs ( 89 [ 90 "${getBin cfg.package}/bin/icecc-scheduler" 91 "-p" 92 (toString cfg.port) 93 ] 94 ++ optionals (cfg.netName != null) [ 95 "-n" 96 (toString cfg.netName) 97 ] 98 ++ optional cfg.persistentClientConnection "-r" 99 ++ cfg.extraArgs 100 ); 101 102 DynamicUser = true; 103 }; 104 }; 105 }; 106 107 meta.maintainers = with lib.maintainers; [ emantor ]; 108}