grimm-nixos-laptop/common/tooling/apparmor/default.nix

178 lines
4.6 KiB
Nix
Raw Normal View History

2024-10-12 18:19:18 +02:00
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
2024-10-13 13:44:16 +02:00
inherit (lib) mkIf optionalString getExe' getExe;
2024-10-12 18:19:18 +02:00
apparmor-d = pkgs.callPackage ./apparmor-d.nix {};
2024-10-13 13:44:16 +02:00
allowFingerprinting = true;
2024-10-12 18:19:18 +02:00
in
{
config = mkIf (enable && tooling.enable) {
services.dbus.apparmor = "enabled";
security.auditd.enable = true;
security.apparmor.packages = [ apparmor-d ];
security.apparmor.enable = true;
2024-10-13 13:44:16 +02:00
2024-10-12 18:19:18 +02:00
security.apparmor.includes = {
2024-10-13 13:44:16 +02:00
"abstractions/base" = ''
2024-10-12 21:01:10 +02:00
/nix/store/*/bin/** mr,
/nix/store/*/lib/** mr,
/nix/store/** r,
'';
2024-10-13 13:44:16 +02:00
"local/speech-dispatcher" = ''
${pkgs.speechd}/libexec/speech-dispatcher-modules/* rix,
@{PROC}/@{pid}/stat r,
@{bin}/mbrola rix,
'';
2024-10-13 14:28:46 +02:00
"local/pass" = ''
${getExe' pkgs.pass ".pass-wrapped"} rix,
${getExe' pkgs.coreutils "coreutils"} rix,
'';
"local/firefox" = ''
${pkgs.passff-host}/share/** rPx -> passff,
'';
2024-10-13 13:44:16 +02:00
"local/thunderbird" = ''
${getExe' pkgs.thunderbird ".thunderbird-wrapped_"} rix,
/dev/urandom w,
'';
"local/xdg-open" = ''
${getExe' pkgs.coreutils "coreutils"} rix,
/proc/version r,
'';
"local/vesktop" = ''
@{bin}/electron rix,
/nix/store/*/libexec/electron/** rix,
@{bin}/speech-dispatcher rPx,
@{bin}/xdg-open rPx,
'' + (optionalString allowFingerprinting ''
/etc/machine-id r,
/dev/udmabuf rw,
/dev/ r,
/sys/devices/@{pci}boot_vga r,
/sys/devices/@{pci}idVendor r,
/sys/devices/@{pci}idProduct r,
'');
2024-10-12 18:19:18 +02:00
};
2024-10-12 21:01:10 +02:00
security.apparmor.policies = {
2024-10-13 14:28:46 +02:00
passff = {
enable = true;
enforce = true;
profile = ''
abi <abi/4.0>,
include <tunables/global>
profile passff ${pkgs.passff-host}/share/passff-host/passff.py {
include <abstractions/base> # read access to /nix/store, basic presets for most apps
include <abstractions/python>
${getExe pkgs.pass} Px,
}
'';
};
2024-10-13 13:44:16 +02:00
swaymux = {
enable = true;
enforce = true;
profile = ''
abi <abi/4.0>,
include <tunables/global>
profile swaymux ${getExe pkgs.swaymux} {
include <abstractions/base> # read access to /nix/store, basic presets for most apps
${pkgs.swaymux}/bin/* rix, # wrapping
owner @{user_config_dirs}/Kvantum/** r, # themeing
}
'';
};
2024-10-12 21:01:10 +02:00
vesktop = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-s-z/vesktop"
'';
};
2024-10-13 13:44:16 +02:00
speech-dispatcher = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-s-z/speech-dispatcher"
'';
};
spotify = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-s-z/spotify"
'';
};
thunderbird = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-s-z/thunderbird"
'';
};
thunderbird-glxtest = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-s-z/thunderbird-glxtest"
'';
};
xdg-open = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/groups/freedesktop/xdg-open"
'';
};
child-open-any = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/groups/children/child-open-any"
'';
};
child-open = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/groups/children/child-open"
'';
};
2024-10-13 14:28:46 +02:00
firefox-glxtest = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/groups/browsers/firefox-glxtest"
'';
};
firefox = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/groups/browsers/firefox"
'';
};
pass = {
enable = true;
enforce = true;
profile = ''
include "${apparmor-d}/etc/apparmor.d/profiles-m-r/pass"
'';
};
2024-10-12 21:01:10 +02:00
};
2024-10-12 18:19:18 +02:00
};
}