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