Thanks, I see.
My use cases is essentially creating an isolated environment for users in a dynamic way, so I can’t really define all instances ahead of time. In that case, I wonder if this would work, and if there would be any downsides to it? Basically, i would have a script run this command, with instanceName
dynamically generated:
extra-container create -s <<'EOF'
{ config, pkgs, lib, ... }:
let
sharedConfig = {
config = {
systemd.services.hello = {
wantedBy = [ "multi-user.target" ];
script = "while true; do echo hello | ${pkgs.netcat}/bin/nc -lN 50; done";
};
};
};
in {
containers = {
instanceName= sharedConfig;
};
}
EOF
sharedConfig
could probably be factored out, though I don’t know if it matters since I think Nix should be able to tell if nix expressions defined in multiple places are effectively identical.
What would be the typical start up time of a container that doesn’t have any services or other extra initialization in this fashion? I’m hoping fairly quick - otherwise I may stick with a running container, possibly going with your original suggestion and firing up multiple instances and rotating between them as a compromise.