Flake and NixOS package differences

I am using NixOS 24.05 without Ruby installed.

> nixos-version
24.05.3346.8c5066250910 (Uakari)
> ruby -v
The program 'ruby' is not in your PATH.

Starting a new shell with ruby_3_3 gives me access to Ruby 3.3.3 as expected since this is what search.nixos.org lists as the version.

> nix-shell -p ruby_3_3
$ ruby -v
ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [x86_64-linux]

So far so good.

Now, for my Ruby on Rails development environment I use a flake which has been updated with nix flake update:

{
  inputs = {
    nixpkgs.url = "nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        env = pkgs.bundlerEnv {
          name = "bundler";
          ruby = pkgs.ruby_3_3;
          gemdir = ./.;
        };

      in with pkgs; {
        devShells.default = mkShell {
          buildInputs = [
            bundix
            env
            ruby_3_3
          ];
        };
      });
}

When I start the development shell I get Ruby 3.3.2, not Ruby 3.3.3.

> nix develop # in the same directory as the flake.nix mentioned above
$ ruby -v
ruby 3.3.2 (2024-05-30 revision e5a195edf6) [x86_64-linux]

How come the ruby_3_3 package in NixOS and in my flake points to different versions?

Thank you!

You are using nixpkgs from the flake registry in your flake, so the most likely cause i see is that nixpkgs registry points to nixpkgs-unstable which has the version of ruby_3_3 at 3.3.2. Try changing it to:

nixpkgs.url = "github:nixos/nixpkgs/24.05";

and see if you get 3.3.3

1 Like

Good idea. I tried and this weirdly enough gives me Ruby 3.3.1, instead of 3.3.3 so one version earlier, not later.

> nix develop 
$ ruby -v
ruby 3.3.1 (2024-04-23 revision c56cd86388) [x86_64-linux]

I think I found it. Changing the flake registry to nixos-24.05 does give me Ruby 3.3.3!

-   nixpkgs.url = "github:nixos/nixpkgs/24.05";
+   nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";

Thank you @wyyllou, for pointing me in the right direction!

2 Likes