Develop on nixos

How I can setup my nixos to work with rbenv (or with some alternative)
I made some researches and found the following alternatives
Probably it can be done with shell.nix but im not experienced enough
I will take any guidelines or ready solutions

I also want to be able to develop on latest rust and probably python and c++

You’d do it on NixOS the same way you’d do it on any other Linux: install the programs you need, and if you run into problems, then you figure out why you’re running into problems. (Using a nix shell instead of ‘installing’ the program is also a good option, sure).

The NixOS Wiki is often a good place to find language-specific tips:

1 Like

If you need a specific version of ruby take a look at GitHub - bobvanderlinden/nixpkgs-ruby: A Nix repository with all Ruby versions being kept up-to-date automatically.
Or have a look at, which allows you to easily use one of the ruby versions packages via nixpkts (ruby 2.7, 3.0 and 3.1). Especially handy if you need also a database running for your application.

This is not the nix way. If I do that It would be better to switch to other distro.
rbenv is a tool which bring the correct version of ruby when cd directory with ruby version file
Ruby also have bundler which install all libraries (gems) locally something that is not so trivial in nixos.
My goal is be able to replicate my dev experience from regular linux distro but using the nix way
I believe that lorri and direnv are the tools that can help me but I have very little experience with nix and ask if someone already did that

I already wrote shell.nix that install ruby and bundler but I cant figure out how to install some gems
Also not sure how to manage the versions of those gems. I know that there is something called bundix that convert gemfile.lock into nix expression but I hope that there should be better way.
At that point is good enough if I can install fixed version of that gems with that shell.nix

I don’t have much to say about ruby since I don’t use the language

For develop on latest rust, fenix should do the job, it comes with all three channels (nightly, stable, beta) and also supports reading from rust-toolchain.toml with fromToolchainFile

Bundix is the state of the art for Ruby as far as I know. It worked very well at my last job for many years. The only complaint I have is it didn’t handle consuming gems with git as the source well.

This is not the nix way…

Perhaps replacing “install the programs you need” with “make the programs available” would better describe your interpretation of ‘the nix way’. – But to me e.g. nix shell nixpkgs#ruby (or an expression like pkgs.mkShell { packages = [ pkgs.ruby ] }) can both be reasonably understood to satisfy “install the packages you need”.

Perhaps you’d quibble with the phrasing, sure, but my point is “how do I do X in Nix” is as approachable as on any other Linux: get the packages you need, try using them, & fix any problems that come up.

If you’ve already got a strong idea in mind as to how the problem should be solved, good, try that.

… If I do that It would be better to switch to other distro. …

I’d encourage a more shallow and iterative relationship with Nix.

It’s better to use Nix for 95% of stuff, than for 0%. If you can’t figure out how to do something in the most elegant, idiomatic way… you can always have another go at it later once you’re more familiar with Nix.

Relatedly, I found this pretty interesting:

… I already wrote shell.nix that install ruby and bundler but I cant figure out how to install some gems
Also not sure how to manage the versions of those gems …

If you want help with more specific problems you’re facing, I’d encourage you to share what you’ve tried and what’s not working. Perhaps as a short, self-contained example of what it is you can’t get working.


Start to becoming disappointed with nixos and nix as a whole. I tried this and few similar guides and always get the same error

error: hash mismatch in fixed-output derivation '/nix/store/iihjgkwr0qsddz267pn3g3p64qq9agba-nokogiri-1.14.1.gem.drv':
         specified: sha256-IdI0xRWCspLi4eAubDDuqRiIlDSJhdaRCqjpk3ScCv8=
            got:    sha256-sts693acKc131fOc09C2WrEJdb3s8EvnHWg/nJq+JmM=

There is no explanation whats got wrong and what I can try. I can’t delete the directory because it’s readonly and nix-store --gc which hopefully delete the file do not help which tells me that there is something wrong in how nix works or there is broken package in nix

What exactly are you running to get these errors?

Nix is a bit different to other distros, but if you stick with it you will get value from it…

this may help you out.

I’m not a ruby developer, so can’t go further, but if you want to post what commands your trying to run, and good debug, someone will help you.

I made up my mind. I will install other distro. While nix and nixos have some interesting ideas that I like there a lot of flaws that some people try to fix with packages.
I already found few broken packages like steam(works but I can’t start my games with gamescope or other tools because fhs expose x screens with wrong permissions), discord (same as steam but + some more), latest vscode and many gnome extensions.
I obviously can’t easily have development environment. The documentation is extremely weak.
The language is awful and hardly better then naked yaml and if I need to use docker flatpak for most of my stuff what is the point of nix and nixos.
Sorry guys, I don’t want to be offensive but I really tried and it’s worst distro experience so far. Any of the benefits is out weighted from the required amount of effort I need to put to achieve the simplest tasks

