unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Daniel Littlewood <danielittlewood@gmail.com>
To: help-guix@gnu.org
Subject: Turning Gemfile.lock into a guix environment
Date: Tue, 27 Feb 2024 23:57:59 +0000	[thread overview]
Message-ID: <CAFDSbVfd+vyLJFHvev_c8O5E05RynhOmNz_pjjnjmvxg7u1Ocw@mail.gmail.com> (raw)

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	other threads:[~2024-02-27 23:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 23:57 Daniel Littlewood [this message]
2024-03-02 12:15 ` Turning Gemfile.lock into a guix environment Carlo Zancanaro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFDSbVfd+vyLJFHvev_c8O5E05RynhOmNz_pjjnjmvxg7u1Ocw@mail.gmail.com \
    --to=danielittlewood@gmail.com \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).