nixpkgs/nixos/modules/security/apparmor.nix

51 lines
1.4 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2013-05-13 13:13:06 +00:00
with lib;
2012-07-16 23:47:41 +00:00
let
cfg = config.security.apparmor;
in
{
options = {
security.apparmor = {
enable = mkOption {
type = types.bool;
2012-07-16 23:47:41 +00:00
default = false;
description = "Enable the AppArmor Mandatory Access Control system.";
2012-07-16 23:47:41 +00:00
};
profiles = mkOption {
type = types.listOf types.path;
2012-07-16 23:47:41 +00:00
default = [];
description = "List of files containing AppArmor profiles.";
2012-07-16 23:47:41 +00:00
};
};
};
config = mkIf cfg.enable {
assertions =
[ { assertion = config.boot.kernelPackages.kernel.features ? apparmor
&& config.boot.kernelPackages.kernel.features.apparmor;
message = "Your selected kernel does not have AppArmor support";
}
];
environment.systemPackages = [ pkgs.apparmor ];
systemd.services.apparmor = {
wantedBy = [ "local-fs.target" ];
path = [ pkgs.apparmor ];
serviceConfig = {
2013-05-13 13:13:06 +00: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-16 23:47:41 +00:00
};
};
2012-07-16 23:47:41 +00:00
};
}