aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 00:39:33 +0000
committertv <tv@krebsco.de>2026-11-16 00:39:33 +0000
commit0c2dcfdadcf863fb7fd1be2c99cf53685e40dfef (patch)
treec920b36610c0db661d02e006e4f1672e0c1fb36d
parent0eba74df49cec656a6d84fd923e50c5b2d1a4566 (diff)
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.
-rw-r--r--default.nix30
1 files 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;
};
};