2
0

add options for setting sysctl parameters at boot time

This commit is contained in:
2025-11-11 20:52:58 +00:00
parent 8646677ead
commit d538e8f6cf
4 changed files with 52 additions and 0 deletions
+1
View File
@@ -113,6 +113,7 @@ in
};
};
};
imports = [ ./early ];
config = {
defaultProfile.packages = with pkgs; [
s6
+37
View File
@@ -0,0 +1,37 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkOption types;
inherit (pkgs.pseudofile) dir symlink;
in
{
options = {
early = with types; {
sysctl = mkOption {
type = attrsOf anything;
description = "sysctl definitions to set at early boot";
example = {
vm.overcommit_memory = 0;
user.max_cgroup_namespaces = 62933;
net.ipv6.route.gc_timeout = 60;
};
};
};
};
config.filesystem = dir {
etc =
let
sysctls = pkgs.writeAshScript "sysctls" { } ''
cd /proc/sys
${pkgs.liminix.writeSysctls config.early.sysctl}
'';
in
dir {
"sysctl.sh" = symlink sysctls;
};
};
}
+2
View File
@@ -27,6 +27,8 @@ if test -c /dev/pmsg0 ; then
(cat /sys/fs/pstore/* && rm /sys/fs/pstore/*) > /run/log/previous-boot
fi
/etc/sysctl.sh
mkdir -m 0751 -p /run/services/outputs
chgrp system /run/services/outputs
+12
View File
@@ -22,6 +22,18 @@ in
uimage = callPackage ./kernel/uimage.nix { };
kernel = callPackage ./kernel { };
};
writeSysctls =
let
inherit (lib) concatStringsSep collect mapAttrsRecursive;
in
s:
concatStringsSep "\n" (
collect (x: !builtins.isAttrs x) (
mapAttrsRecursive (
p: v: "echo ${builtins.toJSON (builtins.toString v)} > ${concatStringsSep "/" p}"
) s
)
);
outputRef =
service: path:
let