Open DrRuhe opened 1 month ago
Thanks for the input
Per-Script Dependency Isolation
Nix allows each script to declare its specific environment, avoiding global dependencies. For example, if only one script requires a particular Python library, it can install and use it independently, preventing conflicts with other scripts. This ensures robustness and avoids breaking other scripts due to version mismatches.
Just a note that's already what Windmill provides for Python, with a caching strategy that is much more efficient than nix and can be backed by S3.
The fact that the code of the script would be a string inline in the "src" field would give a terrible user experience, both locally and in the web editor, prevents to use LSP and the monaco tooling and go against the spirit of Windmill to put the code logic at the center of the DX.
I'm sure some form of nix integration is possible but it seems to me that under this form, it's not so different from calling nix with bash on an inline nix script and would not integrate well.
A better form of Nix integration would probably to do it per-language and likely have the whole nix script (except src) in a metadata field that could be updated but that is something that would require quite a bit of work and we have very little request so far for it so until we do, it would likely have to be a community contribution.
Overview
Enable users to define scripts using Nix, leveraging its package management to ensure reproducible environments, precise dependency management, and access to Nixpkgs.
Benefits of Nix Integration
Central Nixpkgs Revision
Windmill can use a shared Nixpkgs revision, ensuring consistent versions of tools across all scripts. This centralization makes updating and managing dependencies easier, as only the nixpkgs reference has to be updated for all scripts to receive new versions.
Per-Script Dependency Isolation
Nix allows each script to declare its specific environment, avoiding global dependencies. For example, if only one script requires a particular Python library, it can install and use it independently, preventing conflicts with other scripts. This ensures robustness and avoids breaking other scripts due to version mismatches.
Efficient Distribution via the Nix Store
Once a derivation (Nix-built package) is created, it’s stored in the Nix store. Scripts can reuse these pre-built binaries, ensuring fast deployment and execution without recompilation.
Questions
Example 1 : build a Go tool
An example script using Nix to build a Go tool:
Example 2: A python script
This script takes an input MP4 file, extracts the audio using ImageMagick, and generates a spectrogram using Python libraries.