Compare commits

..

No commits in common. "a958784b05b4f07612fb7f4661157f3ca58330fc" and "55b7a907e017ab1eec11055181707a5fe1a642b7" have entirely different histories.

4 changed files with 6 additions and 40 deletions

View file

@ -85,7 +85,7 @@ in
# "9p" # "9p"
"virtiofs" "virtiofs"
]; ];
boot.initrd.systemd.enable = lib.mkDefault true; boot.initrd.systemd.enable = true;
fileSystems = { fileSystems = {
"/nix/store" = { "/nix/store" = {
fsType = "overlay"; fsType = "overlay";

View file

@ -11,8 +11,8 @@
# zswap is said to be more reliable than zram # zswap is said to be more reliable than zram
boot.kernelParams = lib.optionals (!config.zramSwap.enable) [ "zswap.enabled=1" ]; boot.kernelParams = lib.optionals (!config.zramSwap.enable) [ "zswap.enabled=1" ];
} }
(lib.optionalAttrs (options ? "microvm") { (lib.optionalAttrs (options ? "microvm" && config.microvm.guest.enable) {
microvm = lib.mkIf config.microvm.guest.enable { microvm = {
hypervisor = lib.mkDefault "cloud-hypervisor"; hypervisor = lib.mkDefault "cloud-hypervisor";
graphics.enable = lib.mkDefault true; graphics.enable = lib.mkDefault true;
vcpu = lib.mkDefault 2; vcpu = lib.mkDefault 2;

View file

@ -7,32 +7,12 @@
}: }:
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 = {
@ -51,21 +31,10 @@ 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" ];
})
]; ];
} }

View file

@ -22,9 +22,6 @@ in
# https://mastodon.acm.org/@nobody/115108458851355328 # https://mastodon.acm.org/@nobody/115108458851355328
# https://github.com/linux-pam/linux-pam/issues/885#issuecomment-3030698895 # https://github.com/linux-pam/linux-pam/issues/885#issuecomment-3030698895
networking.hosts."100::" = [ "UNKNOWN" ]; networking.hosts."100::" = [ "UNKNOWN" ];
boot.initrd.extraFiles = lib.optionalAttrs config.boot.initrd.network.ssh.enable {
"/etc/hosts" = { inherit (config.environment.etc.hosts) source; };
};
} }
]; ];
} }