I tried to follow that blog post on my own, and was able to recreate the problem.

I then played a bit around, and to fix the issue, I had to edit the gemset.nix and append -x86_64-linux to the version.

Here probably some implementation details of how precompiled gems work on rubygems.

Also I am pretty sure that due to this nokogiri will break during runtime.

So this issue I actually do know how to deal with. Before that though, I agree with your assessment:

I made up my mind. I will install other distro. While nix and nixos have some interesting ideas that I like there a lot of flaws that some people try to fix with packages.

When it works its bulletproof, when it doesn’t its a nightmare. I only recommend using nix-shell on a non-NixOS system until things improve. That way, when it doesn’t work, its effortless to switch back to traditional methods.

A sha-256 issue happened recently because of a Github tarball change. Code inside of nixpkgs expects a certain hash-sum, and that hash-sum was violated. Github reverted the change, but some hashes were updated to the changed version. Usually this wouldn’t even be a problem because fetchFromGithub avoids the tarball, but if a package just uses fetchurl with the raw tarball link, it can cause problems.

The only realy solution for that problem is to find where the package is defined, probably fork it, and either update the sha256 hashes, or switch the code to use fetchFromGithub. A couple weeks ago I spent a long time trying to do this for all of the python-ROS packages, it was quite a beating but I was able to use my fork afterwords.


I do not think this is related, as the gems are downloaded from, not GH.

As I have said above, when tampering with the version string in the gemset.nix, the hash-issue is solved. Though I fear it will just bring problems only visible at runtime…

Ah, thanks for the clarification, that makes sense and would make the problem much easier to solve.

I’m not sure why editing the Gemfile, then running the following wouldn’t work. But it wouldn’t be the first time bundix didn’t behave as expected.

bundix -l
bundler install

If you use bundler install then the file generated by bundix -l will be ignored.

And still I would expect both ways (my fix as well as using bundler directly) to fail at runtime, as both use some precompiled version of nokogiri, which is likely to simply break at NixOS.

Focusing on the specific issue with nokogiri here - bundler supports platform specific gems but bundix doesn’t. The workaround is to use non-platform specific versions only or custom gemset.nix files per environment.

As for the documentation and getting started. The approach of just installing NixOS and hope to hit the ground running when you’ve got shit to do is only going to end in tears. That obviously needs to be addressed but it’s a conversation for another day.

The nicer way to get started is nix on !NixOS where you can “fall back” to the regular way of doing things while you wrap your head around the many nix peculiarities.

In my case, I ran NixOS in a VM for close to 6 months (as I recall) before making the switch, simply because there were too many things that didn’t work the way I expected them to and I needed the computer to do what I needed it do.

You could start with other languages first. You specifically mention C++ which has great support under nix more or less out of the box.

EDIT: typo


I’d distinguish between:

  1. When running into problems: NixOS has the worst distro experience, sure.

  2. When things work with NixOS, NixOS has the best distro experience.

I think that’s fair. I’d say Nix is 95% wonderful, 5% huge pain in the arse.

It can be a difficult tool to use, and can take a long time to learn / get familiar with. And so, yeah, the experience as a novice can be rough.

I think most Nix users have faced things they weren’t able to do with Nix, but stuck around with it, & were eventually able to get to a place where the value of using NixOS vastly outweighs the cost.

… if I need to use docker flatpak for most of my stuff what is the point of nix and nixos.

Perhaps putting it another way: the cost of doing everything 100% in Nix is too high for a beginner to use Nix & NixOS.

Hopefully Nix is able to eventually reduce the number of painful things which don’t work. (“Lowering barriers to Nix” was a key theme in the 2022 Nix Survey).

But, in the mean time, it’s going to be easier to learn NixOS by using Nix for things you can use it for, and gradually figuring out how to use it for other things later.


Alternatively you can come to , and come and learn from some of best, in person. There is only so quickly you can learn nix on your own.

Please find a user group at and try and get in a room with other nixxers. The bandwidth is terrabits…

I didn’t lean unix all those years ago from sitting with man pages… (they helped however) . I was mentored…

See you on the mountain or in the cave…

1 Like

Guys, I really appreciate your desire to help but I already move on. I delete my nix partition and have no plans to turn back. And to be clear I did what I did not because nix is hard but because there are broken packages and the main promise of nix is that shouldn’t happen. Don’t bother to replay, I will put anything nix related into spam

1 Like