Guix Packager's Guide

This is a guide/cheatsheet for writing Guix packages.

Example package definitions file

(define-module (my-packages)
  #:use-module (ice-9 fdes-finalizers)
  #:use-module (guix utils)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system meson)
  #:use-module (guix licenses)
  #:use-module (guix packages)
  #:use-module (gnu packages)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages music))

(define-public zlfo
    (name "zlfo")
    (version "0.1.3")
       (method git-fetch)
       (uri (git-reference
             (url "")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
    (build-system meson-build-system)
     `(("librsvg" ,librsvg)
       ("lv2" ,lv2)
       ("ztoolkit-rsvg" ,ztoolkit-rsvg)))
     `(("pkg-config" ,pkg-config)))
    (synopsis "Low frequency oscillator plugin")
    (description "ZLFO is a fully featured
@dfn{low frequency oscillator} (LFO) for @dfn{control voltage} (CV)-based
automation that comes as an LV2 plugin bundle with a custom UI.")
    (home-page "")
    (license license:agpl3+)))

;; more packages here

The rest of this guide assumes this file is saved as my-packages.scm under the current dir.

Build a package from definition

guix build -L . -K zlfo
  • -L specifies the directory where the package definitions are
  • -K tells guix to keep the temporary build dir if the build fails

Force-rebuild a package

guix build --check --no-grafts zlfo

Deprecate a package

(define-public zlfo
  ;; The "zlfo" package is now included in zplugins
  (deprecated-package "zlfo" zplugins))

Use source as input

    ,(let ((commit "c51d03f11be20cb35eb28e8016e9a81827b50339"))
         (method git-fetch)
         (uri (git-reference
                (url "")
                (commit commit)))
           (base32 "1mkjbixvp7q1fyz9s7qn152iv6c03gfwjbx32dymcx2jayjlakp4"))
         (file-name "juce-src"))))))

Delete a phase

 `(#:tests? #f  ; no "check" target
   (modify-phases %standard-phases
     (delete 'configure))))

Change Make flags

   (list "--directory=extras/Projucer/Builds/LinuxMakefile" "CONFIG=Release")))

Copy a file during install

   (modify-phases %standard-phases
     (replace 'install
       (lambda* (#:key outputs #:allow-other-keys)
         (let* ((out (assoc-ref outputs "out"))
                (bin (string-append out "/bin")))
           (mkdir-p bin)
           (copy-file "extras/Projucer/Builds/LinuxMakefile/build/Projucer"
                      (string-append bin "/Projucer"))))))))

Various procedures

;; setting an env variable
(setenv "GDK_BACKEND" "x11")

;; invoking a command
(invoke "patch" "-N" "Builds/LinuxMakefile/Makefile"


  1. Libraries should list their pkgconfig dependencies as propagated-inputs (see librsvg for example)
By Alexandros Theodotou in
Tags : #packaging,