12 config = mkIf config.boot.isContainer {
14 # Disable some features that are not useful in a container.
16 # containers don't have a kernel
17 boot.kernel.enable = false;
18 boot.modprobeConfig.enable = false;
20 console.enable = mkDefault false;
22 nix.optimise.automatic = mkDefault false; # the store is host managed
23 powerManagement.enable = mkDefault false;
24 documentation.nixos.enable = mkDefault false;
26 networking.useHostResolvConf = mkDefault true;
28 # Containers should be light-weight, so start sshd on demand.
29 services.openssh.startWhenNeeded = mkDefault true;
31 # containers do not need to setup devices
32 services.udev.enable = false;
34 # containers normally do not need to manage logical volumes
35 services.lvm.enable = lib.mkDefault false;
37 # Shut up warnings about not having a boot loader.
38 system.build.installBootLoader = lib.mkDefault "${pkgs.coreutils}/bin/true";
40 # Not supported in systemd-nspawn containers.
41 security.audit.enable = false;
43 # Use the host's nix-daemon.
44 environment.variables.NIX_REMOTE = "daemon";