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