Compare commits

...

4 commits

Author SHA1 Message Date
Else, Someone
a958784b05 zswap in uvms: optional/configurable 2025-10-09 04:14:16 +03:00
Else, Someone
0bebc13927 vsock ssh: set up UNKNOWN /etc/hosts in initrd too 2025-10-09 04:12:06 +03:00
Else, Someone
33d33e745b ch-runner: make initrd systemd optional 2025-10-09 04:11:37 +03:00
Else, Someone
1b889d5b19 resources.nix: prevent infinite recursion 2025-10-09 04:11:18 +03:00
4 changed files with 40 additions and 6 deletions

View file

@ -85,7 +85,7 @@ in
# "9p" # "9p"
"virtiofs" "virtiofs"
]; ];
boot.initrd.systemd.enable = true; boot.initrd.systemd.enable = lib.mkDefault 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" && config.microvm.guest.enable) { (lib.optionalAttrs (options ? "microvm") {
microvm = { microvm = lib.mkIf config.microvm.guest.enable {
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,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" ];
})
]; ];
} }

View file

@ -22,6 +22,9 @@ 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; };
};
} }
]; ];
} }