timbertson/runix

Possible use case? Running pre-commit

Opened this issue · 1 comments

yajo commented

I've recently moved a project I maintain to Nix. It's a Python project. Not so long after the movement, the first contributors complains started. See copier-org/copier#931 (comment) for example. IMHO it's a valid complain!

Of course, the point here is to run a command from the devshell. I guess that's a package too. Would I be able to tell users to run a runix command to run the linters? Some clue on where to start?

If you want to run some predefined and occasionally-changing files, then runix sounds like a good solution. e.g. in this example, if poe is an external tool then you could tell people to run ./script/poe lint, and script/poe would be generated by you running on your machine (that has nix):

$ runix --entrypoint xxxxxxxxxxxxxxxxxxx-poe-1.2.3 bin/poe --save script/poe --with-cache https://yourcache.cachix.org --auto-bootstrap

Given the derivation for poe which you have pushed to your cache. If you want it to be multiplatform (i.e. darwin + linux), you can do that too with a little more work.

The script would be totally self-contained - you commit it to your repo, then anyone who runs it will cache runix and poe once, and then reuse both from the cache. If you update the derivation and commit a new version of this wrapper, anyone running the new version will download any derivations they don't already have cached.

If poe were a fast-moving part of your own project that changed every day, then it could be inconvenient and confusing to keep those derivations up to date. But if it's something you have to redo every 6 months and commit a new version of that generated script, it's definitely doable 👍

Let me know if you hit any troubles, I'd love to encourage real world use cases.


If you prefer, it's possible to make a "dev env" like runix wrapper, where it can wrap more than one tool, and you use it to drop into a shell with a bunch of tools available. That's a bit more complex, so it's probably best to start with the single-purpose wrappers.