From b65f1f6df7fc330f9e510217fce9bd1be8fcb832 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sun, 19 Feb 2023 17:40:05 +0000 Subject: [PATCH] nixos/containers: Ensure containers have cgroupsv2 --- nixos/modules/containers.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nixos/modules/containers.nix b/nixos/modules/containers.nix index 2277c99..4701609 100644 --- a/nixos/modules/containers.nix +++ b/nixos/modules/containers.nix @@ -182,8 +182,12 @@ in c.containerSystem; in { - # systemd.nspawn units can't set the root directory directly, but /run/machines/${n} is one of the search paths - environment.root = "/run/machines/${n}"; + environment = { + # systemd.nspawn units can't set the root directory directly, but /run/machines/${n} is one of the search paths + root = "/run/machines/${n}"; + # Without this, systemd-nspawn will do cgroupsv1 + SYSTEMD_NSPAWN_UNIFIED_HIERARCHY = "1"; + }; restartTriggers = [ (''${n}.nspawn:${hashString "sha256" (toJSON config.systemd.nspawn."${n}")}'') ];