How to run `nixos-rebuild --target-host` from Darwin?

I want to trigger nixos-rebuild switch remotely, using a local file from a Darwin machine. For the purpose of tinkering with an existing NixOS machine on the network, NixOps is overkill. If I were on Linux, I’d just run

nixos-rebuild switch --target-host=<target> configuration.nix

but Darwin naturally does not have nixos-rebuild. Did anybody try something like this already? Will nix complain about the platform even if the target is Linux?

More generally, how do I get an executable from a package in a NixOS module to run on Darwin (assuming all dependencies are compatible)? Do I really have to trick the NixOS tools module into outputting a package that I can capture for my purposes by supplying arguments that are convincing enough?

I haven’t tried this yet, but it’s on my TODO list, but I think you can just copy nixos-rebuild from say here: https://github.com/Kloenk/nix/blob/beb7c9abd050d62babb02cce5eeac53b8cf249ec/nixos-rebuild

and go to town. If you do try it, please update here how it worked out!