nixpkgs-suyu/nixos/modules/security/apparmor.nix

70 lines
1.6 KiB
Nix
Raw Normal View History

2012-07-17 01:47:41 +02:00
{pkgs, config, ...}:
2013-05-13 15:13:06 +02:00
2012-07-17 01:47:41 +02:00
let
cfg = config.security.apparmor;
in
2013-05-13 15:13:06 +02:00
2012-07-17 01:47:41 +02:00
with pkgs.lib;
2013-05-13 15:13:06 +02:00
2012-07-17 01:47:41 +02:00
{
###### interface
options = {
security.apparmor = {
enable = mkOption {
type = types.bool;
2012-07-17 01:47:41 +02:00
default = false;
description = ''
2013-05-13 15:13:06 +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 {
type = types.listOf types.path;
2012-07-17 01:47:41 +02:00
default = [];
description = ''
2013-05-13 15:13:06 +02:00
List of file names of AppArmor profiles.
'';
2012-07-17 01:47:41 +02:00
};
};
};
###### 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"; }
];
environment.systemPackages = [ pkgs.apparmor ];
systemd.services.apparmor = {
#wantedBy = [ "basic.target" ];
wantedBy = [ "local-fs.target" ];
path = [ pkgs.apparmor ];
serviceConfig = {
2013-05-13 15:13:06 +02:00
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = concatMapStrings (profile:
''${pkgs.apparmor}/sbin/apparmor_parser -rKv -I ${pkgs.apparmor}/etc/apparmor.d/ "${profile}" ; ''
) cfg.profiles;
ExecStop = concatMapStrings (profile:
''${pkgs.apparmor}/sbin/apparmor_parser -Rv -I ${pkgs.apparmor}/etc/apparmor.d/ "${profile}" ; ''
) cfg.profiles;
2012-07-17 01:47:41 +02:00
};
};
2012-07-17 01:47:41 +02:00
};
}