nixpkgs/modules/security/apparmor.nix

59 lines
1.1 KiB
Nix
Raw Normal View History

2012-07-17 01:47:41 +02:00
{pkgs, config, ...}:
let
cfg = config.security.apparmor;
in
with pkgs.lib;
{
###### interface
options = {
security.apparmor = {
enable = mkOption {
default = false;
description = ''
2013-05-10 13:57:48 +02:00
Enable AppArmor application security system. Enable only if you want to further improve
AppArmor.
2012-07-17 01:47:41 +02:00
'';
};
profiles = mkOption {
default = [];
merge = mergeListOption;
description = ''
List of file names of AppArmor profiles.
'';
};
};
};
###### implementation
config = mkIf (cfg.enable) {
assertions = [ { assertion = config.boot.kernelPackages.kernel.features ? apparmor
&& config.boot.kernelPackages.kernel.features.apparmor;
message = "AppArmor is enabled, but the kernel doesn't have AppArmor support"; }
];
2012-07-17 01:47:41 +02:00
jobs.apparmor =
{ startOn = "startup";
path = [ pkgs.apparmor ];
preStart = concatMapStrings (profile: ''
apparmor_parser -Kv -I ${pkgs.apparmor}/etc/apparmor.d/ "${profile}"
'') cfg.profiles;
postStop = ''
'';
};
};
}