From 0c2dcfdadcf863fb7fd1be2c99cf53685e40dfef Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 00:39:33 +0000 Subject: strip down the guest Import the minimal and perlless profiles, and turn off what a throwaway VM with a read-only store doesn't need: firewall (which also failed to start with the cut-down kernel), timesyncd (kvm-clock keeps time), nscd, sudo and setuid wrappers, coredumps, oomd, TPM2, fstrim, lvm, bcache, kexec, containers, lingering, nano, fuse and switch-to-configuration. This shrinks the guest closure from 709 MiB to 560 MiB with the default kernel, most of what's left being kernel modules, systemd and glibc. --- default.nix | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index ffc9293..6bb6d08 100644 --- a/default.nix +++ b/default.nix @@ -6,10 +6,14 @@ let nixos = import (pkgs.path + "/nixos") { inherit (pkgs) system; - configuration = { config, ... }: { + configuration = { modulesPath, ... }: { + imports = [ + (modulesPath + "/profiles/minimal.nix") + (modulesPath + "/profiles/perlless.nix") + ]; + system.stateVersion = lib.trivial.release; - boot.loader.grub.enable = false; boot.kernelPackages = kernelPackages; boot.initrd.allowMissingModules = true; # e.g. ahci, efivarfs with a cut-down kernel boot.initrd.kernelModules = [ "virtio_mmio" "virtio_blk" "erofs" ]; @@ -29,9 +33,29 @@ let }; services.getty.autologinUser = "root"; + networking.useDHCP = false; + + boot.bcache.enable = false; + boot.enableContainers = false; + boot.initrd.systemd.tpm2.enable = false; + boot.kexec.enable = false; + networking.firewall.enable = false; nix.enable = false; - documentation.enable = false; + powerManagement.enable = false; + programs.fuse.enable = false; + programs.nano.enable = false; + security.sudo.enable = false; + services.fstrim.enable = false; + services.lvm.enable = false; + services.nscd.enable = false; + services.timesyncd.enable = false; + system.nssModules = lib.mkForce [ ]; + system.switch.enable = false; + systemd.coredump.enable = false; + systemd.oomd.enable = false; + systemd.tpm2.enable = false; + users.manageLingering = false; }; }; -- cgit v1.3.1