Skip to content

GNU Guix guide

GNU Guix

GNU Guix is an alternative to the module system that gives users greater freedom and control over the software they use. Unlike the module system, which offers software centrally installed by administrators, Guix allows you to:

  • Install software without administrator privileges
  • Create and manage custom software environments
  • Use multiple versions of the same program simultaneously
  • Share precisely defined environments

Guix is already installed and ready to use on the cluster, and it can be used either on its own or together with the module system.

How Guix Stores Packages

Guix uses a unique approach to storing software packages:

  • All packages are stored in the /gnu/store directory
  • Each package has a unique path containing its name and a hash value (for example, /gnu/store/d9r7...8zvk-python-3.9.7)

Basic Guix Commands

Package Management

Guix offers simple commands for managing packages:

Command Description
guix search python Search for packages
guix install python Install a package
guix install python@3.9.7 Install a specific version
guix remove python Remove a package
guix package --list-installed List installed packages

Finding Available Packages

To find which packages Guix supports, you can use the following methods:

  1. Search by keyword:

    guix search <keyword>
    

  2. Search by category:

    guix search -c <category>
    guix search -c education
    guix search -c mathematics
    

Package catalogs:

Creating enviorments

Guix also supports creating isolated environments

guix shell python python-numpy python-scipy

This command opens a new shell with the specified packages available.

Manifest files

Manifest files let you define an environment as code, making it reproducible and shareable.

Creating a simple manifest

  • Create a file named manifest.scm:

(specifications->manifest
 '("python"
   "python-numpy"
   "python-scipy"
   "python-matplotlib"))
Here you list all the packages you want to use.

Using a manifest file

  • To use an existing manifest file with guix shell:
guix shell -m manifest.scm
  • Or install the packages into your profile:
guix package -m manifest.scm

For detailed information on writing manifests, see here.

Exporting a manifest from the current environment

When you have tailored your environment with multiple packages and want to recreate it or share it.

To export a manifest file from the packages already installed in your profile:

guix package --export-manifest > manifest.scm

You can then use this file to ensure identical environments.

Guix with Slurm

A simple example of using Guix with Slurm:

#!/bin/bash
#SBATCH --job-name=guix-test
#SBATCH --ntasks=1
#SBATCH --time=01:00:00

# Run Python with the required libraries
guix shell python python-numpy -- python my_script.py

# Or use a manifest file
# guix shell -m manifest.scm -- python my_script.py

Additional resources