What is the Flakes version of "reproducible interpreted scripts"?
i.e., https://nix.dev/tutorials/reproducible-scripts
but with flakes and not traditional Nix.
I have some Bash stuff that I want to preserve.
Also, if there was a way to do it the Nix way but only if Nix was installed, that would be sweet, too.
EDIT: I ended up doing it this way; adapt to your own needs, but this seems to work well for now while not requiring any other files:
https://gist.github.com/pmarreck/18a27a2af8688bef2f51992763ded238
Posted Apr 26, 2023, 11:26 PM UTC · edited
I would write a package output built on something from the family of
writeShellApplication,writeShellScriptBin, etc in roughly that order of preference:https://ryantm.github.io/nixpkgs/builders/trivial-builders/#trivial-builder-writeShellApplication
If they already exist as files you can use
builtins.readFileinstead of inline strings.oh this is nice. does it solve the problem of calling shell functions defined there at runtime though? where the PATH might have changed to point to different versions of any deps utilized...
There's some substitution helper that may help if I correctly understand your question, but I can't recall the name to provide a link.
I'm also not 100% on whether it answers the question, but I imagine you're thinking of https://github.com/abathur/resholve (doc in nixpkgs: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/misc/resholve/README.md)
Edit: doesn't address flakes, but I have a general ~breakdown of the main approaches to using Nix for shell dependencies in https://www.t-ravis.com/post/shell/no_look_no_leap_shell_with_nix/
just to clarify with an example: I run a shell file defined in this way; it defines some shell functions in my current environment. Later on, I call the function, but I'm now in a different scope/profile/environment/whatever, so when code inside the function calls (for example)
curl, will it use thecurlspecified within the nix file or will it use the firstcurlit finds on whatever value PATH has at that time it is run?EDIT: I guess it would have to use a fully-specified bin path in order to be deterministic