(Mildly cursed) I figured out how to build my server's NixOS config as a Docker ...

@xy@mastodon.mit.edu

(Mildly cursed) I figured out how to build my server's NixOS config as a Docker image and run it in a libkrun microVM!

In short you add "${nixpkgs}/nixos/modules/profiles/docker-container.nix" as a module, then build it with:

pkgs.dockerTools.buildLayeredImage {
contents = [ self.nixosConfigurations.blah.config.system.build.toplevel ];
config.Entrypoint = [ "/init" ];
extraCommands = ''
rm -f etc
mkdir etc
'';
};

Finally run: podman run --runtime=krun -e KRUN_INIT_PID1=1 image