Guix: List of Packages in Your Default Profile

(Some credit goes to the helpful folks in the #guix irc channel.)

If you are wanting to build a package manifest file, it is helpful to run code like in this example, which gives a list of packages in your profile by package name:

<username>@nightshade ~$ guix repl
GNU Guile 3.0.4
Copyright (C) 1995-2020 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> ,use (guix profiles)
scheme@(guix-user)> (map manifest-entry-name (manifest-entries (profile-manifest "/home/<username>/.guix-profile")))
$1 = ("abbaye" "alex4" "astromenace" "audacity" "avr-toolchain" "bambam" "bombadillo" "bsd-games" "bzflag" "celestia-gtk" "chess" "corsix-th" "cool-retro-term" "cpupower" "curseradio" "dfu-programmer" "dosbox" "eboard" "edgar" "emacs" "emacs-arduino-mode" "emacs-doom-modeline" "emacs-doom-themes" "emacs-elpher" "emacs-geiser" "emacs-guix" "emacs-magit" "emacs-shell-pop" "emacs-spinner" "emacs-wget" "emacs-youtube-dl" "endless-sky" "file" "frozen-bubble" "ghex" "git" "gitg" "gforth" "glibc-locales" "gnome-shell-extensions" "gnucash" "gnupg" "gnuplot" "graphviz" "guile" "guile-colorized" "guile-hall" "guile-readline" "icedtea" "inkscape" "keepassxc" "kitty" "lm-sensors" "linphoneqt" "lure" "maxima" "meritous" "microscheme" "mps-youtube" "no-more-secrets" "openssh" "opensurge" "p7zip" "picocom" "pioneers" "qemu" "recutils" "screen" "starfighter" "stockfish" "strace" "supertux" "supertuxkart" "tig" "tree" "tuxpaint" "unzip" "warzone2100" "wget2" "wgetpaste" "wxmaxima" "xaos" "xboard" "xmoto" "xsensors" "youtube-dl" "youtube-viewer" "zip")

You can then copy and paste the list into a manifest file of this format:

(specifications->manifest '("abbaye" "alex4" ...etc... "zip"))

This is not quite a perfect conversion method as we have ignored some of the details of the profile entries like output type (e.g., out and utils). That could all be handled with some more guile scheme handling of the manifest entries, but I’m not feeling motivated to work out an example for this post.

Guix: How to Change Your Default CPU Frequency Governor

There are I believe a few ways to do this, but I think this is the simplest: Simply insert the following code, nested in your operating-system declaration:

  (kernel-arguments (cons "cpufreq.default_governor=conservative" %default-kernel-arguments))

Replace “conservative” with the governor you want. The same code in an example operating-system declaration:

(operating-system
  (locale "en_US.utf8")
  (timezone "America/Anchorage")
  (keyboard-layout
    (keyboard-layout "us" "altgr-intl"))
  (bootloader
    (bootloader-configuration
      (bootloader grub-bootloader)
      (target "/dev/sda")
      (keyboard-layout keyboard-layout)))
  (kernel-arguments (cons "cpufreq.default_governor=conservative" %default-kernel-arguments))
<etc...>

From what I was told (on IRC) this method will only work with linux kernel release 5.9 or later, which was only added to the Guix main repository five days ago. So you might need to run a guix pull first if you haven’t update Guix in a while. The newer kernel has a feature to allow you to pass in the default governor as a boot parameter, rather than having to recompile the kernel.

(As a side note, today’s commits of the Guix master repository have a broken gdm login manager so I actually used commit b618c15 from five days ago to test the feature being highlighted in this blog post.)

The cpupower command will give you a list of governors available for your system. I would recommend “ondemand” for most users, as that lowers your cpu frequency when the system is running at lower loads, saving you electricity and heat. However, I prefer “conservative”, which is the same, but waits a little longer before bumping up the frequency, so as to not overreact to quick load spikes. “Powersave”, I believe, keeps you running always at the lowest frequency, while “performance” keeps you running always at the highest frequency.

christopher@nightshade ~$ sudo cpupower frequency-info
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4.0 us
  hardware limits: 800 MHz - 3.30 GHz
  available frequency steps:  3.30 GHz, 2.60 GHz, 2.10 GHz, 800 MHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 800 MHz and 3.30 GHz.
                  The governor "conservative" may decide which speed to use
                  within this range.
  current CPU frequency: 800 MHz (asserted by call to hardware)
  boost state support:
    Supported: no
    Active: no
    Boost States: 0
    Total States: 4
    Pstate-P0:  3300MHz
    Pstate-P1:  2600MHz
    Pstate-P2:  2100MHz
    Pstate-P3:  800MHz

Guix: Manifest Functions

A technically unnecessary but hopefully interesting introduction: One cool thing about Gnu Guix is the ability to use manifests, which are a declarative definition of the package outputs of a profile. In other words, instead of running the commands

guix install emacs
guix install frozen-bubble
guix install git

You can just have a manifest file like

(specifications->manifest
  '("emacs"
    "frozen-bubble"
    "git"))

saved in a file, say, “christopher-home.scm”, and then feed it into the package manager to define your whole package profile at once:

guix package -m /home/christopher/Manifests/christopher-home.scm

That is nice, because then you can just edit that file to change your package set. Also, you can backup that file, copy it to another computer, or put it under version control.

Another great feature of Guix is the ability to have multiple profiles. A profile is basically a set of package outputs that are exposed in the same place with accompanying environment information. My default profile is programs, libraries, etc. that I want to have easy access to most of the time (not including their dependencies, which is another matter taken care of “behind the scene”). But I can create another profile that just exposes a few programs and libraries that I need for some special purpose.

Probably the most likely example would be certain libraries or programs needed for building or for running some piece of downloaded software. My real life example is trying to run the downloaded (pre-built) version of the Arduino IDE, which is not yet packaged in Guix. To do this I needed some particular system libraries, as well as Java, leading to this specification:

(use-modules (gnu packages gcc))

(concatenate-manifests
 (list
  (specifications->manifest
   '("avr-toolchain"
     "dfu-programmer"
     "gcc-toolchain"
     "glibc"
     "icedtea"
     "libx11"
     "libxrandr"
     "libxtst"))
  (packages->manifest
   `((,gcc "lib")))))

In my case, I install this profile with

guix package -m /home/christopher/Manifests/arduino.scm -p /home/christopher/.guix-extra-profiles/arduino/arduino

And so we come to the ostensible purpose of this post, to describe two features useful in constructing manifests, not really covered well in the Guix reference manual:

First, there is the concatenate-manifests procedure from the (guix profiles) module. This allows you to combine together a manifest constructed by specifications->manifest, along with one constructed by packages->manifest. For most packages you want to use specifications->manifest, because that convenient procedure saves you the bother of having to explicitly import the required package definitions. But, sometimes you need packages->manifest, which leads to the second thing I wanted to mention:

When using packages->manifest, you can specify your manifest entries as tuples containing the package object followed by a string describing the specific package output you need. In my case, this is critical, as I need to use the “hidden” package gcc (in order, if you must know, to get the libstdc++ library exposed) as well as the specific package output lib, since the default output did not expose the required library.

Further reading:

Gnu Hurd on Guix

It is a simple process to build a Hurd vm from Guix:


christopher@nightshade ~/Scratch$ guix build -S guix
/gnu/store/f8qhkr6lzzmw7a5v44nqvbi1gg8cyh85-guix-1.1.0-4.bdc801e-checkout
christopher@nightshade ~/Scratch$ guix build -f /gnu/store/f8qhkr6lzzmw7a5v44nqvbi1gg8cyh85-guix-1.1.0-4.bdc801e-checkout/gnu/system/hurd.scm
/gnu/store/4l65yggpi0v6y9pi8q7aij17zx28wyzp-qemu-image
christopher@nightshade ~/Scratch$ cp /gnu/store/4l65yggpi0v6y9pi8q7aij17zx28wyzp-qemu-image ~/Scratch/
christopher@nightshade ~/Scratch$ sudo qemu-system-i386 -enable-kvm -m 512 -snapshot -hda 4l65yggpi0v6y9pi8q7aij17zx28wyzp-qemu-image

The VM from this config does not have guix (package manager) installed, so it is somewhat limited what you could do with it. (I think there is a fancier version in a Guix development branch somewhere.) But guile scheme is installed already!

From what I understand, before Guix, Debian was the only distro that had made a Gnu Hurd system practical. But Guix is making rapid progress. I believe the benefits of Guix development investment in Hurd will be more enduring also, due to the functional nature of the Guix package management system.

For the “official” Guix plans to deprecate Linux kernel support, see the following link:

http://guix.gnu.org/blog/2020/deprecating-support-for-the-linux-kernel/