The other day I was helping someone get started with Nix. I wanted to give them the most minimal example of getting up and running with Nix and Ruby on Rails. No niv. No flakes. Just a 14 line shell.nix.
You can think of using Nix to manage system dependencies like we use Bundler to manage application dependencies. Everything can be self contained to the working directory and your future self won’t have to wrangle with different versions of Ruby, Node, or C libraries between projects.
Follow the official installation instructions on NixOS. It is recommended to use the multi-user installation if you’re on macOS or Linux. It should only take a few minutes.
$ nix-shell
. Verify you’re in the Nix shell by running $ which ruby
to see if Nix is in the path (E.g. /nix/store/vwa1c708p5447vjkk06f8xfvl66yy1wx-ruby-3.1.4/bin/ruby)$ ./bin/rails console
We’ve only scratched the surface. To make your day-to-day usage more ergonomic consider the following:
Thanks to Brad Parker for introducing our team to Nix in 2020.
Written by Tate Johnson on 24 Apr 2023. Subscribe to my blog's RSS feed.