usbguard: add enable option, enable on temperance

This commit is contained in:
Charlie Root 2025-04-06 23:17:40 +02:00
commit 41b3d31129
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
2 changed files with 20 additions and 12 deletions

View file

@ -80,6 +80,7 @@ in {
services = { services = {
locate.enable = true; locate.enable = true;
usbguard.enable = true;
media.mpd = { media.mpd = {
enable = true; enable = true;

View file

@ -5,9 +5,15 @@
... ...
}: let }: let
inherit (config.meta.mainUser) username; inherit (config.meta.mainUser) username;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.services.usbguard;
in { in {
options.modules.services.usbguard.enable = mkEnableOption "usbguard";
config = mkIf cfg.enable {
environment.systemPackages = [pkgs.usbguard]; environment.systemPackages = [pkgs.usbguard];
services.usbguard = { services.usbguard = {
enable = true;
IPCAllowedUsers = ["root" "${username}"]; IPCAllowedUsers = ["root" "${username}"];
presentDevicePolicy = "allow"; presentDevicePolicy = "allow";
rules = '' rules = ''
@ -20,4 +26,5 @@ in {
reject with-interface all-of { 08:*:* 02:*:* } reject with-interface all-of { 08:*:* 02:*:* }
''; '';
}; };
};
} }