opensnitch: add package option
This commit is contained in:
parent
6ebd5c0190
commit
aadd7d26b3
@ -13,12 +13,12 @@ let
|
|||||||
file = pkgs.writeText "rule" (builtins.toJSON cfg);
|
file = pkgs.writeText "rule" (builtins.toJSON cfg);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.opensnitch = {
|
services.opensnitch = {
|
||||||
enable = lib.mkEnableOption "Opensnitch application firewall";
|
enable = lib.mkEnableOption "Opensnitch application firewall";
|
||||||
|
package = lib.mkPackageOption pkgs "opensnitch" { };
|
||||||
|
|
||||||
rules = lib.mkOption {
|
rules = lib.mkOption {
|
||||||
default = { };
|
default = { };
|
||||||
@ -192,13 +192,13 @@ in
|
|||||||
services.opensnitch.settings = lib.mapAttrs (_: v: lib.mkDefault v) (
|
services.opensnitch.settings = lib.mapAttrs (_: v: lib.mkDefault v) (
|
||||||
builtins.fromJSON (
|
builtins.fromJSON (
|
||||||
builtins.unsafeDiscardStringContext (
|
builtins.unsafeDiscardStringContext (
|
||||||
builtins.readFile "${pkgs.opensnitch}/etc/opensnitchd/default-config.json"
|
builtins.readFile "${cfg.package}/etc/opensnitchd/default-config.json"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
packages = [ pkgs.opensnitch ];
|
packages = [ cfg.package ];
|
||||||
services.opensnitchd = {
|
services.opensnitchd = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
@ -210,7 +210,7 @@ in
|
|||||||
in
|
in
|
||||||
[
|
[
|
||||||
""
|
""
|
||||||
"${pkgs.opensnitch}/bin/opensnitchd --config-file ${format.generate "default-config.json" preparedSettings}"
|
"${cfg.package}/bin/opensnitchd --config-file ${format.generate "default-config.json" preparedSettings}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
preStart = lib.mkIf (cfg.rules != { }) (
|
preStart = lib.mkIf (cfg.rules != { }) (
|
||||||
@ -245,7 +245,7 @@ in
|
|||||||
};
|
};
|
||||||
tmpfiles.rules = [
|
tmpfiles.rules = [
|
||||||
"d ${cfg.settings.Rules.Path} 0750 root root - -"
|
"d ${cfg.settings.Rules.Path} 0750 root root - -"
|
||||||
"L+ /etc/opensnitchd/system-fw.json - - - - ${pkgs.opensnitch}/etc/opensnitchd/system-fw.json"
|
"L+ /etc/opensnitchd/system-fw.json - - - - ${cfg.package}/etc/opensnitchd/system-fw.json"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user