From 4ceba60918091ebd70eca51f229b2424c605b106 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sun, 12 Jun 2022 12:51:47 +0100 Subject: [PATCH] nixos/containers: Fix users and group revival --- nixos/modules/containers.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nixos/modules/containers.nix b/nixos/modules/containers.nix index d26b1ff..17f56a5 100644 --- a/nixos/modules/containers.nix +++ b/nixos/modules/containers.nix @@ -246,10 +246,22 @@ in ]; my = { - tmproot.enable = true; + tmproot = { + enable = true; + persistence.dir = "/persist"; + }; }; system.activationScripts = { + # So that update-users-groups.pl can see the saved info. Normally stage-1-init.sh would do these mounts early. + earlyPersist.text = '' + if ! mountpoint -q /var/lib/nixos; then + mkdir -p {/persist,}/var/lib/nixos + mount --bind {/persist,}/var/lib/nixos + fi + ''; + users.deps = [ "earlyPersist" ]; + # Ordinarily I think the Nix daemon does this but ofc it doesn't in the container createNixPerUserDirs = { text =