<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>guix &#8211; CS@Worcester</title>
	<atom:link href="https://cs.worcester.edu/category/guix/feed/" rel="self" type="application/rss+xml" />
	<link>https://cs.worcester.edu</link>
	<description>Worcester State University Computer Science Department</description>
	<lastBuildDate>Mon, 14 Sep 2015 19:00:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
<site xmlns="com-wordpress:feed-additions:1">236835116</site>	<item>
		<title>call-with-container: Linux containers for GNU Guix</title>
		<link>http://dthompson.us/call-with-container-linux-containers-for-gnu-guix.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Mon, 14 Sep 2015 19:00:00 +0000</pubDate>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[guile]]></category>
		<category><![CDATA[guix]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=944ef7cbb36b377282fdda8bff4618d6</guid>

					<description><![CDATA[<p>Containers have become a hot topic.  Docker, LXC, Rkt, systemd-nspawn,
etc. are popular and make a lot headlines on technology news websites.
There are even <a href="http://events.linuxfoundation.org/events/containercon">entire conferences</a> dedicated to "containerization."
The next release of <a href="https://gnu.org/s/guix">GNU Guix</a>, a purely functional package manager,
will feature basic support for Linux containers, dubbed
<tt><span>call-with-container</span></tt>.  GNU Guix is written in the Guile Scheme
programming language.  Thus, in typical Scheme fashion, we have used
the <tt><span>call-with-*</span></tt> naming convention (like our old friend
<tt><span>call-with-current-continuation</span></tt>, for example) to refer to the
container implementation, which allows the user to apply an arbitrary
Scheme procedure in a new, containerized process.  For those familiar
with Guile, it's like a fancier version of <tt><span>primitive-fork</span></tt>.  In
addition to forking via <tt>clone(2)</tt>, <tt><span>call-with-container</span></tt> unshares
resources such as the network, mount, and user namespaces from the
host system and creates a temporary file system in a chroot (though we
actually use <tt>pivot_root</tt> instead), among other things.</p>
<p>So, given the fast-paced world of Linux container development and the
companies investing huge sums of money into the aformentioned tools,
why add another implementation to the mix?  What's wrong with the
status quo?  What can Guix possibly add?  Let's dive into the
motivation behind Guix containers, how they differ from the status
quo, and how they solve issues that other implementations cannot.</p>
<div>
<h2>The Trouble with Disk Images</h2>
<p>The term "container" has in practice come to mean a disk image whose
binaries are run in a lightweight virtualization with kernel
namespaces.  Docker and friends work with raw disk images, or layers
of them, as their fundamental data unit.  There are several issues
with this approach.  This presents issues with regards to disk and
memory usage and file system complexity.  Containers typically include
the minimal core software of a GNU/Linux distribution within them,
plus the extra software that is application-specific.</p>
<p>WRITEME: Deduplicating software amongst containers via
content-addressable storage (/gnu/store) and full dependency graph</p>
</div>
<div>
<h2>Imperative vs. Functional - The Dockerfile Problem</h2>
<p>WRITEME: Functional &#62; Imperative.  Mention issues with imperative
Dockerfiles and how the order of operations influences how well the
cache is utilized.  Docker cannot possibly know the details that Guix
knows because Docker defers to other package managers to do things
that are opaque to it.</p>
</div>
<div>
<h2>Guix and GuixSD Containers</h2>
<p>WRITEME: Simple, unprivileged containers with 'guix environment'.  Add
example for sharing file systems from the host.</p>
<p>WRITEME: GuixSD containers with 'guix system container'.  Mention the
use of a real init system (dmd) and the full-system configuration
language.</p>
<p>WRITEME: An arbitrary Scheme script that launches a container, showing
that (guix build linux-container) is a generic library to be re-used as
you wish.</p>
</div>
<div>
<h2>Future Work</h2>
<p>WRITEME: The future: cgroups, networking, orchestration.  Reach out
for contributors.</p>
<p>As an aside, before I bid you farewell, dear reader: I live in the
Boston area and I'm looking for local meetups and conferences that
would welcome a technical presentation about GNU Guix and the benefits
of the functional package and configuration management paradigm.  If
you have the connections and I have piqued your interest, please send
an email to davet at gnu dot org.</p>
</div>]]></description>
										<content:encoded><![CDATA[<p>Containers have become a hot topic.  Docker, LXC, Rkt, systemd-nspawn,<br />
etc. are popular and make a lot headlines on technology news websites.<br />
There are even <a class="reference external" href="http://events.linuxfoundation.org/events/containercon">entire conferences</a> dedicated to &quot;containerization.&quot;<br />
The next release of <a class="reference external" href="https://gnu.org/s/guix">GNU Guix</a>, a purely functional package manager,<br />
will feature basic support for Linux containers, dubbed<br />
<tt class="docutils literal"><span class="pre">call-with-container</span></tt>.  GNU Guix is written in the Guile Scheme<br />
programming language.  Thus, in typical Scheme fashion, we have used<br />
the <tt class="docutils literal"><span class="pre">call-with-*</span></tt> naming convention (like our old friend<br />
<tt class="docutils literal"><span class="pre">call-with-current-continuation</span></tt>, for example) to refer to the<br />
container implementation, which allows the user to apply an arbitrary<br />
Scheme procedure in a new, containerized process.  For those familiar<br />
with Guile, it&#8217;s like a fancier version of <tt class="docutils literal"><span class="pre">primitive-fork</span></tt>.  In<br />
addition to forking via <tt class="docutils literal">clone(2)</tt>, <tt class="docutils literal"><span class="pre">call-with-container</span></tt> unshares<br />
resources such as the network, mount, and user namespaces from the<br />
host system and creates a temporary file system in a chroot (though we<br />
actually use <tt class="docutils literal">pivot_root</tt> instead), among other things.</p>
<p>So, given the fast-paced world of Linux container development and the<br />
companies investing huge sums of money into the aformentioned tools,<br />
why add another implementation to the mix?  What&#8217;s wrong with the<br />
status quo?  What can Guix possibly add?  Let&#8217;s dive into the<br />
motivation behind Guix containers, how they differ from the status<br />
quo, and how they solve issues that other implementations cannot.</p>
<div class="section" id="the-trouble-with-disk-images">
<h2>The Trouble with Disk Images</h2>
<p>The term &quot;container&quot; has in practice come to mean a disk image whose<br />
binaries are run in a lightweight virtualization with kernel<br />
namespaces.  Docker and friends work with raw disk images, or layers<br />
of them, as their fundamental data unit.  There are several issues<br />
with this approach.  This presents issues with regards to disk and<br />
memory usage and file system complexity.  Containers typically include<br />
the minimal core software of a GNU/Linux distribution within them,<br />
plus the extra software that is application-specific.</p>
<p>WRITEME: Deduplicating software amongst containers via<br />
content-addressable storage (/gnu/store) and full dependency graph</p>
</div>
<div class="section" id="imperative-vs-functional-the-dockerfile-problem">
<h2>Imperative vs. Functional &#8211; The Dockerfile Problem</h2>
<p>WRITEME: Functional &gt; Imperative.  Mention issues with imperative<br />
Dockerfiles and how the order of operations influences how well the<br />
cache is utilized.  Docker cannot possibly know the details that Guix<br />
knows because Docker defers to other package managers to do things<br />
that are opaque to it.</p>
</div>
<div class="section" id="guix-and-guixsd-containers">
<h2>Guix and GuixSD Containers</h2>
<p>WRITEME: Simple, unprivileged containers with &#8216;guix environment&#8217;.  Add<br />
example for sharing file systems from the host.</p>
<p>WRITEME: GuixSD containers with &#8216;guix system container&#8217;.  Mention the<br />
use of a real init system (dmd) and the full-system configuration<br />
language.</p>
<p>WRITEME: An arbitrary Scheme script that launches a container, showing<br />
that (guix build linux-container) is a generic library to be re-used as<br />
you wish.</p>
</div>
<div class="section" id="future-work">
<h2>Future Work</h2>
<p>WRITEME: The future: cgroups, networking, orchestration.  Reach out<br />
for contributors.</p>
<p>As an aside, before I bid you farewell, dear reader: I live in the<br />
Boston area and I&#8217;m looking for local meetups and conferences that<br />
would welcome a technical presentation about GNU Guix and the benefits<br />
of the functional package and configuration management paradigm.  If<br />
you have the connections and I have piqued your interest, please send<br />
an email to davet at gnu dot org.</p>
</div>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">3975</post-id>	</item>
		<item>
		<title>Ruby on Guix</title>
		<link>http://dthompson.us/ruby-on-guix.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Sun, 30 Aug 2015 19:00:00 +0000</pubDate>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[guile]]></category>
		<category><![CDATA[guix]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=cd8a17791ee842681e7b97c007621b14</guid>

					<description><![CDATA[<p>I've been working with Ruby professionally for over 3 years now and
I've grown frustrated with two of its most popular development tools:
RVM and Bundler.  For those that may not know, RVM is the Ruby version
manager and it allows unprivileged users to download, compile,
install, and manage many versions of Ruby instead of being stuck with
the one that is installed globally by your distro's package manager.
Bundler is the tool that allows developers to keep a version
controlled "Gemfile" that specifies all of the project's dependencies
and provides utilities to install and update those gems.  These tools
are crucial because Ruby developers often work with many applications
that use different versions of Ruby and/or different versions of gems
such as Rails.  Traditional GNU/Linux distributions install packages
to the global <tt>/usr</tt> directory, limiting users to a single version
of Ruby and associated gems, if they are packaged at all.  Traditional
package management fails to meet the needs of a lot of users, so many
niche package managers have been developed to supplement them.</p>
<p>Taking a step back, it becomes apparent that dependency isolation is a
general problem that isn't confined to software written in Ruby: Node
has npm and nvm, Python has pip and virtualenv, and so on.  A big
limitation of all these language-specific package managers is that
they cannot control what is outside of their language domain.  In
order to use RVM to successfully compile a version of Ruby, you need
to make sure you have the GCC toolchain, OpenSSL, readline, libffi,
etc. installed using the system package manager (note: I've seen RVM
try to build prerequisites like OpenSSL before, which I then disabled
to avoid duplication and security issues and I recommend you do the
same.)  In order to use Bundler to install Nokogiri, you need to make
sure libxml2 has been installed using the system package manager.  If
you work with more than a single language, the number of different
package management tools needed to get work done is staggering.  For
web applications, it's not uncommon to use RVM, Bundler, NPM, Bower,
and the system package manager simultaneously to get all of the
necessary programs and libraries.  Large web applications are
notoriously difficult to deploy, and companies hire a bunch of
operations folk like me to try to wrangle it all.</p>
<p>Anyway, let's forget about Node, Python, etc. and just focus on Ruby.
Have you or someone you work with encountered hard to debug issues and
Git merge conflicts due to a problem with <tt>Gemfile.lock</tt>?  Bundler's
fast and loose versioning in the <tt>Gemfile</tt> (e.g. <tt>rails &#62;= 4.0</tt>)
causes headaches when different users update different gems at
different times and check the resulting auto-generated
<tt>Gemfile.lock</tt> into the repository.  Have you ever been frustrated
that it's difficult to deduplicate gems that are shared between
multiple bundled gem sets?  Have you looked at the <a href="https://rvm.io/">RVM home page</a>
and been frustrated that they recommend you to <tt>curl &#124; bash</tt> to
install their software?  Have you been annoyed by RVM's strange system
of overriding shell built-ins in order to work its magic?  I'm not
sure how you feel, dear reader, but my Ruby environments feel like one
giant, brittle hack, and I'm often enough involved in fixing issues
with them on my own workstation, that of my colleagues, and on
production servers.</p>
<p>So, if you're still with me, what do we do about this?  How can we
work to improve upon the status quo?  Just use Docker?  Docker is
helpful, and certainly much better than no isolation at all, but it
hides the flaws of package management inside an opaque disk image and
restricts the environments in which your application is built to
function.  The general problem of dependency isolation is orthogonal
to the runtime environment, be it container, virtual machine, or "bare
metal."  Enter functional package management.  What does it mean for a
package manager to be functional?  GNU Guix, the functional package
manager that I contribute to and recommend, has this to say:</p>
<blockquote>
<p>GNU Guix is a functional package management tool for the GNU
system.  Package management consists of all activities that relate
to building packages from sources, honoring their build-time and
run-time dependencies, installing packages in user environments,
upgrading installed packages to new versions or rolling back to a
previous set, removing unused software packages, etc.</p>
<p>The term functional refers to a specific package management
discipline.  In Guix, the package build and installation process
is seen as a function, in the mathematical sense.  That function
takes inputs, such as build scripts, a compiler, and libraries,
and returns an installed package.</p>
</blockquote>
<p>Guix has a rich set of features, some of which you may find in other
package managers, but not all of them (unless you use another
functional package manager such as Nix.)  Gem/Bundler can do
unprivileged gem installation, but it cannot do transactional upgrades
and rollbacks or install non-Ruby dependencies.  Dpkg/yum/pacman can
install all build-time and rumtime dependencies, but it cannot do
unprivileged package installation to isolated user environments.  And
none of them can precisely describe the <em>full</em> dependency graph (all
the way down to the C compiler's compiler) but <em>Guix can</em>.</p>
<p>Guix is written in Guile, an implementation of the Scheme programming
language.  The upcoming release of Guix will feature a Ruby build
system that captures the process of installing gems from <tt>.gem</tt>
archives and a RubyGems import utility to make it easier to write Guix
packages by using the metadata available on <a href="https://rubygems.org/">https://rubygems.org</a>.
Ruby developers interested in functional package management are
encouraged to try packaging their gems (and dependencies) for Guix.</p>
<p>Now, how exactly can Guix replace RVM and Bundler?  Guix uses an
abstraction called a "profile" that represents a user-defined set of
packages that should work together.  Think of it as having many
<tt>/usr</tt> file system trees that can be used in isolation from the
others (without invoking virtualization technologies such as virtual
machines or containers.)  To install multiple versions of Ruby and
various gems, the user need only create a separate profile for them:</p>
<div><pre>guix package --profile=project-1 --install ruby-2.2 ruby-rspec-3
# Hypothetical packages:
guix package --profile=project-2 --install ruby-1.9 ruby-rspec-2
</pre></div>
<p>A profile is a "symlink forest" that is the union of all the packages
it includes, and files are deduplicated among all of them.  To
actually use the profile, the relevant environment variables must be
configured.  Guix is aware of such variables, and can tell you what to
set by running the following:</p>
<div><pre>guix package --search-paths --profile=project-1
</pre></div>
<p>Additionally, you can also create ad-hoc development environments with
the <tt>guix environment</tt> tool.  This tool will spawn a sub-shell (or
another program of your choice) in an environment in which a set of
specified packages are available.  This is my preferred method as it
automagically sets all of the environment variables for me and Guix is
free to garbage collect the packages when I close the sub-shell:</p>
<div><pre># Launch a Ruby REPL with ActiveSupport available.
guix environment --ad-hoc ruby ruby-activesupport -E irb
</pre></div>
<p>In order to make this environment reproducible for others, I recommend
keeping a <tt>package.scm</tt> file in version control that describes the
complete dependency graph for your project, as well as metadata such
as the license, version, and description:</p>
<div><pre><span>(</span><span>use-modules</span> <span>(</span><span>guix</span> <span>packages</span><span>)</span>
             <span>(</span><span>guix</span> <span>licenses</span><span>)</span>
             <span>(</span><span>guix</span> <span>build-system</span> <span>ruby</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>version-control</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>ssh</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>ruby</span><span>))</span>

<span>(</span><span>package</span>
  <span>(</span><span>name</span> <span>"cool-ruby-project"</span><span>)</span>
  <span>(</span><span>version</span> <span>"1.0"</span><span>)</span>
  <span>(</span><span>source</span> <span>#f</span><span>)</span> <span>; not needed just to create dev environment</span>
  <span>(</span><span>build-system</span> <span>ruby-build-system</span><span>)</span>
  <span>;; These correspond roughly to "development" dependencies.</span>
  <span>(</span><span>native-inputs</span>
   <span>`</span><span>((</span><span>"git"</span> <span>,</span><span>git</span><span>)</span>
     <span>(</span><span>"openssh"</span> <span>,</span><span>openssh</span><span>)</span>
     <span>(</span><span>"ruby-rspec"</span> <span>,</span><span>ruby-rspec</span><span>)))</span>
  <span>(</span><span>propagated-inputs</span>
   <span>`</span><span>((</span><span>"ruby-pg"</span> <span>,</span><span>ruby-pg</span><span>)</span>
     <span>(</span><span>"ruby-nokogiri"</span> <span>,</span><span>ruby-nokogiri</span><span>)</span>
     <span>(</span><span>"ruby-i18n"</span> <span>,</span><span>ruby-i18n</span><span>)</span>
     <span>(</span><span>"ruby-rails"</span> <span>,</span><span>ruby-rails</span><span>)))</span>
  <span>(</span><span>synopsis</span> <span>"A cool Ruby project"</span><span>)</span>
  <span>(</span><span>description</span> <span>"This software does some cool stuff, trust me."</span><span>)</span>
  <span>(</span><span>home-page</span> <span>"https://example.com"</span><span>)</span>
  <span>(</span><span>license</span> <span>expat</span><span>))</span>
</pre></div>
<p>With this package file, it is simple to an instantiate a development
environment:</p>
<div><pre>guix environment -l package.scm
</pre></div>
<p>I'm not covering it in this post, but properly filling out the blank
<tt>source</tt> field above would allow for building development snapshots,
including running the test suite, in an isolated build container using
the <tt>guix build</tt> utility.  This is a very useful when composed with
a continuous integration system.  Guix itself uses <a href="https://nixos.org/hydra/">Hydra</a> as its CI
system to perform all package builds.</p>
<p>As mentioned earlier, one of the big advantages of writing Guix
package recipes is that the full dependency graph can be captured,
including non-Ruby components.  The pg gem provides a good example:</p>
<div><pre><span>(</span><span>define-public</span> <span>ruby-pg</span>
  <span>(</span><span>package</span>
    <span>(</span><span>name</span> <span>"ruby-pg"</span><span>)</span>
    <span>(</span><span>version</span> <span>"0.18.2"</span><span>)</span>
    <span>(</span><span>source</span>
     <span>(</span><span>origin</span>
       <span>(</span><span>method</span> <span>url-fetch</span><span>)</span>
       <span>(</span><span>uri</span> <span>(</span><span>rubygems-uri</span> <span>"pg"</span> <span>version</span><span>))</span>
       <span>(</span><span>sha256</span>
        <span>(</span><span>base32</span>
         <span>"1axxbf6ij1iqi3i1r3asvjc80b0py5bz0m2wy5kdi5xkrpr82kpf"</span><span>))))</span>
    <span>(</span><span>build-system</span> <span>ruby-build-system</span><span>)</span>
    <span>(</span><span>arguments</span>
     <span>'</span><span>(</span><span>#</span><span>:test-target</span> <span>"spec"</span><span>))</span>
    <span>;; Native inputs are used only at build and test time.</span>
    <span>(</span><span>native-inputs</span>
     <span>`</span><span>((</span><span>"ruby-rake-compiler"</span> <span>,</span><span>ruby-rake-compiler</span><span>)</span>
       <span>(</span><span>"ruby-hoe"</span> <span>,</span><span>ruby-hoe</span><span>)</span>
       <span>(</span><span>"ruby-rspec"</span> <span>,</span><span>ruby-rspec</span><span>)))</span>
    <span>;; Native extension links against PostgreSQL shared library.</span>
    <span>(</span><span>inputs</span>
     <span>`</span><span>((</span><span>"postgresql"</span> <span>,</span><span>postgresql</span><span>)))</span>
    <span>(</span><span>synopsis</span> <span>"Ruby interface to PostgreSQL"</span><span>)</span>
    <span>(</span><span>description</span> <span>"Pg is the Ruby interface to the PostgreSQL RDBMS.  It works</span>
<span>with PostgreSQL 8.4 and later."</span><span>)</span>
    <span>(</span><span>home-page</span> <span>"https://bitbucket.org/ged/ruby-pg"</span><span>)</span>
    <span>(</span><span>license</span> <span>license:ruby</span><span>)))</span>
</pre></div>
<p>Note how the recipe specifies the PostgreSQL dependency.  Below is the
dependency graph for ruby-pg as produced by <tt>guix graph</tt>, excluding
the GCC compiler toolchain and other low-level tools for brevity.
Pretty neat, eh?</p>
<img alt="" src="http://dthompson.us/images/guix/ruby-pg-graph.png"><p>Given that Guix doesn't yet have many gems packaged (help wanted), it
can still be advantageous to use it for getting more up-to-date
packages than many distros provide, but in conjuction with Bundler for
fetching Ruby gems.  This gets RVM out of your hair whilst creating a
migration path away from Bundler at a later time once the required
gems have been packaged:</p>
<div><pre>cd my-project/
guix environment --ad-hoc ruby bundler libxml2 libxslt # etc.
# A small bash script can be used to make these gem sets.
mkdir .gems
export GEM_HOME=$PWD/.gems
export GEM_PATH=$GEM_HOME:$GEM_PATH
export PATH=$GEM_HOME/bin:$PATH
bundle install
</pre></div>
<p>As you've seen in the above package snippets, Guix package definitions
are typically very short and rather easy to write yourself.  The
<tt>guix import gem</tt> tool was made to lower the barrier even more by
generating most of the boilerplate code.  For example:</p>
<div><pre>guix import gem pry
</pre></div>
<p>Produces this Scheme code:</p>
<div><pre><span>(</span><span>package</span>
  <span>(</span><span>name</span> <span>"ruby-pry"</span><span>)</span>
  <span>(</span><span>version</span> <span>"0.10.1"</span><span>)</span>
  <span>(</span><span>source</span>
    <span>(</span><span>origin</span>
      <span>(</span><span>method</span> <span>url-fetch</span><span>)</span>
      <span>(</span><span>uri</span> <span>(</span><span>rubygems-uri</span> <span>"pry"</span> <span>version</span><span>))</span>
      <span>(</span><span>sha256</span>
        <span>(</span><span>base32</span>
          <span>"1j0r5fm0wvdwzbh6d6apnp7c0n150hpm9zxpm5xvcgfqr36jaj8z"</span><span>))))</span>
  <span>(</span><span>build-system</span> <span>ruby-build-system</span><span>)</span>
  <span>(</span><span>propagated-inputs</span>
    <span>`</span><span>((</span><span>"ruby-coderay"</span> <span>,</span><span>ruby-coderay</span><span>)</span>
      <span>(</span><span>"ruby-method-source"</span> <span>,</span><span>ruby-method-source</span><span>)</span>
      <span>(</span><span>"ruby-slop"</span> <span>,</span><span>ruby-slop</span><span>)))</span>
  <span>(</span><span>synopsis</span>
    <span>"An IRB alternative and runtime developer console"</span><span>)</span>
  <span>(</span><span>description</span>
    <span>"An IRB alternative and runtime developer console"</span><span>)</span>
  <span>(</span><span>home-page</span> <span>"http://pryrepl.org"</span><span>)</span>
  <span>(</span><span>license</span> <span>expat</span><span>))</span>
</pre></div>
<p>One still has to package the propagated inputs if they aren't yet
available, add the necessary inputs for building native extensions if
needed, and fiddle with the native inputs needed to run the test
suite, but for most pure Ruby gems this gets you close to a working
package quickly.</p>
<p>In conclusion, while support for Ruby in Guix is still in its early
days, I hope that you have seen the benefits that using a
general-purpose, functional package manager can bring to your Ruby
environments (and all other environments, too.)  For more information
about Guix concepts, installation instructions, programming interface,
and tools, please refer to the <a href="https://gnu.org/software/guix/manual/">official manual</a>.  Check out the
<a href="https://gnu.org/software/guix/help/">help</a> page for ways to contact the development team for help or to
report bugs.  If you are interested in getting your hands dirty,
please <a href="https://gnu.org/software/guix/contribute/">contribute</a>.  Besides contributions of code, art, and docs,
we also need <a href="https://gnu.org/software/guix/donate/">hardware donations</a> to grow our build farm to meet the
needs of all our users.  Happy hacking!</p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been working with Ruby professionally for over 3 years now and<br />
I&#8217;ve grown frustrated with two of its most popular development tools:<br />
RVM and Bundler.  For those that may not know, RVM is the Ruby version<br />
manager and it allows unprivileged users to download, compile,<br />
install, and manage many versions of Ruby instead of being stuck with<br />
the one that is installed globally by your distro&#8217;s package manager.<br />
Bundler is the tool that allows developers to keep a version<br />
controlled &quot;Gemfile&quot; that specifies all of the project&#8217;s dependencies<br />
and provides utilities to install and update those gems.  These tools<br />
are crucial because Ruby developers often work with many applications<br />
that use different versions of Ruby and/or different versions of gems<br />
such as Rails.  Traditional GNU/Linux distributions install packages<br />
to the global <tt class="docutils literal">/usr</tt> directory, limiting users to a single version<br />
of Ruby and associated gems, if they are packaged at all.  Traditional<br />
package management fails to meet the needs of a lot of users, so many<br />
niche package managers have been developed to supplement them.</p>
<p>Taking a step back, it becomes apparent that dependency isolation is a<br />
general problem that isn&#8217;t confined to software written in Ruby: Node<br />
has npm and nvm, Python has pip and virtualenv, and so on.  A big<br />
limitation of all these language-specific package managers is that<br />
they cannot control what is outside of their language domain.  In<br />
order to use RVM to successfully compile a version of Ruby, you need<br />
to make sure you have the GCC toolchain, OpenSSL, readline, libffi,<br />
etc. installed using the system package manager (note: I&#8217;ve seen RVM<br />
try to build prerequisites like OpenSSL before, which I then disabled<br />
to avoid duplication and security issues and I recommend you do the<br />
same.)  In order to use Bundler to install Nokogiri, you need to make<br />
sure libxml2 has been installed using the system package manager.  If<br />
you work with more than a single language, the number of different<br />
package management tools needed to get work done is staggering.  For<br />
web applications, it&#8217;s not uncommon to use RVM, Bundler, NPM, Bower,<br />
and the system package manager simultaneously to get all of the<br />
necessary programs and libraries.  Large web applications are<br />
notoriously difficult to deploy, and companies hire a bunch of<br />
operations folk like me to try to wrangle it all.</p>
<p>Anyway, let&#8217;s forget about Node, Python, etc. and just focus on Ruby.<br />
Have you or someone you work with encountered hard to debug issues and<br />
Git merge conflicts due to a problem with <tt class="docutils literal">Gemfile.lock</tt>?  Bundler&#8217;s<br />
fast and loose versioning in the <tt class="docutils literal">Gemfile</tt> (e.g. <tt class="docutils literal">rails &gt;= 4.0</tt>)<br />
causes headaches when different users update different gems at<br />
different times and check the resulting auto-generated<br />
<tt class="docutils literal">Gemfile.lock</tt> into the repository.  Have you ever been frustrated<br />
that it&#8217;s difficult to deduplicate gems that are shared between<br />
multiple bundled gem sets?  Have you looked at the <a class="reference external" href="https://rvm.io/">RVM home page</a><br />
and been frustrated that they recommend you to <tt class="docutils literal">curl | bash</tt> to<br />
install their software?  Have you been annoyed by RVM&#8217;s strange system<br />
of overriding shell built-ins in order to work its magic?  I&#8217;m not<br />
sure how you feel, dear reader, but my Ruby environments feel like one<br />
giant, brittle hack, and I&#8217;m often enough involved in fixing issues<br />
with them on my own workstation, that of my colleagues, and on<br />
production servers.</p>
<p>So, if you&#8217;re still with me, what do we do about this?  How can we<br />
work to improve upon the status quo?  Just use Docker?  Docker is<br />
helpful, and certainly much better than no isolation at all, but it<br />
hides the flaws of package management inside an opaque disk image and<br />
restricts the environments in which your application is built to<br />
function.  The general problem of dependency isolation is orthogonal<br />
to the runtime environment, be it container, virtual machine, or &quot;bare<br />
metal.&quot;  Enter functional package management.  What does it mean for a<br />
package manager to be functional?  GNU Guix, the functional package<br />
manager that I contribute to and recommend, has this to say:</p>
<blockquote>
<p>GNU Guix is a functional package management tool for the GNU<br />
system.  Package management consists of all activities that relate<br />
to building packages from sources, honoring their build-time and<br />
run-time dependencies, installing packages in user environments,<br />
upgrading installed packages to new versions or rolling back to a<br />
previous set, removing unused software packages, etc.</p>
<p>The term functional refers to a specific package management<br />
discipline.  In Guix, the package build and installation process<br />
is seen as a function, in the mathematical sense.  That function<br />
takes inputs, such as build scripts, a compiler, and libraries,<br />
and returns an installed package.</p>
</blockquote>
<p>Guix has a rich set of features, some of which you may find in other<br />
package managers, but not all of them (unless you use another<br />
functional package manager such as Nix.)  Gem/Bundler can do<br />
unprivileged gem installation, but it cannot do transactional upgrades<br />
and rollbacks or install non-Ruby dependencies.  Dpkg/yum/pacman can<br />
install all build-time and rumtime dependencies, but it cannot do<br />
unprivileged package installation to isolated user environments.  And<br />
none of them can precisely describe the <em>full</em> dependency graph (all<br />
the way down to the C compiler&#8217;s compiler) but <em>Guix can</em>.</p>
<p>Guix is written in Guile, an implementation of the Scheme programming<br />
language.  The upcoming release of Guix will feature a Ruby build<br />
system that captures the process of installing gems from <tt class="docutils literal">.gem</tt><br />
archives and a RubyGems import utility to make it easier to write Guix<br />
packages by using the metadata available on <a class="reference external" href="https://rubygems.org/">https://rubygems.org</a>.<br />
Ruby developers interested in functional package management are<br />
encouraged to try packaging their gems (and dependencies) for Guix.</p>
<p>Now, how exactly can Guix replace RVM and Bundler?  Guix uses an<br />
abstraction called a &quot;profile&quot; that represents a user-defined set of<br />
packages that should work together.  Think of it as having many<br />
<tt class="docutils literal">/usr</tt> file system trees that can be used in isolation from the<br />
others (without invoking virtualization technologies such as virtual<br />
machines or containers.)  To install multiple versions of Ruby and<br />
various gems, the user need only create a separate profile for them:</p>
<div class="highlight">
<pre>guix package --profile=project-1 --install ruby-2.2 ruby-rspec-3
# Hypothetical packages:
guix package --profile=project-2 --install ruby-1.9 ruby-rspec-2
</pre>
</div>
<p>A profile is a &quot;symlink forest&quot; that is the union of all the packages<br />
it includes, and files are deduplicated among all of them.  To<br />
actually use the profile, the relevant environment variables must be<br />
configured.  Guix is aware of such variables, and can tell you what to<br />
set by running the following:</p>
<div class="highlight">
<pre>guix package --search-paths --profile=project-1
</pre>
</div>
<p>Additionally, you can also create ad-hoc development environments with<br />
the <tt class="docutils literal">guix environment</tt> tool.  This tool will spawn a sub-shell (or<br />
another program of your choice) in an environment in which a set of<br />
specified packages are available.  This is my preferred method as it<br />
automagically sets all of the environment variables for me and Guix is<br />
free to garbage collect the packages when I close the sub-shell:</p>
<div class="highlight">
<pre># Launch a Ruby REPL with ActiveSupport available.
guix environment --ad-hoc ruby ruby-activesupport -E irb
</pre>
</div>
<p>In order to make this environment reproducible for others, I recommend<br />
keeping a <tt class="docutils literal">package.scm</tt> file in version control that describes the<br />
complete dependency graph for your project, as well as metadata such<br />
as the license, version, and description:</p>
<div class="highlight">
<pre><span class="p">(</span><span class="nf">use-modules</span> <span class="p">(</span><span class="nf">guix</span> <span class="nv">packages</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">guix</span> <span class="nv">licenses</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">guix</span> <span class="nv">build-system</span> <span class="nv">ruby</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">version-control</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">ssh</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">ruby</span><span class="p">))</span>

<span class="p">(</span><span class="nf">package</span>
  <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;cool-ruby-project&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;1.0&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">source</span> <span class="no">#f</span><span class="p">)</span> <span class="c1">; not needed just to create dev environment</span>
  <span class="p">(</span><span class="nf">build-system</span> <span class="nv">ruby-build-system</span><span class="p">)</span>
  <span class="c1">;; These correspond roughly to &quot;development&quot; dependencies.</span>
  <span class="p">(</span><span class="nf">native-inputs</span>
   <span class="o">`</span><span class="p">((</span><span class="s">&quot;git&quot;</span> <span class="o">,</span><span class="nv">git</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;openssh&quot;</span> <span class="o">,</span><span class="nv">openssh</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;ruby-rspec&quot;</span> <span class="o">,</span><span class="nv">ruby-rspec</span><span class="p">)))</span>
  <span class="p">(</span><span class="nf">propagated-inputs</span>
   <span class="o">`</span><span class="p">((</span><span class="s">&quot;ruby-pg&quot;</span> <span class="o">,</span><span class="nv">ruby-pg</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;ruby-nokogiri&quot;</span> <span class="o">,</span><span class="nv">ruby-nokogiri</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;ruby-i18n&quot;</span> <span class="o">,</span><span class="nv">ruby-i18n</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;ruby-rails&quot;</span> <span class="o">,</span><span class="nv">ruby-rails</span><span class="p">)))</span>
  <span class="p">(</span><span class="nf">synopsis</span> <span class="s">&quot;A cool Ruby project&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">description</span> <span class="s">&quot;This software does some cool stuff, trust me.&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;https://example.com&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">license</span> <span class="nv">expat</span><span class="p">))</span>
</pre>
</div>
<p>With this package file, it is simple to an instantiate a development<br />
environment:</p>
<div class="highlight">
<pre>guix environment -l package.scm
</pre>
</div>
<p>I&#8217;m not covering it in this post, but properly filling out the blank<br />
<tt class="docutils literal">source</tt> field above would allow for building development snapshots,<br />
including running the test suite, in an isolated build container using<br />
the <tt class="docutils literal">guix build</tt> utility.  This is a very useful when composed with<br />
a continuous integration system.  Guix itself uses <a class="reference external" href="https://nixos.org/hydra/">Hydra</a> as its CI<br />
system to perform all package builds.</p>
<p>As mentioned earlier, one of the big advantages of writing Guix<br />
package recipes is that the full dependency graph can be captured,<br />
including non-Ruby components.  The pg gem provides a good example:</p>
<div class="highlight">
<pre><span class="p">(</span><span class="nf">define-public</span> <span class="nv">ruby-pg</span>
  <span class="p">(</span><span class="nf">package</span>
    <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;ruby-pg&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;0.18.2&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">source</span>
     <span class="p">(</span><span class="nf">origin</span>
       <span class="p">(</span><span class="nf">method</span> <span class="nv">url-fetch</span><span class="p">)</span>
       <span class="p">(</span><span class="nf">uri</span> <span class="p">(</span><span class="nf">rubygems-uri</span> <span class="s">&quot;pg&quot;</span> <span class="nv">version</span><span class="p">))</span>
       <span class="p">(</span><span class="nf">sha256</span>
        <span class="p">(</span><span class="nf">base32</span>
         <span class="s">&quot;1axxbf6ij1iqi3i1r3asvjc80b0py5bz0m2wy5kdi5xkrpr82kpf&quot;</span><span class="p">))))</span>
    <span class="p">(</span><span class="nf">build-system</span> <span class="nv">ruby-build-system</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">arguments</span>
     <span class="o">&#39;</span><span class="p">(</span><span class="o">#</span><span class="nv">:test-target</span> <span class="s">&quot;spec&quot;</span><span class="p">))</span>
    <span class="c1">;; Native inputs are used only at build and test time.</span>
    <span class="p">(</span><span class="nf">native-inputs</span>
     <span class="o">`</span><span class="p">((</span><span class="s">&quot;ruby-rake-compiler&quot;</span> <span class="o">,</span><span class="nv">ruby-rake-compiler</span><span class="p">)</span>
       <span class="p">(</span><span class="s">&quot;ruby-hoe&quot;</span> <span class="o">,</span><span class="nv">ruby-hoe</span><span class="p">)</span>
       <span class="p">(</span><span class="s">&quot;ruby-rspec&quot;</span> <span class="o">,</span><span class="nv">ruby-rspec</span><span class="p">)))</span>
    <span class="c1">;; Native extension links against PostgreSQL shared library.</span>
    <span class="p">(</span><span class="nf">inputs</span>
     <span class="o">`</span><span class="p">((</span><span class="s">&quot;postgresql&quot;</span> <span class="o">,</span><span class="nv">postgresql</span><span class="p">)))</span>
    <span class="p">(</span><span class="nf">synopsis</span> <span class="s">&quot;Ruby interface to PostgreSQL&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">description</span> <span class="s">&quot;Pg is the Ruby interface to the PostgreSQL RDBMS.  It works</span>
<span class="s">with PostgreSQL 8.4 and later.&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;https://bitbucket.org/ged/ruby-pg&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">license</span> <span class="nv">license:ruby</span><span class="p">)))</span>
</pre>
</div>
<p>Note how the recipe specifies the PostgreSQL dependency.  Below is the<br />
dependency graph for ruby-pg as produced by <tt class="docutils literal">guix graph</tt>, excluding<br />
the GCC compiler toolchain and other low-level tools for brevity.<br />
Pretty neat, eh?</p>
<p><img data-recalc-dims="1" decoding="async" alt="" src="https://i0.wp.com/dthompson.us/images/guix/ruby-pg-graph.png?w=625" /></p>
<p>Given that Guix doesn&#8217;t yet have many gems packaged (help wanted), it<br />
can still be advantageous to use it for getting more up-to-date<br />
packages than many distros provide, but in conjuction with Bundler for<br />
fetching Ruby gems.  This gets RVM out of your hair whilst creating a<br />
migration path away from Bundler at a later time once the required<br />
gems have been packaged:</p>
<div class="highlight">
<pre>cd my-project/
guix environment --ad-hoc ruby bundler libxml2 libxslt # etc.
# A small bash script can be used to make these gem sets.
mkdir .gems
export GEM_HOME=$PWD/.gems
export GEM_PATH=$GEM_HOME:$GEM_PATH
export PATH=$GEM_HOME/bin:$PATH
bundle install
</pre>
</div>
<p>As you&#8217;ve seen in the above package snippets, Guix package definitions<br />
are typically very short and rather easy to write yourself.  The<br />
<tt class="docutils literal">guix import gem</tt> tool was made to lower the barrier even more by<br />
generating most of the boilerplate code.  For example:</p>
<div class="highlight">
<pre>guix import gem pry
</pre>
</div>
<p>Produces this Scheme code:</p>
<div class="highlight">
<pre><span class="p">(</span><span class="nf">package</span>
  <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;ruby-pry&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;0.10.1&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">source</span>
    <span class="p">(</span><span class="nf">origin</span>
      <span class="p">(</span><span class="nf">method</span> <span class="nv">url-fetch</span><span class="p">)</span>
      <span class="p">(</span><span class="nf">uri</span> <span class="p">(</span><span class="nf">rubygems-uri</span> <span class="s">&quot;pry&quot;</span> <span class="nv">version</span><span class="p">))</span>
      <span class="p">(</span><span class="nf">sha256</span>
        <span class="p">(</span><span class="nf">base32</span>
          <span class="s">&quot;1j0r5fm0wvdwzbh6d6apnp7c0n150hpm9zxpm5xvcgfqr36jaj8z&quot;</span><span class="p">))))</span>
  <span class="p">(</span><span class="nf">build-system</span> <span class="nv">ruby-build-system</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">propagated-inputs</span>
    <span class="o">`</span><span class="p">((</span><span class="s">&quot;ruby-coderay&quot;</span> <span class="o">,</span><span class="nv">ruby-coderay</span><span class="p">)</span>
      <span class="p">(</span><span class="s">&quot;ruby-method-source&quot;</span> <span class="o">,</span><span class="nv">ruby-method-source</span><span class="p">)</span>
      <span class="p">(</span><span class="s">&quot;ruby-slop&quot;</span> <span class="o">,</span><span class="nv">ruby-slop</span><span class="p">)))</span>
  <span class="p">(</span><span class="nf">synopsis</span>
    <span class="s">&quot;An IRB alternative and runtime developer console&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">description</span>
    <span class="s">&quot;An IRB alternative and runtime developer console&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;http://pryrepl.org&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">license</span> <span class="nv">expat</span><span class="p">))</span>
</pre>
</div>
<p>One still has to package the propagated inputs if they aren&#8217;t yet<br />
available, add the necessary inputs for building native extensions if<br />
needed, and fiddle with the native inputs needed to run the test<br />
suite, but for most pure Ruby gems this gets you close to a working<br />
package quickly.</p>
<p>In conclusion, while support for Ruby in Guix is still in its early<br />
days, I hope that you have seen the benefits that using a<br />
general-purpose, functional package manager can bring to your Ruby<br />
environments (and all other environments, too.)  For more information<br />
about Guix concepts, installation instructions, programming interface,<br />
and tools, please refer to the <a class="reference external" href="https://gnu.org/software/guix/manual/">official manual</a>.  Check out the<br />
<a class="reference external" href="https://gnu.org/software/guix/help/">help</a> page for ways to contact the development team for help or to<br />
report bugs.  If you are interested in getting your hands dirty,<br />
please <a class="reference external" href="https://gnu.org/software/guix/contribute/">contribute</a>.  Besides contributions of code, art, and docs,<br />
we also need <a class="reference external" href="https://gnu.org/software/guix/donate/">hardware donations</a> to grow our build farm to meet the<br />
needs of all our users.  Happy hacking!</p>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">3972</post-id>	</item>
		<item>
		<title>Reproducible Development Environments with GNU Guix</title>
		<link>http://dthompson.us/reproducible-development-environments-with-gnu-guix.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Sun, 09 Nov 2014 03:00:00 +0000</pubDate>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[guile]]></category>
		<category><![CDATA[guix]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=9a5370ca9c54a34a5168828756ea3cb0</guid>

					<description><![CDATA[<p>If you're a software developer, then you probably know very well that
setting up a project's development environment for the first time can
be a real pain.  Installing all of the necessary dependencies using
your system's package manager can be very tedious.  To "solve" this
problem, we have resorted to inventing new package managers and
dependency bundlers for pretty much every programming language.  Ruby
has rubygems and bundler, Python has pip and virtualenv, PHP has
composer, node.js has npm, and so on.  Wouldn't it be nice to instead
have a single package manager that can handle it all?  Enter <a href="https://gnu.org/software/guix">GNU
Guix</a>, a purely functional package manager and GNU/Linux
distribution.  Using Guix, you can easily create a development
environment for any software project using the <tt>guix environment</tt>
tool.</p>
<p><tt>guix environment</tt> is a new utility added in Guix 0.8, which should
be released in a few weeks.  It accepts one on more packages as input
and produces a new shell environment in which all of the dependencies
for those packages are made available.  For example, <tt>guix
environment emacs</tt> will get you everything you need to build GNU
Emacs from a source release tarball.  By default, your <tt>$SHELL</tt> is
spawned, but you may opt to use any arbitrary shell command instead.
If you've used Nix before, you may notice that this sounds exactly
like <tt><span>nix-shell</span></tt>, and that's because it was what inspired me to
write <tt>guix environment</tt>.</p>
<p>Now, let's take a look at an example.  One of my hobby projects is
<a href="https://gitorious.org/sly/sly">Sly</a>, a game engine written in Guile Scheme.  Here's the relevant Guix
code that will produce a complete development environment:</p>
<div><pre><span>;;; Copyright (C) 2014 David Thompson &#60;davet@gnu.org&#62;</span>
<span>;;;</span>
<span>;;; Sly is free software: you can redistribute it and/or modify it</span>
<span>;;; under the terms of the GNU General Public License as published by</span>
<span>;;; the Free Software Foundation, either version 3 of the License, or</span>
<span>;;; (at your option) any later version.</span>

<span>(</span><span>use-modules</span> <span>(</span><span>guix</span> <span>packages</span><span>)</span>
             <span>(</span><span>guix</span> <span>licenses</span><span>)</span>
             <span>(</span><span>guix</span> <span>build-system</span> <span>gnu</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>autotools</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>guile</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>gl</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>pkg-config</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>sdl</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>maths</span><span>)</span>
             <span>(</span><span>gnu</span> <span>packages</span> <span>image</span><span>))</span>

<span>;; The development environment needs a tweaked LD_LIBRARY_PATH for</span>
<span>;; finding libfreeimage.</span>
<span>(</span><span>define </span><span>freeimage</span>
  <span>(</span><span>package</span> <span>(</span><span>inherit</span> <span>freeimage</span><span>)</span>
    <span>(</span><span>native-search-paths</span>
     <span>(</span><span>list </span><span>(</span><span>search-path-specification</span>
            <span>(</span><span>variable</span> <span>"LD_LIBRARY_PATH"</span><span>)</span>
            <span>(</span><span>directories</span> <span>'</span><span>(</span><span>"lib"</span><span>)))))))</span>

<span>(</span><span>package</span>
  <span>(</span><span>name</span> <span>"sly"</span><span>)</span>
  <span>(</span><span>version</span> <span>"0.0"</span><span>)</span>
  <span>(</span><span>source</span> <span>#f</span><span>)</span>
  <span>(</span><span>build-system</span> <span>gnu-build-system</span><span>)</span>
  <span>(</span><span>inputs</span>
   <span>`</span><span>((</span><span>"pkg-config"</span> <span>,</span><span>pkg-config</span><span>)</span>
     <span>(</span><span>"autoconf"</span> <span>,</span><span>autoconf</span><span>)</span>
     <span>(</span><span>"automake"</span> <span>,</span><span>automake</span><span>)</span>
     <span>(</span><span>"guile"</span> <span>,</span><span>guile-2</span><span>.</span><span>0</span><span>)</span>
     <span>(</span><span>"guile-sdl"</span> <span>,</span><span>guile-sdl</span><span>)</span>
     <span>(</span><span>"guile-opengl"</span> <span>,</span><span>guile-opengl</span><span>)</span>
     <span>(</span><span>"gsl"</span> <span>,</span><span>gsl</span><span>)</span>
     <span>(</span><span>"freeimage"</span> <span>,</span><span>freeimage</span><span>)</span>
     <span>(</span><span>"mesa"</span> <span>,</span><span>mesa</span><span>)))</span>
  <span>(</span><span>synopsis</span> <span>"2D/3D game engine for GNU Guile"</span><span>)</span>
  <span>(</span><span>description</span> <span>"Sly is a 2D/3D game engine written in Guile Scheme.</span>
<span>Sly differs from most game engines in that it emphasizes functional</span>
<span>reactive programming and live coding."</span><span>)</span>
  <span>(</span><span>home-page</span> <span>"https://gitorious.org/sly/sly"</span><span>)</span>
  <span>(</span><span>license</span> <span>gpl3+</span><span>))</span>
</pre></div>
<p>You may have noticed that the source field has been set to false.
This is because the package is not for building and installing.  It's
sole purpose is to provide the necessary software needed to build Sly
from a fresh git checkout.</p>
<p>Assuming this code is in a file called <tt>package.scm</tt>, you can simply
run <tt>guix environment <span>-l</span> package.scm</tt> to spawn a shell for hacking
on Sly.  By default, the environment created is an augmented version
of your pre-existing shell's environment.  This is convenient when you
want to use your installed software in the new environment, such as
git.  However, it's important to make sure that the environment really
does have everything needed for development without relying on any
impurities introduced by your existing environment.  Without verifying
this, new developers might be frustrated to find out that the
environment provided to them is incomplete.  To verify, pass the
<tt><span>--pure</span></tt> flag and build from scratch.</p>
<p>So, <tt>guix environment</tt> is a pretty nice way to acquire all the
dependencies you need to work on a project, but there is still a lot
of room for improvement.  What if you were working on a web
application that required a running PostgreSQL database, Redis server,
and XMPP server?  It would be really great if Guix could handle
setting this up for you, too, a la Vagrant.  To do so, <tt>guix
environment</tt> could use the existing features of <tt>guix system</tt> to
spawn a new virtual machine that shared the host system's package
store and the project's source tree, and then spawn a shell with your
development environment.  I hope to implement this in the
not-too-distant future.  Until next time, happy hacking!</p>]]></description>
										<content:encoded><![CDATA[<p>If you&#8217;re a software developer, then you probably know very well that<br />
setting up a project&#8217;s development environment for the first time can<br />
be a real pain.  Installing all of the necessary dependencies using<br />
your system&#8217;s package manager can be very tedious.  To &quot;solve&quot; this<br />
problem, we have resorted to inventing new package managers and<br />
dependency bundlers for pretty much every programming language.  Ruby<br />
has rubygems and bundler, Python has pip and virtualenv, PHP has<br />
composer, node.js has npm, and so on.  Wouldn&#8217;t it be nice to instead<br />
have a single package manager that can handle it all?  Enter <a class="reference external" href="https://gnu.org/software/guix">GNU<br />
Guix</a>, a purely functional package manager and GNU/Linux<br />
distribution.  Using Guix, you can easily create a development<br />
environment for any software project using the <tt class="docutils literal">guix environment</tt><br />
tool.</p>
<p><tt class="docutils literal">guix environment</tt> is a new utility added in Guix 0.8, which should<br />
be released in a few weeks.  It accepts one on more packages as input<br />
and produces a new shell environment in which all of the dependencies<br />
for those packages are made available.  For example, <tt class="docutils literal">guix<br />
environment emacs</tt> will get you everything you need to build GNU<br />
Emacs from a source release tarball.  By default, your <tt class="docutils literal">$SHELL</tt> is<br />
spawned, but you may opt to use any arbitrary shell command instead.<br />
If you&#8217;ve used Nix before, you may notice that this sounds exactly<br />
like <tt class="docutils literal"><span class="pre">nix-shell</span></tt>, and that&#8217;s because it was what inspired me to<br />
write <tt class="docutils literal">guix environment</tt>.</p>
<p>Now, let&#8217;s take a look at an example.  One of my hobby projects is<br />
<a class="reference external" href="https://gitorious.org/sly/sly">Sly</a>, a game engine written in Guile Scheme.  Here&#8217;s the relevant Guix<br />
code that will produce a complete development environment:</p>
<div class="highlight">
<pre><span class="c1">;;; Copyright (C) 2014 David Thompson &lt;davet@gnu.org&gt;</span>
<span class="c1">;;;</span>
<span class="c1">;;; Sly is free software: you can redistribute it and/or modify it</span>
<span class="c1">;;; under the terms of the GNU General Public License as published by</span>
<span class="c1">;;; the Free Software Foundation, either version 3 of the License, or</span>
<span class="c1">;;; (at your option) any later version.</span>

<span class="p">(</span><span class="nf">use-modules</span> <span class="p">(</span><span class="nf">guix</span> <span class="nv">packages</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">guix</span> <span class="nv">licenses</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">guix</span> <span class="nv">build-system</span> <span class="nv">gnu</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">autotools</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">guile</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">gl</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">pkg-config</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">sdl</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">maths</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">gnu</span> <span class="nv">packages</span> <span class="nv">image</span><span class="p">))</span>

<span class="c1">;; The development environment needs a tweaked LD_LIBRARY_PATH for</span>
<span class="c1">;; finding libfreeimage.</span>
<span class="p">(</span><span class="k">define </span><span class="nv">freeimage</span>
  <span class="p">(</span><span class="nf">package</span> <span class="p">(</span><span class="nf">inherit</span> <span class="nv">freeimage</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">native-search-paths</span>
     <span class="p">(</span><span class="nb">list </span><span class="p">(</span><span class="nf">search-path-specification</span>
            <span class="p">(</span><span class="nf">variable</span> <span class="s">&quot;LD_LIBRARY_PATH&quot;</span><span class="p">)</span>
            <span class="p">(</span><span class="nf">directories</span> <span class="o">&#39;</span><span class="p">(</span><span class="s">&quot;lib&quot;</span><span class="p">)))))))</span>

<span class="p">(</span><span class="nf">package</span>
  <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;sly&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;0.0&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">source</span> <span class="no">#f</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">build-system</span> <span class="nv">gnu-build-system</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">inputs</span>
   <span class="o">`</span><span class="p">((</span><span class="s">&quot;pkg-config&quot;</span> <span class="o">,</span><span class="nv">pkg-config</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;autoconf&quot;</span> <span class="o">,</span><span class="nv">autoconf</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;automake&quot;</span> <span class="o">,</span><span class="nv">automake</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;guile&quot;</span> <span class="o">,</span><span class="nv">guile-2</span><span class="o">.</span><span class="mi">0</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;guile-sdl&quot;</span> <span class="o">,</span><span class="nv">guile-sdl</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;guile-opengl&quot;</span> <span class="o">,</span><span class="nv">guile-opengl</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;gsl&quot;</span> <span class="o">,</span><span class="nv">gsl</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;freeimage&quot;</span> <span class="o">,</span><span class="nv">freeimage</span><span class="p">)</span>
     <span class="p">(</span><span class="s">&quot;mesa&quot;</span> <span class="o">,</span><span class="nv">mesa</span><span class="p">)))</span>
  <span class="p">(</span><span class="nf">synopsis</span> <span class="s">&quot;2D/3D game engine for GNU Guile&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">description</span> <span class="s">&quot;Sly is a 2D/3D game engine written in Guile Scheme.</span>
<span class="s">Sly differs from most game engines in that it emphasizes functional</span>
<span class="s">reactive programming and live coding.&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;https://gitorious.org/sly/sly&quot;</span><span class="p">)</span>
  <span class="p">(</span><span class="nf">license</span> <span class="nv">gpl3+</span><span class="p">))</span>
</pre>
</div>
<p>You may have noticed that the source field has been set to false.<br />
This is because the package is not for building and installing.  It&#8217;s<br />
sole purpose is to provide the necessary software needed to build Sly<br />
from a fresh git checkout.</p>
<p>Assuming this code is in a file called <tt class="docutils literal">package.scm</tt>, you can simply<br />
run <tt class="docutils literal">guix environment <span class="pre">-l</span> package.scm</tt> to spawn a shell for hacking<br />
on Sly.  By default, the environment created is an augmented version<br />
of your pre-existing shell&#8217;s environment.  This is convenient when you<br />
want to use your installed software in the new environment, such as<br />
git.  However, it&#8217;s important to make sure that the environment really<br />
does have everything needed for development without relying on any<br />
impurities introduced by your existing environment.  Without verifying<br />
this, new developers might be frustrated to find out that the<br />
environment provided to them is incomplete.  To verify, pass the<br />
<tt class="docutils literal"><span class="pre">--pure</span></tt> flag and build from scratch.</p>
<p>So, <tt class="docutils literal">guix environment</tt> is a pretty nice way to acquire all the<br />
dependencies you need to work on a project, but there is still a lot<br />
of room for improvement.  What if you were working on a web<br />
application that required a running PostgreSQL database, Redis server,<br />
and XMPP server?  It would be really great if Guix could handle<br />
setting this up for you, too, a la Vagrant.  To do so, <tt class="docutils literal">guix<br />
environment</tt> could use the existing features of <tt class="docutils literal">guix system</tt> to<br />
spawn a new virtual machine that shared the host system&#8217;s package<br />
store and the project&#8217;s source tree, and then spawn a shell with your<br />
development environment.  I hope to implement this in the<br />
not-too-distant future.  Until next time, happy hacking!</p>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">3493</post-id>	</item>
		<item>
		<title>First GNU Guile Patch and More Guix Packages</title>
		<link>http://dthompson.us/first-gnu-guile-patch-and-more-guix-packages.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Sat, 23 Nov 2013 02:00:00 +0000</pubDate>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[guile]]></category>
		<category><![CDATA[guix]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=2577123a41e5bed615faac6966c502bd</guid>

					<description><![CDATA[<p>I have spent some of the last month working on contributing to GNU
Guile and now I can finally say that I have contributed code to the
project. Guile has several hash table implementations: a Guile native
one, SRFI-69, and R6RS. SRFI-69 contains a handy procedure,
<tt><span>alist-&#62;hash-table</span></tt>, which allows for a sort of hash literal-like
syntax:</p>
<div><pre><span>(</span><span>alist-&#62;hash-table</span>
 <span>'</span><span>((</span><span>foo</span> <span>.</span> <span>1</span><span>)</span>
   <span>(</span><span>bar</span> <span>.</span> <span>2</span><span>)</span>
   <span>(</span><span>baz</span> <span>.</span> <span>3</span><span>)))</span>
</pre></div>
<p>However, I prefer to use Guile's native hash implementation, and
SRFI-69 is incompatible with it, so I decided to port
<tt><span>alist-&#62;hash-table</span></tt>. Unfortunately, it was not as simple as writing
just one procedure. The native hash tables actually have 4 different
ways of doing key comparisons: Using <tt>equal?</tt>, <tt>eq?</tt>, <tt>eqv?</tt>,
and user-defined procedures. This is a design flaw because the user
must make sure to use the right procedures at all times rather than
simply set the <tt>hash</tt> and <tt>assoc</tt> procedures when creating the
hash table instance.</p>
<p>Below is the final implementation. Since 3 of the 4 variations were
essentially the same, I wrote a short macro to reduce code
duplication.</p>
<div><pre><span>;;;; Copyright (C) 2013 Free Software Foundation, Inc.</span>
<span>;;;;</span>
<span>;;;; This library is free software; you can redistribute it and/or</span>
<span>;;;; modify it under the terms of the GNU Lesser General Public</span>
<span>;;;; License as published by the Free Software Foundation; either</span>
<span>;;;; version 3 of the License, or (at your option) any later version.</span>
<span>;;;;</span>
<span>;;;; This library is distributed in the hope that it will be useful,</span>
<span>;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span>;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<span>;;;; Lesser General Public License for more details.</span>
<span>;;;;</span>
<span>;;;; You should have received a copy of the GNU Lesser General Public</span>
<span>;;;; License along with this library; if not, write to the Free Software</span>
<span>;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<span>;;;;</span>

<span>(</span><span>define-syntax-rule</span> <span>(</span><span>define-alist-converter</span> <span>name</span> <span>hash-set-proc</span><span>)</span>
  <span>(</span><span>define </span><span>(</span><span>name</span> <span>alist</span><span>)</span>
    <span>"Convert ALIST into a hash table."</span>
    <span>(</span><span>let </span><span>((</span><span>table</span> <span>(</span><span>make-hash-table</span><span>)))</span>
      <span>(</span><span>for-each </span><span>(</span><span>lambda </span><span>(</span><span>pair</span><span>)</span>
                  <span>(</span><span>hash-set-proc</span> <span>table</span> <span>(</span><span>car </span><span>pair</span><span>)</span> <span>(</span><span>cdr </span><span>pair</span><span>)))</span>
                <span>(</span><span>reverse </span><span>alist</span><span>))</span>
      <span>table</span><span>)))</span>

<span>(</span><span>define-alist-converter</span> <span>alist-&#62;hash-table</span> <span>hash-set!</span><span>)</span>
<span>(</span><span>define-alist-converter</span> <span>alist-&#62;hashq-table</span> <span>hashq-set!</span><span>)</span>
<span>(</span><span>define-alist-converter</span> <span>alist-&#62;hashv-table</span> <span>hashv-set!</span><span>)</span>

<span>(</span><span>define </span><span>(</span><span>alist-&#62;hashx-table</span> <span>hash</span> <span>assoc</span> <span>alist</span><span>)</span>
  <span>"Convert ALIST into a hash table with custom HASH and ASSOC</span>
<span>procedures."</span>
  <span>(</span><span>let </span><span>((</span><span>table</span> <span>(</span><span>make-hash-table</span><span>)))</span>
    <span>(</span><span>for-each </span><span>(</span><span>lambda </span><span>(</span><span>pair</span><span>)</span>
                <span>(</span><span>hashx-set!</span> <span>hash</span> <span>assoc</span> <span>table</span> <span>(</span><span>car </span><span>pair</span><span>)</span> <span>(</span><span>cdr </span><span>pair</span><span>)))</span>
              <span>(</span><span>reverse </span><span>alist</span><span>))</span>
    <span>table</span><span>))</span>
</pre></div>
<p>Not only did I manage to get my code into Guile, I was given commit
access to GNU Guix by the lead developer, Ludovic Court&#232;s. I have
never had commit access to any free software project repositories
besides my own. I feel quite honored, as cheesy as that may sound.</p>
<p>Packages for SDL and SDL2 have been merged into master, and packages
for SDL_gfx, SDL_image, SDL_mixer, SDL_net, and SDL_ttf for SDL 1.2
are pending review.</p>
<p>I like to show off the elegance of Guix package recipes, so here's
some code:</p>
<div><pre><span>;;; Copyright &#169; 2013 David Thompson &#60;dthompson2@worcester.edu&#62;</span>
<span>;;;</span>
<span>;;; This file is part of GNU Guix.</span>
<span>;;;</span>
<span>;;; GNU Guix is free software; you can redistribute it and/or modify it</span>
<span>;;; under the terms of the GNU General Public License as published by</span>
<span>;;; the Free Software Foundation; either version 3 of the License, or (at</span>
<span>;;; your option) any later version.</span>
<span>;;;</span>
<span>;;; GNU Guix is distributed in the hope that it will be useful, but</span>
<span>;;; WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span>;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span>;;; GNU General Public License for more details.</span>
<span>;;;</span>
<span>;;; You should have received a copy of the GNU General Public License</span>
<span>;;; along with GNU Guix.  If not, see &#60;http://www.gnu.org/licenses/&#62;.</span>

<span>(</span><span>define </span><span>sdl</span>
  <span>(</span><span>package</span>
    <span>(</span><span>name</span> <span>"sdl"</span><span>)</span>
    <span>(</span><span>version</span> <span>"1.2.15"</span><span>)</span>
    <span>(</span><span>source</span> <span>(</span><span>origin</span>
             <span>(</span><span>method</span> <span>url-fetch</span><span>)</span>
             <span>(</span><span>uri</span>
              <span>(</span><span>string-append </span><span>"http://libsdl.org/release/SDL-"</span>
                             <span>version</span> <span>".tar.gz"</span><span>))</span>
             <span>(</span><span>sha256</span>
              <span>(</span><span>base32</span>
               <span>"005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn"</span><span>))))</span>
    <span>(</span><span>build-system</span> <span>gnu-build-system</span><span>)</span>
    <span>(</span><span>arguments</span> <span>'</span><span>(</span><span>#</span><span>:tests?</span> <span>#f</span><span>))</span> <span>; no check target</span>
    <span>(</span><span>inputs</span> <span>`</span><span>((</span><span>"libx11"</span> <span>,</span><span>libx11</span><span>)</span>
              <span>(</span><span>"libxrandr"</span> <span>,</span><span>libxrandr</span><span>)</span>
              <span>(</span><span>"mesa"</span> <span>,</span><span>mesa</span><span>)</span>
              <span>(</span><span>"alsa-lib"</span> <span>,</span><span>alsa-lib</span><span>)</span>
              <span>(</span><span>"pkg-config"</span> <span>,</span><span>pkg-config</span><span>)</span>
              <span>(</span><span>"pulseaudio"</span> <span>,</span><span>pulseaudio</span><span>)))</span>
    <span>(</span><span>synopsis</span> <span>"Cross platform game development library"</span><span>)</span>
    <span>(</span><span>description</span> <span>"Simple DirectMedia Layer is a cross-platform development</span>
<span>library designed to provide low level access to audio, keyboard, mouse,</span>
<span>joystick, and graphics hardware."</span><span>)</span>
    <span>(</span><span>home-page</span> <span>"http://libsdl.org/"</span><span>)</span>
    <span>(</span><span>license</span> <span>lgpl2</span><span>.</span><span>1</span><span>)))</span>

<span>(</span><span>define </span><span>sdl2</span>
  <span>(</span><span>package</span> <span>(</span><span>inherit</span> <span>sdl</span><span>)</span>
    <span>(</span><span>name</span> <span>"sdl2"</span><span>)</span>
    <span>(</span><span>version</span> <span>"2.0.0"</span><span>)</span>
    <span>(</span><span>source</span> <span>(</span><span>origin</span>
             <span>(</span><span>method</span> <span>url-fetch</span><span>)</span>
             <span>(</span><span>uri</span>
              <span>(</span><span>string-append </span><span>"http://libsdl.org/release/SDL2-"</span>
                             <span>version</span> <span>".tar.gz"</span><span>))</span>
             <span>(</span><span>sha256</span>
              <span>(</span><span>base32</span>
               <span>"0y3in99brki7vc2mb4c0w39v70mf4h341mblhh8nmq4h7lawhskg"</span><span>))))</span>
    <span>(</span><span>license</span> <span>bsd-3</span><span>)))</span>
</pre></div>
<p>Much help is needed to package the GNU system for Guix. If you are
interested in helping, please drop by #guix on freenode, we are
friendly. :)</p>]]></description>
										<content:encoded><![CDATA[<p>I have spent some of the last month working on contributing to GNU<br />
Guile and now I can finally say that I have contributed code to the<br />
project. Guile has several hash table implementations: a Guile native<br />
one, SRFI-69, and R6RS. SRFI-69 contains a handy procedure,<br />
<tt class="docutils literal"><span class="pre">alist-&gt;hash-table</span></tt>, which allows for a sort of hash literal-like<br />
syntax:</p>
<div class="highlight">
<pre><span class="p">(</span><span class="nf">alist-&gt;hash-table</span>
 <span class="o">&#39;</span><span class="p">((</span><span class="nf">foo</span> <span class="o">.</span> <span class="mi">1</span><span class="p">)</span>
   <span class="p">(</span><span class="nf">bar</span> <span class="o">.</span> <span class="mi">2</span><span class="p">)</span>
   <span class="p">(</span><span class="nf">baz</span> <span class="o">.</span> <span class="mi">3</span><span class="p">)))</span>
</pre>
</div>
<p>However, I prefer to use Guile&#8217;s native hash implementation, and<br />
SRFI-69 is incompatible with it, so I decided to port<br />
<tt class="docutils literal"><span class="pre">alist-&gt;hash-table</span></tt>. Unfortunately, it was not as simple as writing<br />
just one procedure. The native hash tables actually have 4 different<br />
ways of doing key comparisons: Using <tt class="docutils literal">equal?</tt>, <tt class="docutils literal">eq?</tt>, <tt class="docutils literal">eqv?</tt>,<br />
and user-defined procedures. This is a design flaw because the user<br />
must make sure to use the right procedures at all times rather than<br />
simply set the <tt class="docutils literal">hash</tt> and <tt class="docutils literal">assoc</tt> procedures when creating the<br />
hash table instance.</p>
<p>Below is the final implementation. Since 3 of the 4 variations were<br />
essentially the same, I wrote a short macro to reduce code<br />
duplication.</p>
<div class="highlight">
<pre><span class="c1">;;;; Copyright (C) 2013 Free Software Foundation, Inc.</span>
<span class="c1">;;;;</span>
<span class="c1">;;;; This library is free software; you can redistribute it and/or</span>
<span class="c1">;;;; modify it under the terms of the GNU Lesser General Public</span>
<span class="c1">;;;; License as published by the Free Software Foundation; either</span>
<span class="c1">;;;; version 3 of the License, or (at your option) any later version.</span>
<span class="c1">;;;;</span>
<span class="c1">;;;; This library is distributed in the hope that it will be useful,</span>
<span class="c1">;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c1">;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<span class="c1">;;;; Lesser General Public License for more details.</span>
<span class="c1">;;;;</span>
<span class="c1">;;;; You should have received a copy of the GNU Lesser General Public</span>
<span class="c1">;;;; License along with this library; if not, write to the Free Software</span>
<span class="c1">;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<span class="c1">;;;;</span>

<span class="p">(</span><span class="nf">define-syntax-rule</span> <span class="p">(</span><span class="nf">define-alist-converter</span> <span class="nv">name</span> <span class="nv">hash-set-proc</span><span class="p">)</span>
  <span class="p">(</span><span class="k">define </span><span class="p">(</span><span class="nf">name</span> <span class="nv">alist</span><span class="p">)</span>
    <span class="s">&quot;Convert ALIST into a hash table.&quot;</span>
    <span class="p">(</span><span class="k">let </span><span class="p">((</span><span class="nf">table</span> <span class="p">(</span><span class="nf">make-hash-table</span><span class="p">)))</span>
      <span class="p">(</span><span class="nb">for-each </span><span class="p">(</span><span class="k">lambda </span><span class="p">(</span><span class="nf">pair</span><span class="p">)</span>
                  <span class="p">(</span><span class="nf">hash-set-proc</span> <span class="nv">table</span> <span class="p">(</span><span class="nb">car </span><span class="nv">pair</span><span class="p">)</span> <span class="p">(</span><span class="nb">cdr </span><span class="nv">pair</span><span class="p">)))</span>
                <span class="p">(</span><span class="nb">reverse </span><span class="nv">alist</span><span class="p">))</span>
      <span class="nv">table</span><span class="p">)))</span>

<span class="p">(</span><span class="nf">define-alist-converter</span> <span class="nv">alist-&gt;hash-table</span> <span class="nv">hash-set!</span><span class="p">)</span>
<span class="p">(</span><span class="nf">define-alist-converter</span> <span class="nv">alist-&gt;hashq-table</span> <span class="nv">hashq-set!</span><span class="p">)</span>
<span class="p">(</span><span class="nf">define-alist-converter</span> <span class="nv">alist-&gt;hashv-table</span> <span class="nv">hashv-set!</span><span class="p">)</span>

<span class="p">(</span><span class="k">define </span><span class="p">(</span><span class="nf">alist-&gt;hashx-table</span> <span class="nv">hash</span> <span class="nv">assoc</span> <span class="nv">alist</span><span class="p">)</span>
  <span class="s">&quot;Convert ALIST into a hash table with custom HASH and ASSOC</span>
<span class="s">procedures.&quot;</span>
  <span class="p">(</span><span class="k">let </span><span class="p">((</span><span class="nf">table</span> <span class="p">(</span><span class="nf">make-hash-table</span><span class="p">)))</span>
    <span class="p">(</span><span class="nb">for-each </span><span class="p">(</span><span class="k">lambda </span><span class="p">(</span><span class="nf">pair</span><span class="p">)</span>
                <span class="p">(</span><span class="nf">hashx-set!</span> <span class="nv">hash</span> <span class="nv">assoc</span> <span class="nv">table</span> <span class="p">(</span><span class="nb">car </span><span class="nv">pair</span><span class="p">)</span> <span class="p">(</span><span class="nb">cdr </span><span class="nv">pair</span><span class="p">)))</span>
              <span class="p">(</span><span class="nb">reverse </span><span class="nv">alist</span><span class="p">))</span>
    <span class="nv">table</span><span class="p">))</span>
</pre>
</div>
<p>Not only did I manage to get my code into Guile, I was given commit<br />
access to GNU Guix by the lead developer, Ludovic Courtès. I have<br />
never had commit access to any free software project repositories<br />
besides my own. I feel quite honored, as cheesy as that may sound.</p>
<p>Packages for SDL and SDL2 have been merged into master, and packages<br />
for SDL_gfx, SDL_image, SDL_mixer, SDL_net, and SDL_ttf for SDL 1.2<br />
are pending review.</p>
<p>I like to show off the elegance of Guix package recipes, so here&#8217;s<br />
some code:</p>
<div class="highlight">
<pre><span class="c1">;;; Copyright © 2013 David Thompson &lt;dthompson2@worcester.edu&gt;</span>
<span class="c1">;;;</span>
<span class="c1">;;; This file is part of GNU Guix.</span>
<span class="c1">;;;</span>
<span class="c1">;;; GNU Guix is free software; you can redistribute it and/or modify it</span>
<span class="c1">;;; under the terms of the GNU General Public License as published by</span>
<span class="c1">;;; the Free Software Foundation; either version 3 of the License, or (at</span>
<span class="c1">;;; your option) any later version.</span>
<span class="c1">;;;</span>
<span class="c1">;;; GNU Guix is distributed in the hope that it will be useful, but</span>
<span class="c1">;;; WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c1">;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="c1">;;; GNU General Public License for more details.</span>
<span class="c1">;;;</span>
<span class="c1">;;; You should have received a copy of the GNU General Public License</span>
<span class="c1">;;; along with GNU Guix.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>

<span class="p">(</span><span class="k">define </span><span class="nv">sdl</span>
  <span class="p">(</span><span class="nf">package</span>
    <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;sdl&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;1.2.15&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">source</span> <span class="p">(</span><span class="nf">origin</span>
             <span class="p">(</span><span class="nf">method</span> <span class="nv">url-fetch</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">uri</span>
              <span class="p">(</span><span class="nb">string-append </span><span class="s">&quot;http://libsdl.org/release/SDL-&quot;</span>
                             <span class="nv">version</span> <span class="s">&quot;.tar.gz&quot;</span><span class="p">))</span>
             <span class="p">(</span><span class="nf">sha256</span>
              <span class="p">(</span><span class="nf">base32</span>
               <span class="s">&quot;005d993xcac8236fpvd1iawkz4wqjybkpn8dbwaliqz5jfkidlyn&quot;</span><span class="p">))))</span>
    <span class="p">(</span><span class="nf">build-system</span> <span class="nv">gnu-build-system</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">arguments</span> <span class="o">&#39;</span><span class="p">(</span><span class="o">#</span><span class="nv">:tests?</span> <span class="no">#f</span><span class="p">))</span> <span class="c1">; no check target</span>
    <span class="p">(</span><span class="nf">inputs</span> <span class="o">`</span><span class="p">((</span><span class="s">&quot;libx11&quot;</span> <span class="o">,</span><span class="nv">libx11</span><span class="p">)</span>
              <span class="p">(</span><span class="s">&quot;libxrandr&quot;</span> <span class="o">,</span><span class="nv">libxrandr</span><span class="p">)</span>
              <span class="p">(</span><span class="s">&quot;mesa&quot;</span> <span class="o">,</span><span class="nv">mesa</span><span class="p">)</span>
              <span class="p">(</span><span class="s">&quot;alsa-lib&quot;</span> <span class="o">,</span><span class="nv">alsa-lib</span><span class="p">)</span>
              <span class="p">(</span><span class="s">&quot;pkg-config&quot;</span> <span class="o">,</span><span class="nv">pkg-config</span><span class="p">)</span>
              <span class="p">(</span><span class="s">&quot;pulseaudio&quot;</span> <span class="o">,</span><span class="nv">pulseaudio</span><span class="p">)))</span>
    <span class="p">(</span><span class="nf">synopsis</span> <span class="s">&quot;Cross platform game development library&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">description</span> <span class="s">&quot;Simple DirectMedia Layer is a cross-platform development</span>
<span class="s">library designed to provide low level access to audio, keyboard, mouse,</span>
<span class="s">joystick, and graphics hardware.&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;http://libsdl.org/&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">license</span> <span class="nv">lgpl2</span><span class="o">.</span><span class="mi">1</span><span class="p">)))</span>

<span class="p">(</span><span class="k">define </span><span class="nv">sdl2</span>
  <span class="p">(</span><span class="nf">package</span> <span class="p">(</span><span class="nf">inherit</span> <span class="nv">sdl</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;sdl2&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;2.0.0&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">source</span> <span class="p">(</span><span class="nf">origin</span>
             <span class="p">(</span><span class="nf">method</span> <span class="nv">url-fetch</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">uri</span>
              <span class="p">(</span><span class="nb">string-append </span><span class="s">&quot;http://libsdl.org/release/SDL2-&quot;</span>
                             <span class="nv">version</span> <span class="s">&quot;.tar.gz&quot;</span><span class="p">))</span>
             <span class="p">(</span><span class="nf">sha256</span>
              <span class="p">(</span><span class="nf">base32</span>
               <span class="s">&quot;0y3in99brki7vc2mb4c0w39v70mf4h341mblhh8nmq4h7lawhskg&quot;</span><span class="p">))))</span>
    <span class="p">(</span><span class="nf">license</span> <span class="nv">bsd-3</span><span class="p">)))</span>
</pre>
</div>
<p>Much help is needed to package the GNU system for Guix. If you are<br />
interested in helping, please drop by #guix on freenode, we are<br />
friendly. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2709</post-id>	</item>
		<item>
		<title>My First GNU Guix Patch</title>
		<link>http://dthompson.us/my-first-gnu-guix-patch.html</link>
		
		<dc:creator><![CDATA[David Thompson]]></dc:creator>
		<pubDate>Thu, 17 Oct 2013 01:00:00 +0000</pubDate>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[guile]]></category>
		<category><![CDATA[guix]]></category>
		<category><![CDATA[scheme]]></category>
		<category><![CDATA[WSU]]></category>
		<guid isPermaLink="false">http://cs.worcester.edu/blog/?guid=872d1a77f2493b80a67fd9ebc8732b68</guid>

					<description><![CDATA[<p>Over the weekend, I decided to try out GNU Guix: A fully functional
package manager based on Nix and a distribution of the GNU system. I'm
a big proponent of GNU Guile, thus I was excited to see a DSL for
package management written with Guile.</p>
<p>I was told that libtheora would be pretty easy to package, and it
was. Here's what the package definition looks like:</p>
<div><pre><span>(</span><span>define </span><span>libtheora</span>
  <span>(</span><span>package</span>
    <span>(</span><span>name</span> <span>"libtheora"</span><span>)</span>
    <span>(</span><span>version</span> <span>"1.1.1"</span><span>)</span>
    <span>(</span><span>source</span> <span>(</span><span>origin</span>
             <span>(</span><span>method</span> <span>url-fetch</span><span>)</span>
             <span>(</span><span>uri</span> <span>(</span><span>string-append </span><span>"http://downloads.xiph.org/releases/theora/libtheora-"</span>
                                 <span>version</span> <span>".tar.xz"</span><span>))</span>
             <span>(</span><span>sha256</span>
              <span>(</span><span>base32</span>
               <span>"0q8wark9ribij57dciym5vdikg2464p8q2mgqvfb78ksjh4s8vgk"</span><span>))))</span>
    <span>(</span><span>build-system</span> <span>gnu-build-system</span><span>)</span>
    <span>(</span><span>inputs</span> <span>`</span><span>((</span><span>"libvorbis"</span> <span>,</span><span>libvorbis</span><span>)))</span>
    <span>;; The .pc files refer to libogg.</span>
    <span>(</span><span>propagated-inputs</span> <span>`</span><span>((</span><span>"libogg"</span> <span>,</span><span>libogg</span><span>)))</span>
    <span>(</span><span>synopsis</span> <span>"Library implementing the Theora video format"</span><span>)</span>
    <span>(</span><span>description</span>
     <span>"The libtheora library implements the ogg theora video format,</span>
<span>a fully open, non-proprietary, patent-and-royalty-free, general-purpose</span>
<span>compressed video format."</span><span>)</span>
    <span>(</span><span>license</span> <span>license:bsd-3</span><span>)</span>
    <span>(</span><span>home-page</span> <span>"http://xiph.org/theora/"</span><span>)))</span>
</pre></div>
<p>Pretty slick, eh? Now, I'm starting to work on packaging SDL (1.2
and 2) and the SDL extensions (gfx, ttf, etc.), which are not quite as
easy. I hope to package all of the dependencies that guile-2d will
need to be available as a Guix package.</p>]]></description>
										<content:encoded><![CDATA[<p>Over the weekend, I decided to try out GNU Guix: A fully functional<br />
package manager based on Nix and a distribution of the GNU system. I&#8217;m<br />
a big proponent of GNU Guile, thus I was excited to see a DSL for<br />
package management written with Guile.</p>
<p>I was told that libtheora would be pretty easy to package, and it<br />
was. Here&#8217;s what the package definition looks like:</p>
<div class="highlight">
<pre><span class="p">(</span><span class="k">define </span><span class="nv">libtheora</span>
  <span class="p">(</span><span class="nf">package</span>
    <span class="p">(</span><span class="nf">name</span> <span class="s">&quot;libtheora&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">version</span> <span class="s">&quot;1.1.1&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">source</span> <span class="p">(</span><span class="nf">origin</span>
             <span class="p">(</span><span class="nf">method</span> <span class="nv">url-fetch</span><span class="p">)</span>
             <span class="p">(</span><span class="nf">uri</span> <span class="p">(</span><span class="nb">string-append </span><span class="s">&quot;http://downloads.xiph.org/releases/theora/libtheora-&quot;</span>
                                 <span class="nv">version</span> <span class="s">&quot;.tar.xz&quot;</span><span class="p">))</span>
             <span class="p">(</span><span class="nf">sha256</span>
              <span class="p">(</span><span class="nf">base32</span>
               <span class="s">&quot;0q8wark9ribij57dciym5vdikg2464p8q2mgqvfb78ksjh4s8vgk&quot;</span><span class="p">))))</span>
    <span class="p">(</span><span class="nf">build-system</span> <span class="nv">gnu-build-system</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">inputs</span> <span class="o">`</span><span class="p">((</span><span class="s">&quot;libvorbis&quot;</span> <span class="o">,</span><span class="nv">libvorbis</span><span class="p">)))</span>
    <span class="c1">;; The .pc files refer to libogg.</span>
    <span class="p">(</span><span class="nf">propagated-inputs</span> <span class="o">`</span><span class="p">((</span><span class="s">&quot;libogg&quot;</span> <span class="o">,</span><span class="nv">libogg</span><span class="p">)))</span>
    <span class="p">(</span><span class="nf">synopsis</span> <span class="s">&quot;Library implementing the Theora video format&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">description</span>
     <span class="s">&quot;The libtheora library implements the ogg theora video format,</span>
<span class="s">a fully open, non-proprietary, patent-and-royalty-free, general-purpose</span>
<span class="s">compressed video format.&quot;</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">license</span> <span class="nv">license:bsd-3</span><span class="p">)</span>
    <span class="p">(</span><span class="nf">home-page</span> <span class="s">&quot;http://xiph.org/theora/&quot;</span><span class="p">)))</span>
</pre>
</div>
<p>Pretty slick, eh? Now, I&#8217;m starting to work on packaging SDL (1.2<br />
and 2) and the SDL extensions (gfx, ttf, etc.), which are not quite as<br />
easy. I hope to package all of the dependencies that guile-2d will<br />
need to be available as a Guix package.</p>

<p class="syndicated-attribution"><em>From the blog <a href="http://dthompson.us/">dthompson</a> by <a href="https://cs.worcester.edu/author/0/" title="Read other posts by David Thompson">David Thompson</a></em> and used with permission of the author. All other rights reserved by the author.</p>]]></content:encoded>
					
		
		<enclosure url="" length="0" type="" />

		<post-id xmlns="com-wordpress:feed-additions:1">2685</post-id>	</item>
	</channel>
</rss>
