Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions nixos/modules/config/sysmodule.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ config, lib, ... }:
let
cfg = config.boot.kernel.sysmodule;

kernelParamOptionType = lib.mkOptionType {
name = "kernel command-line parameters option value";
check =
val:
let
checkType = x: lib.isBool x || lib.isString x || lib.isInt x || x == null;
in
checkType val || (val._type or "" == "override" && checkType val.content);
merge = loc: defs: lib.mergeOneOption loc (lib.filterOverrides defs);
};

in
{
options.boot.kernel.sysmodule = lib.mkOption {
type = lib.types.submodule {
freeformType = lib.types.attrsOf (lib.types.attrsOf kernelParamOptionType);
};
};

config.systemd.tmpfiles.settings.sysmodule = lib.listToAttrs (
lib.concatLists (
lib.mapAttrsToList (
moduleName: v:
lib.mapAttrsToList (paramName: paramValue: {
name = "/sys/module/${moduleName}/parameters/${paramName}";
value = lib.mkIf (paramValue != null) {
"w-".argument = if paramValue == false then "0" else toString paramValue;
};
}) v
) cfg
)
);
}
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
./config/stub-ld.nix
./config/swap.nix
./config/sysctl.nix
./config/sysmodule.nix
./config/system-environment.nix
./config/system-path.nix
./config/terminfo.nix
Expand Down
Loading