zswap in uvms: optional/configurable
This commit is contained in:
parent
0bebc13927
commit
61dd3938aa
1 changed files with 34 additions and 3 deletions
|
|
@ -7,12 +7,32 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
mkIfGuest = import ../lib/mkIfMicrovmGuest.nix { inherit options config lib; };
|
mkIfGuest = import ../lib/mkIfMicrovmGuest.nix { inherit options config lib; };
|
||||||
|
inherit (lib) types;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./vsock-connect-guest.nix
|
./vsock-connect-guest.nix
|
||||||
./uvms-users.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 [
|
config = lib.mkMerge [
|
||||||
(mkIfGuest {
|
(mkIfGuest {
|
||||||
microvm = {
|
microvm = {
|
||||||
|
|
@ -31,10 +51,21 @@ in
|
||||||
size = 768;
|
size = 768;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
systemd.services."microvm@".serviceConfig.ExecStartPost = [
|
||||||
|
(pkgs.writeShellScript "microvm-fix-umask" ''
|
||||||
|
if [[ -e CONNECT.sock ]] ; then
|
||||||
|
chmod g+rw CONNECT.sock
|
||||||
|
fi
|
||||||
|
'')
|
||||||
|
];
|
||||||
})
|
})
|
||||||
{
|
(lib.mkIf config.uvms.zswap.enable {
|
||||||
boot.kernelParams = [ "zswap.enabled=1" ];
|
|
||||||
zramSwap.enable = false;
|
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