help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Turning Gemfile.lock into a guix environment


From: Daniel Littlewood
Subject: Turning Gemfile.lock into a guix environment
Date: Tue, 27 Feb 2024 23:57:59 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]