Bundler not available on older Ruby versions
pcasaretto opened this issue · comments
Paulo Casaretto commented
Hi there,
Not sure If I'm doing something wrong but following the instructions on README I get an environment with ruby but no bundler.
flake.nix
{
description = "A simple ruby app demo";
nixConfig = {
extra-substituters = "https://nixpkgs-ruby.cachix.org";
extra-trusted-public-keys =
"nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
};
inputs = {
nixpkgs.url = "nixpkgs";
ruby-nix.url = "github:sagittaros/ruby-nix";
# a fork that supports platform dependant gem
bundix = {
url = "github:sagittaros/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
fu.url = "github:numtide/flake-utils";
bob-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
bob-ruby.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, fu, ruby-nix, bundix, bob-ruby }:
with fu.lib;
eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ bob-ruby.overlays.default ];
};
rubyNix = ruby-nix.lib pkgs;
# TODO generate gemset.nix with bundix
gemset =
if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };
# If you want to override gem build config, see
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix
gemConfig = { };
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-3.2";
bundixcli = bundix.packages.${system}.default;
in rec {
inherit (rubyNix {
inherit gemset ruby;
name = "my-rails-app";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env;
devShells = rec {
default = dev;
dev = pkgs.mkShell {
buildInputs = [ env bundixcli ]
++ (with pkgs; [ nodejs-19_x yarn rufo ]);
};
};
});
}
flake.lock
{
"nodes": {
"bob-ruby": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1681278043,
"narHash": "sha256-RsoF1uJJRDBfl1yF4kxNFs2ZEq4XDY5fa205RbE/lwo=",
"owner": "bobvanderlinden",
"repo": "nixpkgs-ruby",
"rev": "42dc88616a47462efc0c3aad7d3027cd04bbd202",
"type": "github"
},
"original": {
"owner": "bobvanderlinden",
"repo": "nixpkgs-ruby",
"type": "github"
}
},
"bundix": {
"inputs": {
"fu": "fu",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1679041248,
"narHash": "sha256-E2Lo2y7EU3XUm4/HzyJz2uxbz55kBuap4sNcDMyRcCw=",
"owner": "sagittaros",
"repo": "bundix",
"rev": "139e7726f9ae13d355e15c9224e045ccd9af7b3b",
"type": "github"
},
"original": {
"owner": "sagittaros",
"ref": "main",
"repo": "bundix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fu": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fu_2": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1681389457,
"narHash": "sha256-Z6TRJ2aI1eRd+kICdrkNyL2aH7XKw8ogzLdtGz1Q9qI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c58e6fbf258df1572b535ac1868ec42faf7675dd",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1678875422,
"narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"bob-ruby": "bob-ruby",
"bundix": "bundix",
"fu": "fu_2",
"nixpkgs": "nixpkgs",
"ruby-nix": "ruby-nix"
}
},
"ruby-nix": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1679572735,
"narHash": "sha256-LZJ79cu146aTSLkX5OgXCSv1lZZ2RcE+a2gjeB9Mk5Y=",
"owner": "sagittaros",
"repo": "ruby-nix",
"rev": "dfb2a4531fec56793b84c5cec9bffd5d5e19c0b6",
"type": "github"
},
"original": {
"owner": "sagittaros",
"repo": "ruby-nix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
.envrc
if ! has nix_direnv_version || ! nix_direnv_version 2.2.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.0/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc="
fi
use flake
Output:
λ which bundle
/usr/bin/bundle
~/test-ruby-env
λ which ruby
/nix/store/ccd0ack4dw4dsg28zj86pbnhlajpqlfl-my-rails-app/bin/ruby
~/test-ruby-env
λ echo $PATH | tr : "\n"
/nix/store/1mq693ljrcnrdzmkfiywbzxk9pz2c3m8-clang-wrapper-11.1.0/bin
/nix/store/lv1r3zd6jrs5zvw9k72nxav7xwd0cbl7-clang-11.1.0/bin
/nix/store/v2v8ljfaid7icj00ay6lyv6k57xirak8-coreutils-9.1/bin
/nix/store/23siajrr39w6wj691mk7i9ryzn0g8zks-cctools-binutils-darwin-wrapper-973.0.1/bin
/nix/store/zrqd8yv2kmv460zyrgrlb2514nq4fk9m-cctools-binutils-darwin-973.0.1/bin
/nix/store/ccd0ack4dw4dsg28zj86pbnhlajpqlfl-my-rails-app/bin
/nix/store/3m0rs8awi836kabivdv70kszx8j59123-bundix/bin
/nix/store/mknm4z3zw3ai12w7jgghzbc41g1qbsyv-nodejs-19.9.0/bin
/nix/store/hr2rph6jmp9l85837zcc4yfgv4asnf32-yarn-1.22.19/bin
/nix/store/1ybk7dfryn8ngnjhjnhvc9pba8fwypi4-rufo-0.12.0/bin
/nix/store/v2v8ljfaid7icj00ay6lyv6k57xirak8-coreutils-9.1/bin
/nix/store/cph6k98y8sjmr0mis2y60s56b3sdpxj1-findutils-4.9.0/bin
/nix/store/pcfw2fnaxcxxs7ln4hy1jaaqgb8rmdhj-diffutils-3.9/bin
/nix/store/n023kyx1zmzdjqhc5jwb2vrlxmgm3pzv-gnused-4.9/bin
/nix/store/ynp1z7azqz6xcs9x3isgpm3ry4526nx0-gnugrep-3.7/bin
/nix/store/q4zlavvz0x1iyx7mrv4zwkz7lk77yams-gawk-5.2.1/bin
/nix/store/swrn8a0pzdvyqb9k4snj0f81qi2zj482-gnutar-1.34/bin
/nix/store/mbxlf6szaixjhqw07k139jam6g5vb005-gzip-1.12/bin
/nix/store/28azg0h5mighcayy28x1shgaz6wbw3nr-bzip2-1.0.8-bin/bin
/nix/store/d1bybmym70qv03h82ij7sc7055b75zj0-gnumake-4.4.1/bin
/nix/store/24myb0ky5zv2zfkm6lwrijiavly13cf7-bash-5.2-p15/bin
/nix/store/aa17c5qkavymj717hif7hsdyhglb1ngd-patch-2.7.6/bin
/nix/store/yvdv2x7z7qjhqzym5zndnimisg2b74nq-xz-5.4.2-bin/bin
/nix/store/3jsn64538qqfjyix6z89cs1ippigmf8q-file-5.44/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/Users/pcasaretto/.nix-profile/bin
/etc/profiles/per-user/pcasaretto/bin
/run/current-system/sw/bin
/nix/var/nix/profiles/default/bin
/usr/local/bin
/usr/bin
/usr/sbin
/bin
/sbin
Paulo Casaretto commented
Changing back to Ruby 3.2 as per the example makes bundle available.
I guess the old Ruby versions don't include bundler?
Can I specify I need it in my flake file?
Felx commented
Sorry, I missed this entirely. This is something I experienced myself after using nixpkgs-ruby
. I will update the example to reflect the shortage.
Thanks for filing this.
Felx commented
{
description = "A simple ruby app demo";
nixConfig = {
extra-substituters = "https://nixpkgs-ruby.cachix.org";
extra-trusted-public-keys =
"nixpkgs-ruby.cachix.org-1:vrcdi50fTolOxWCZZkw0jakOnUI1T19oYJ+PRYdK4SM=";
};
inputs = {
nixpkgs.url = "nixpkgs";
ruby-nix.url = "github:inscapist/ruby-nix";
# a fork that supports platform dependant gem
bundix = {
url = "github:inscapist/bundix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
fu.url = "github:numtide/flake-utils";
bob-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
bob-ruby.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, fu, ruby-nix, bundix, bob-ruby }:
with fu.lib;
eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ bob-ruby.overlays.default];
config.permittedInsecurePackages = [
"openssl-1.1.1w"
];
};
rubyNix = ruby-nix.lib pkgs;
# TODO generate gemset.nix with bundix
gemset =
if builtins.pathExists ./gemset.nix then import ./gemset.nix else { };
# If you want to override gem build config, see
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix
gemConfig = { };
# See available versions here: https://github.com/bobvanderlinden/nixpkgs-ruby/blob/master/ruby/versions.json
ruby = pkgs."ruby-2.7.6";
bundixcli = bundix.packages.${system}.default;
in rec {
inherit (rubyNix {
inherit gemset ruby;
name = "my-rails-app";
gemConfig = pkgs.defaultGemConfig // gemConfig;
})
env;
devShells = rec {
default = dev;
dev = pkgs.mkShell {
buildInputs = [ env bundixcli ]
++ (with pkgs; [ yarn rufo ]);
};
};
});
}
Checking if we can close this, so I tried 2.7.6 and bundle is in path.
/tmp/ruby-proj
▲ nix develop
[jane@nixos ruby-proj]$ which bundle
/nix/store/9palvpy1wnj9df2x5hfn1fsphk0aa1vk-my-rails-app/bin/bundle