1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 05:31:22 +00:00
nixpkgs/nixos/modules/security/apparmor.nix

50 lines
1.3 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.";
};
2017-01-10 21:47:23 +00:00
packages = mkOption {
type = types.listOf types.package;
default = [];
description = "List of packages to be added to apparmor's include path";
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.apparmor-utils ];
2017-01-10 21:47:23 +00:00
systemd.services.apparmor = let
paths = concatMapStrings (s: " -I ${s}/etc/apparmor.d")
([ pkgs.apparmor-profiles ] ++ cfg.packages);
in {
wantedBy = [ "local-fs.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
2017-01-10 21:47:23 +00:00
ExecStart = map (p:
''${pkgs.apparmor-parser}/bin/apparmor_parser -rKv ${paths} "${p}"''
) cfg.profiles;
2017-01-10 21:47:23 +00:00
ExecStop = map (p:
''${pkgs.apparmor-parser}/bin/apparmor_parser -Rv "${p}"''
) cfg.profiles;
};
};
};
2012-07-17 00:47:41 +01:00
}