Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor script to allow for environment variables #9

Open
eureka-cpu opened this issue Aug 6, 2024 · 2 comments
Open

Refactor script to allow for environment variables #9

eureka-cpu opened this issue Aug 6, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@eureka-cpu
Copy link
Contributor

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:

  • If a user passes a flag/option that conflicts with the environment variable, the flag/option should override it, i.e NIX_WATCH_COMMAND="nix build --keep-going" but the user specifies nix-watch -x "nix flake check"

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

@eureka-cpu eureka-cpu added enhancement New feature or request good first issue Good for newcomers labels Aug 6, 2024
eureka-cpu added a commit that referenced this issue Aug 7, 2024
Ref #9 

Makes evaluation of commands passed via `-x, --exec` more robust. Adds
the ability to declare the command to run on source changes as an
environment variable.
andrewvious added a commit that referenced this issue Aug 7, 2024
Ref #9 

Adds support for the debug env variable, and adds a integer to bool
conversion fn that can be used on other env vars in the future if
conversion is necessary
andrewvious added a commit that referenced this issue Aug 7, 2024
Ref #9 
Adds script support for the `clear` env variable
andrewvious added a commit that referenced this issue Aug 7, 2024
Ref #9 
Adds script support for `ignore-nothing` env var, and reorder logic
regarding the ignore patterns
andrewvious added a commit that referenced this issue Aug 7, 2024
Ref #9 
Add script support for `no-restart` env var
andrewvious added a commit that referenced this issue Aug 7, 2024
Ref #9 
Adds script support for postpone env var
eureka-cpu added a commit that referenced this issue Aug 17, 2024
Ref #9 

Updates `process_command` function to accept an array and return a
processed array. Updates the name of `process_command` to `process_args`
to better reflect its use cases. Enables detection of
`NIX_WATCH_SHELL_ARGS` environment variable, yielding to command line
args passed.
eureka-cpu added a commit that referenced this issue Aug 20, 2024
Ref #9 

Adds the ability to declare `NIX_WATCH_PRINT_BUILD_LOGS` environment
variable.
eureka-cpu added a commit that referenced this issue Aug 20, 2024
Ref #9 

Adds the `IGNORE_PATTERNS` environment variable handling.
@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Sep 8, 2024

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants