Hello! I continue my journey to expore Nix as a (Ruby) development environment. Now I have a problem using
nix-shell for a Ruby app which depends on a gem from a private Git repository.
shell.nix is trivial: it uses
ruby and gems built by
When I launch
nix-shell, it fails because it cannot build a derivation for the private gem. Related excerpt from the output:
# ... snip ... exporting https://gitlab.com/<my-org>/<my-gem>.git (rev <revision>) into /nix/store/3d57xxnxnfih316is8w0gynir4ir10d4-<my-gem>-7727f7a Initialized empty Git repository in /nix/store/3d57xxnxnfih316is8w0gynir4ir10d4-<my-gem>-7727f7a/.git/ fatal: could not read Username for 'https://gitlab.com': Device not configured fatal: could not read Username for 'https://gitlab.com': Device not configured Unable to checkout <revision> from https://gitlab.com/<my-org>/<my-gem>.git # ... snip ... cannot build derivation '/nix/store/x3mvcly1n3klawih9n2a9g7qcs6zsfz7-<my-app-gems>.drv': 1 dependencies couldn't be built error: build of '/nix/store/x3mvcly1n3klawih9n2a9g7qcs6zsfz7-<my-app-gems>.drv' failed
This discussion mentions private Git repos but it doesn’t lead to a conclusion on this topic.
bundix --magic kinda works (it asks for the credentials) but it has some drawbacks:
- it doesn’t install gems’ executables so I have to use e.g.
bundle exec railsinstead of
- it doesn’t seem to use
pkgs.defaultGemConfigso I have to manually install native dependencies (e.g.
libsodium, etc.), otherwise
bundix --magicwill fail;
- it modifies local
An unrelated question: my app depends on two gems, both of them install
bin/console which makes
nix-shell fail because of collisions. I have solved it by overriding
meta.priority for one of them in
gemConfig. Is this the right way?