zswap in uvms: optional/configurable
This commit is contained in:
parent
0bebc13927
commit
a958784b05
1 changed files with 34 additions and 3 deletions
|
|
@ -7,12 +7,32 @@
|
|||
}:
|
||||
let
|
||||
mkIfGuest = import ../lib/mkIfMicrovmGuest.nix { inherit options config lib; };
|
||||
inherit (lib) types;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./vsock-connect-guest.nix
|
||||
./uvms-users.nix
|
||||
];
|
||||
options = {
|
||||
uvms.zswap.enable = lib.mkEnableOption "Pass zswap.enabled=1 to kernelParams (and disable zramSwap)";
|
||||
uvms.zswap.settings = lib.mkOption {
|
||||
description = "Zswap kernel module configuration";
|
||||
type = types.submodule {
|
||||
freeformType = types.attrsOf types.str;
|
||||
options.max_pool_percent = lib.mkOption {
|
||||
type = types.int;
|
||||
default = 25;
|
||||
description = "...";
|
||||
};
|
||||
options.compressor = lib.mkOption {
|
||||
type = types.str;
|
||||
default = "zstd";
|
||||
description = "...";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkMerge [
|
||||
(mkIfGuest {
|
||||
microvm = {
|
||||
|
|
@ -31,10 +51,21 @@ in
|
|||
size = 768;
|
||||
}
|
||||
];
|
||||
systemd.services."microvm@".serviceConfig.ExecStartPost = [
|
||||
(pkgs.writeShellScript "microvm-fix-umask" ''
|
||||
if [[ -e CONNECT.sock ]] ; then
|
||||
chmod g+rw CONNECT.sock
|
||||
fi
|
||||
'')
|
||||
];
|
||||
})
|
||||
{
|
||||
boot.kernelParams = [ "zswap.enabled=1" ];
|
||||
(lib.mkIf config.uvms.zswap.enable {
|
||||
zramSwap.enable = false;
|
||||
}
|
||||
boot.kernelParams =
|
||||
builtins.attrValues (lib.mapAttrs (
|
||||
name: value: "zswap.${name}=${toString value}"
|
||||
)) config.uvms.zswap.settings
|
||||
++ [ "zswap.enabled=1" ];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue