Hacker News new | ask | show | jobs
by pxc 434 days ago
You may not use Nix, but some pretty cool Nix tools use your work. :)

Just today I was working on some integrations with a runtime dependency resolver for shell programs that uses OSH for parsing on the job. We use Nix to manage our development environments, and we use it to make some small wrappers and tools written in Bash into something portable and reproducible that we can include in development environments that run both on Linux and macOS.

Historically we've just included them inline in our Nix files, but thanks to resholve, we're switching to a nicer system so that they live in separate files that are more pleasant to edit. The "source code" of the scripts lives in the repo as normal bash scripts, but when they get built into the development environment, all command invocations get automatically replaced with hard-coded references to the paths of the relevant executables in the Nix store, the shebang gets pinned to a specific bash version in the same way, and they also get run through ShellCheck. Now we have not only a really nice and quick way to define portable wrappers in our Nix code, but a sane way to manage longer scripts without any portability issues.

So thanks for your cool shell and associated tools and libs!

> Or maybe it's just a harder problem

Fwiw, I think this is true.

> Some people do not like git, but I get the feeling that most people just use it, and get on with their day.

I think one of the other devs on my team probably feels this way. He thinks it's conceptually cool but is somewhat horrified by the complexity and UI. He makes simple uses of it in ways that have precedent on our team, but never really dives in.

> Why the difference with Nix?

Nix didn't have a celebrity author to spur adoption early on, in some ways it can be slow, and I think maybe it isn't as much better than entrenched alternative stacks than Git was as opposed to SVN. The pain of SVN was very acute for the average developer. I'm not sure that any of the pains of dependency hell, stateful configuration management, distribution of portable executables, etc., are quite as acute for the average operator or developer as that. People who feel Nix makes their professional lives easier tend to have come to it after their career has inflicted more specialized pain upon them.

Using Git also doesn't generally (ever?) involve writing code in a Turing-complete language, but to make the best use of Nix, you do have to do that. The paradigm of that language is not very mainstream, either, and although it's generally suited to its domain imo, it certainly has some warts.

1 comments

I'm glad to hear this! Travis Everett deserves a shout out too for building on OSH, and for being an early adopter :)

Now that Oils has been completely translated to native code (as of last year), we should probably find a way to officially support that functionality.

It is basically built on 'osh --tool syntax-tree foo.sh' ( https://oils.pub/release/0.28.0/doc/ref/chap-front-end.html )

I've also gotten a request for "tree-shaking", which is very related

Thanks for letting me know it's useful!

---

And on reflection I do think Nix has a harder problem, in part because it has to deal with the "outside messy world", where as git just stores files. For example, I noticed that on Debian the set of root packages is actually pretty coupled to apt-get. So any package manager has to have some hacks. Also OS X and libc make that even harder, etc. Some decisions are at the mercy of the OS itself

I suppose one characteristic that Oils, resholve, and Nix share is that each is an ambitious attempt to bridge two worlds in order to propagate recent innovations to actually-existing environments that are entangled with complex legacies: Oils with its two frontends/modes/languages that hope to bring the innovations of PowerShell to settings where Bash is deeply entrenched, resholve in trying to add dependency management to a language that has always fundamentally lacked it and has perhaps a uniquely flexible standard of interop, and Nix in trying to bring insights from implementations of functional programming languages (e.g., garbage collection) and their features (immutability, composability) to Unix filesystem hierarchies.

In a way, I suppose resholve also directly shares a goal of Oils itself— namely, to make shell scripts "more like 'real programs'". YSH pursues this goal through more powerful and flexible language constructs, greater facility with data structures, more ergonomic error messages and other feedback for the user, things like that. Resholve pursues this goal by trying to make it possible for shell programs— even shell programs that rely on a mixture of third-party programs from God-knows-where— can be more portable, less sensitive to changes in the environment, and more amenable to a kind of static analysis of their behavior and dependencies. And both try to achieve their missions in a "conservative" way, letting users retain (or continue to write) code written in the shell language they're most familiar with.

Certainly here on HN, "disruptive" innovation gets a lot more consideration (and praise). But I think that "conservative" innovation of the kind I've just outlined is sometimes even more ambitious and challenging. It's a great thing to see such projects manage to produce interesting and useful results.

So long live Nix, resholve, and Oils!