Magix: Build, cache and run compiled scripts

Some time ago, Brian Hicks stepped down from maintaining nix-script, a tool for running (possibly compiled) scripts with dependencies. See also

The big advantage of nix-script is that it hashes the input script and so remembers the Nix derivation as well as the Nix derivation result. Thereby, nix-script speeds up the compilation process until script execution by several orders of magnitude.

For the last months, I have maintained a fork of nix-script. However, my Rust is a bit rusty, and nix-script is a complex project. Maybe a bit more complex than it needs to be. I tried building a simpler (but also less feature-rich) alternative in Haskell: Magix.

  • Magix is simple and stupid.
  • Magix is a tiny wrapper around nix-build.
  • Magix is heavily tested (only unit tests at the moment, but please drop a PR).
  • Magix uses Nix expression templates, and so, is easier to understand, modify, and enhance.

I have been using Magix for over a month now, and have not had a single issue. It is fast, and extremely easy to use, so if you like, have a look, try it out, and suggest an improvement (or add support for your language of choice)!

Finally, I wanted to thank Brian Hicks for his work on nix-script. It has been a great tool that I have been using for years!

8 Likes

This looks really cool!

I just went to nix-script’s archived repo, found a link to the initial blog post he wrote introducing the original concept here -

https://bytes.zone/posts/nix-script/

Might be worth linking to it/quoting parts of it somewhere here or in the GitHub readme - and maybe could even throw in a comparison of how you would achieve the same result as in his examples from that linked blog post, but in Magix.

I’ll have to give this a try with some of the scripts I use currently - as I wasn’t aware of the original project, or the fork you’ve continued maintaining (kudos for that btw!).

Thanks again for taking the time to create and share this!

2 Likes

Yea, thanks! I actually linked to the exact same post. I will edit so the link shows up a bit more prominent!

2 Likes