at 23.11-pre 1.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.fireqos; 7 fireqosConfig = pkgs.writeText "fireqos.conf" "${cfg.config}"; 8in { 9 options.services.fireqos = { 10 enable = mkOption { 11 type = types.bool; 12 default = false; 13 description = lib.mdDoc '' 14 If enabled, FireQOS will be launched with the specified 15 configuration given in `config`. 16 ''; 17 }; 18 19 config = mkOption { 20 type = types.str; 21 default = ""; 22 example = '' 23 interface wlp3s0 world-in input rate 10mbit ethernet 24 class web commit 50kbit 25 match tcp ports 80,443 26 27 interface wlp3s0 world-out input rate 10mbit ethernet 28 class web commit 50kbit 29 match tcp ports 80,443 30 ''; 31 description = lib.mdDoc '' 32 The FireQOS configuration goes here. 33 ''; 34 }; 35 }; 36 37 config = mkIf cfg.enable { 38 systemd.services.fireqos = { 39 description = "FireQOS"; 40 after = [ "network.target" ]; 41 serviceConfig = { 42 Type = "oneshot"; 43 RemainAfterExit = true; 44 ExecStart = "${pkgs.firehol}/bin/fireqos start ${fireqosConfig}"; 45 ExecStop = [ 46 "${pkgs.firehol}/bin/fireqos stop" 47 "${pkgs.firehol}/bin/fireqos clear_all_qos" 48 ]; 49 }; 50 }; 51 }; 52}