all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Turning Gemfile.lock into a guix environment
@ 2024-02-27 23:57 Daniel Littlewood
  2024-03-02 12:15 ` Carlo Zancanaro
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Littlewood @ 2024-02-27 23:57 UTC (permalink / raw)
  To: help-guix

Hi everyone, I'm trying to figure out how to convert a Ruby project
from using bundler to using guix directly, so I can sidestep
rvm/rbenv/bundle.

I found two articles about this, but neither seems to go into the
detail of pinning versions to get a really reproducible environment.
They just provide ideas.

1. RUBY.org guix notes by pjotr:
https://github.com/pjotrp/guix-notes/blob/master/RUBY.org
2. Ruby on Guix article by David Thompson:
https://dthompson.us/posts/ruby-on-guix.html

Anyway, I wanted to share a small ruby script I wrote which will parse
your Gemfile.lock file and shell out to call `guix import gem` with
the version specified in your lockfile. I'm actually stuck here,
because I don't know how to build a guix package definition out of
these snippets.

```ruby
#!/usr/bin/env ruby

require 'bundler'
parser = Bundler::LockfileParser.new(File.read(ARGV[0]))
ruby_gems = parser.specs.select { |s| spec.is_a?(Bundler::Source::Rubygems) }
ruby_gems.each { |g| puts %x(guix import gem #{g.name}@#{g.version}) }
```

Usage: ./gemfile_import.rb Gemfile.lock

this worked for me with a gemfile.lock of a few hundred specs.
Obviously the resulting package definition will be pretty big, but I
assume that's okay. I'm particularly hoping to script the import so
that I can use guix at work in parallel with my colleagues on other
systems who prefer to use bundler. I don't know how updating gems
would work yet in this setup.

I wonder a) whether anybody else cares about this problem and b)
whether anybody has any advice for building the final package
definition? I will keep looking through the docs, but I am quite new
to guix and haven't built my own package definition before.

All the best,
Dan


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Turning Gemfile.lock into a guix environment
  2024-02-27 23:57 Turning Gemfile.lock into a guix environment Daniel Littlewood
@ 2024-03-02 12:15 ` Carlo Zancanaro
  0 siblings, 0 replies; 2+ messages in thread
From: Carlo Zancanaro @ 2024-03-02 12:15 UTC (permalink / raw)
  To: Daniel Littlewood; +Cc: help-guix

Hi Daniel,

On Tue, Feb 27 2024, Daniel Littlewood wrote:
> Hi everyone, I'm trying to figure out how to convert a Ruby project
> from using bundler to using guix directly, so I can sidestep
> rvm/rbenv/bundle.

I'm not aware of a solution to this in Guix, but there is a Nix-based
solution: bundix[1]. I use the Nix service on my Guix system so I can
use a Nix environment to manage my Ruby dependencies. My setup is
similar to what is described in the Nix manual[2].

One thing to keep in mind with this is that the Guix packages written by
the importer might not work without modification. Nix maintains a list
of modifications required for automatically imported packages to
build[3]. Presumably there would need to be something similar for Guix.

I haven't seriously investigated what it would take to generate Guix
environments from Ruby Gemfiles, but I would definitely be interested in
using this feature if it existed.

Carlo

[1]: https://github.com/nix-community/bundix
[2]: https://nixos.org/manual/nixpkgs/stable/#developing-with-ruby
[3]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/ruby-modules/gem-config/default.nix


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-02 12:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 23:57 Turning Gemfile.lock into a guix environment Daniel Littlewood
2024-03-02 12:15 ` Carlo Zancanaro

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.