1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-20 12:42:24 +00:00
nixpkgs/nixos/modules/security/apparmor.nix
Eelco Dolstra d5047faede Remove uses of the "merge" option attribute
It's redundant because you can (and should) specify an option type, or
an apply function.
2013-10-28 22:45:56 +01:00

70 lines
1.6 KiB
Nix

{pkgs, config, ...}:
let
cfg = config.security.apparmor;
in
with pkgs.lib;
{
###### interface
options = {
security.apparmor = {
enable = mkOption {
type = types.bool;
default = false;
description = ''
Enable AppArmor application security system. Enable only if
you want to further improve AppArmor.
'';
};
profiles = mkOption {
type = types.listOf types.path;
default = [];
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"; }
];
environment.systemPackages = [ pkgs.apparmor ];
systemd.services.apparmor = {
#wantedBy = [ "basic.target" ];
wantedBy = [ "local-fs.target" ];
path = [ pkgs.apparmor ];
serviceConfig = {
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;
};
};
};
}