Thanks. Until now I always thought of NixOS as some kind of separate wrapper around Nix, some tooling from a different repo + Nix if you wish. But apparently
nixpkgs has all
nixos derivations inside. That means Nix has “bateries included”. I mean in hindsight it’s obvious, but I never thought about that.
At some point NixOS was a separate repository (But coordination became annoying). And Nix per se definitely doesn’t require using specifically Nixpkgs!
nixos-shell is a really nice thing. It does quite some stuff, but am I correct that the “essence” of it is:
nix-build '<nixpkgs/nixos>' -A vm
I think it was more towards a container, but generally yes.
So basically I could instantiate <nixpkgs/nixos> and then symlink systemd services?
Yes, you can also do that. My example does not build a full NixOS system and does not have sufficient config for that, but you can even build «the NixOS you would prefer to run here» and use a few units out of it.
Of course, as you will not want to use some (that overlap with Debian-provided ones), you need to be careful and keep track of NixOS unit names changing. It doesn’t seem to be a frequent event, but NixOS does not promise anything about the unit names… You can probably automatically assert the existence of the chosen units, but in principle there might also be a problem with NixOS changing the unit dependencies.