There’s been some talk about generalizing nixos modules to be less dependent on systemd - in theory that would allow sharing more code between nixos, home-manager, nix-on-non-nixos, docker, etc.
The main RFC is https://github.com/NixOS/rfcs/pull/163 I think, and it was recently discussed at in the Brainstorm for RFC: Assimilate home-manager into Nixpkgs monorepo - #14 by waffle8946 thread.
I love the goal, but I’m not sure yet whether ‘more layers of indirection’ will work out - sometimes ‘multiple simple abstractions’ turns out to be simpler than ‘one general abstraction’, however much we’d like that not to be the case