nixpkgs/nixos/modules/security/apparmor.nix

42 lines
1.1 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2013-05-13 14:13:06 +01:00
2012-07-17 00:47:41 +01:00
let
inherit (lib) mkIf mkOption types concatMapStrings;
2012-07-17 00:47:41 +01:00
cfg = config.security.apparmor;
in
2012-07-17 00:47:41 +01:00
{
options = {
security.apparmor = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable the AppArmor Mandatory Access Control system.";
};
profiles = mkOption {
type = types.listOf types.path;
default = [];
description = "List of files containing AppArmor profiles.";
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.apparmor-utils ];
systemd.services.apparmor = {
wantedBy = [ "local-fs.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = concatMapStrings (p:
''${pkgs.apparmor-parser}/bin/apparmor_parser -rKv -I ${pkgs.apparmor-profiles}/etc/apparmor.d "${p}" ; ''
) cfg.profiles;
ExecStop = concatMapStrings (p:
''${pkgs.apparmor-parser}/bin/apparmor_parser -Rv "${p}" ; ''
) cfg.profiles;
};
};
};
2012-07-17 00:47:41 +01:00
}