···
# This module defines global configuration for Haka.
cfg = config.services.haka;
···
"${haka}/share/haka/sample/${cfg.configFile}"
26
-
${optionalString (builtins.lessThan 0 cfg.threads) "thread = ${cfg.threads}"}
22
+
${lib.optionalString (builtins.lessThan 0 cfg.threads) "thread = ${cfg.threads}"}
29
-
${optionalString cfg.pcap ''module = "packet/pcap"''}
30
-
${optionalString cfg.nfqueue ''module = "packet/nqueue"''}
31
-
${optionalString cfg.dump.enable ''dump = "yes"''}
32
-
${optionalString cfg.dump.enable ''dump_input = "${cfg.dump.input}"''}
33
-
${optionalString cfg.dump.enable ''dump_output = "${cfg.dump.output}"''}
25
+
${lib.optionalString cfg.pcap ''module = "packet/pcap"''}
26
+
${lib.optionalString cfg.nfqueue ''module = "packet/nqueue"''}
27
+
${lib.optionalString cfg.dump.enable ''dump = "yes"''}
28
+
${lib.optionalString cfg.dump.enable ''dump_input = "${cfg.dump.input}"''}
29
+
${lib.optionalString cfg.dump.enable ''dump_output = "${cfg.dump.output}"''}
interfaces = "${lib.strings.concatStringsSep "," cfg.interfaces}"
···
65
-
enable = mkEnableOption "Haka";
61
+
enable = lib.mkEnableOption "Haka";
67
-
package = mkPackageOption pkgs "haka" { };
63
+
package = lib.mkPackageOption pkgs "haka" { };
69
-
configFile = mkOption {
65
+
configFile = lib.mkOption {
example = "/srv/haka/myfilter.lua";
68
+
type = lib.types.str;
Specify which configuration file Haka uses.
It can be absolute path or a path relative to the sample directory of
···
80
-
interfaces = mkOption {
76
+
interfaces = lib.mkOption {
83
-
type = with types; listOf str;
79
+
type = with lib.types; listOf str;
Specify which interface(s) Haka listens to.
Use 'any' to listen to all interfaces.
90
-
threads = mkOption {
86
+
threads = lib.mkOption {
89
+
type = lib.types.int;
The number of threads that will be used.
All system threads are used by default.
96
+
pcap = lib.mkOption {
98
+
type = lib.types.bool;
description = "Whether to enable pcap";
106
-
nfqueue = mkEnableOption "nfqueue";
102
+
nfqueue = lib.mkEnableOption "nfqueue";
108
-
dump.enable = mkEnableOption "dump";
109
-
dump.input = mkOption {
104
+
dump.enable = lib.mkEnableOption "dump";
105
+
dump.input = lib.mkOption {
default = "/tmp/input.pcap";
example = "/path/to/file.pcap";
108
+
type = lib.types.path;
description = "Path to file where incoming packets are dumped";
116
-
dump.output = mkOption {
112
+
dump.output = lib.mkOption {
default = "/tmp/output.pcap";
example = "/path/to/file.pcap";
115
+
type = lib.types.path;
description = "Path to file where outgoing packets are dumped";
···
127
-
config = mkIf cfg.enable {
123
+
config = lib.mkIf cfg.enable {