I have a flake that exposes derivations that depend on certain local paths - of the src = ./file.ext
variety. I’m actively developing the sources in question. What I’m looking for is a way of watching all of the local source files and rebuilding whenever one changes. Perhaps as a way of polling nix to see if the derivation has changed, and if it has, rebuild and rerun.
The use case is as follows. I’ve been using Nix for a while and for a hobby project I’m looking to try out some web development using Nix. The end result will be several docker images (e.g. one for static assets, one for a blog backend, etc) that I pass traffic to. But during active development, web projects tend to favour rapid iterations (specifically - change a file and see the results almost immediately), and I’m looking to recreate that experience - entirely bypassing dockertools’ buildImage, docker load, etc, and simply running binaries natively and port forwarding them for an nginx ingress image to route localhost traffic to them. If I change a style.css file, for instance, I’d like the static file server binary to automatically rebuild, shut down the old one, and relaunch the new one.
In order to do this, I need a way of knowing when/if a derivation has changed, and acting upon that. The ‘ideal’ solution would be if nix had a watch option, such as nix-run --watch .#static-file-server -- --port=1234
.
Is there any existing solution for this?