mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
nixos/security: add landlock, yama, and bpf defaults
This commit is contained in:
parent
558478154c
commit
22f2e258af
1 changed files with 22 additions and 12 deletions
|
@ -5,7 +5,7 @@ in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
security.lsm = lib.mkOption {
|
security.lsm = lib.mkOption {
|
||||||
type = lib.types.uniq (lib.types.listOf lib.types.str);
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = ''
|
description = ''
|
||||||
A list of the LSMs to initialize in order.
|
A list of the LSMs to initialize in order.
|
||||||
|
@ -13,7 +13,16 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (lib.lists.length cfg.lsm > 0) {
|
config = lib.mkMerge [
|
||||||
|
{
|
||||||
|
# We set the default LSM's here due to them not being present if set when enabling AppArmor.
|
||||||
|
security.lsm = [
|
||||||
|
"landlock"
|
||||||
|
"yama"
|
||||||
|
"bpf"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
(lib.mkIf (lib.lists.length cfg.lsm > 0) {
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = builtins.length (lib.filter (lib.hasPrefix "security=") config.boot.kernelParams) == 0;
|
assertion = builtins.length (lib.filter (lib.hasPrefix "security=") config.boot.kernelParams) == 0;
|
||||||
|
@ -24,5 +33,6 @@ in
|
||||||
boot.kernelParams = [
|
boot.kernelParams = [
|
||||||
"lsm=${lib.concatStringsSep "," cfg.lsm}"
|
"lsm=${lib.concatStringsSep "," cfg.lsm}"
|
||||||
];
|
];
|
||||||
};
|
})
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue