Cloud-Scythe-Labs / nix-watch

Nix Watch watches over your project's source for changes, and runs Nix commands when they occur.
BSD 2-Clause "Simplified" License
4 stars 0 forks source link

Refactor script to allow for environment variables #9

Open eureka-cpu opened 3 months ago

eureka-cpu commented 3 months ago

It would be cool to allow environment variables for variables in the script that rely on the command line flags so that the watcher could be declarative. Basically I'd like to be able to do:

{
  devShells.default = pkgs.mkShell {
    buildInputs = [ pkgs.nil ] ++ nix-watch.nix-watch.${system}.devTools;
    NIX_WATCH_COMMAND="nix build --keep-going";
    NIX_WATCH_DEBUG=true;
    # ... etc
  };
}

How the default variables are constructed would need to change. The following is the behaviour I'd expect:

There may be other quirks that will present themselves as I haven't entirely thought this out, but that's the gist.

dzmitry-lahoda commented 2 months ago

would you mind also move script into separate file out of nix and make builtins.readFile in nix? It will make script reusable out of nix.

also you may consider using https://github.com/ko1nksm/getoptions by refencing it as non flake input? it parses into ENV vars kind of as it seems.

eureka-cpu commented 2 months ago

would you mind also move script into separate file out of nix and make builtins.readFile in nix? It will make script reusable out of nix.

also you may consider using https://github.com/ko1nksm/getoptions by refencing it as non flake input? it parses into ENV vars kind of as it seems.

Do you have an example of how someone would use this in a non-nix setting? It's a nix developer tool, so I only really see anyone using it with nix.