Next: , Previous: , Up: Setup   [Contents][Index] ‘GUIX_PACKAGE_PATH

Note: Starting from Guix 0.16, the more flexible Guix channels are the preferred way and supersede ‘GUIX_PACKAGE_PATH’. See next section.

It can be tedious to specify the file from the command line instead of simply calling guix package --install my-hello as you would do with the official packages.

Guix makes it possible to streamline the process by adding as many “package declaration directories” as you want.

Create a directory, say ~/guix-packages and add it to the ‘GUIX_PACKAGE_PATH’ environment variable:

$ mkdir ~/guix-packages
$ export GUIX_PACKAGE_PATH=~/guix-packages

To add several directories, separate them with a colon (:).

Our previous ‘my-hello’ needs some adjustments though:

(define-module (my-hello)
  #:use-module (guix licenses)
  #:use-module (guix packages)
  #:use-module (guix build-system gnu)
  #:use-module (guix download))

(define-public my-hello
    (name "my-hello")
    (version "2.10")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://gnu/hello/hello-" version
    (build-system gnu-build-system)
    (synopsis "Hello, Guix world: An example custom Guix package")
     "GNU Hello prints the message \"Hello, world!\" and then exits.  It
serves as an example of standard GNU coding practices.  As such, it supports
command-line arguments, multiple languages, and so on.")
    (home-page "")
    (license gpl3+)))

Note that we have assigned the package value to an exported variable name with define-public. This is effectively assigning the package to the my-hello variable so that it can be referenced, among other as dependency of other packages.

If you use guix package --install-from-file=my-hello.scm on the above file, it will fail because the last expression, define-public, does not return a package. If you want to use define-public in this use-case nonetheless, make sure the file ends with an evaluation of my-hello:

; ...
(define-public my-hello
  ; ...


This last example is not very typical.

Now ‘my-hello’ should be part of the package collection like all other official packages. You can verify this with:

$ guix package --show=my-hello

Next: , Previous: , Up: Setup   [Contents][Index]