maralorn / nix-output-monitor

Pipe your nix-build output through the nix-output-monitor a.k.a nom to get additional information while building.
GNU Affero General Public License v3.0
835 stars 24 forks source link

add nom run #110

Open takeda opened 1 year ago

takeda commented 1 year ago

Is there a reason why nix run does not have equivalent in nom?

I'm able to use: nix run --log-format internal-json .#docker.copyToDockerDaemon |& nom --json and it seems to work.

maralorn commented 1 year ago

The problem is, that once nix finishes fetching or building the program it starts running it. And then piping stdout and stdin through nom is most likely not what you want. Imagine how broken this would be if you do nom run nixpkgs#htop. So we need a way to determine that nix has finished so that we can somehow switch into pass-through mode. This is the same problem as with nix shell and nix develop and I don’t know if there is a good solution for this.

takeda commented 1 year ago

I see, I mostly use it with https://github.com/nlewo/nix2container and current output is good enough.

Atemu commented 5 months ago

A not very clean but simple solution would be to translate the nom run ... to nom build ... --no-link) and then exec into nix run ... at the end.

This way all output paths are cached and nix run would only need to eval. The only slight issue would be that eval would only be cached with flakes, so you'd eval twice but that's quite a bit better than no nom run at all.

maralorn commented 5 months ago

Or we go bold and try to mirror the eval which nix run does with nix shell and then execute the process in the shell. I guess if one looks a while hard at the implementation of nix run it won’t be to hard to find a passable solution.