mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-11-16 13:21:01 +01:00
31 lines
1.0 KiB
Nix
31 lines
1.0 KiB
Nix
{ lib, outputs }:
|
|
lib.genAttrs (builtins.attrNames outputs.nixosConfigurations) (
|
|
name:
|
|
let
|
|
config = outputs.nixosConfigurations.${name}.config;
|
|
keys = [
|
|
"kernel.dmesg_restrict"
|
|
"kernel.kptr_restrict"
|
|
"kernel.yama.ptrace_scope"
|
|
"kernel.perf_event_paranoid"
|
|
"kernel.unprivileged_bpf_disabled"
|
|
"net.core.bpf_jit_harden"
|
|
"vm.unprivileged_userfaultfd"
|
|
"fs.protected_symlinks"
|
|
"fs.protected_hardlinks"
|
|
"fs.protected_fifos"
|
|
"fs.protected_regular"
|
|
];
|
|
in
|
|
{
|
|
sysctl = lib.genAttrs keys (key: config.boot.kernel.sysctl.${key} or null);
|
|
# Nix sandbox, rootless Podman and application sandboxes need user namespaces.
|
|
inherit (config.security) allowUserNamespaces;
|
|
# An ordinary host exception must win without mkForce or a merge conflict.
|
|
hostOverride =
|
|
(outputs.nixosConfigurations.${name}.extendModules {
|
|
modules = [ { boot.kernel.sysctl."kernel.kptr_restrict" = 1; } ];
|
|
}).config.boot.kernel.sysctl."kernel.kptr_restrict";
|
|
}
|
|
)
|