Development Environments with GUIX shell

2025-01-04 @rrobin

Since I use guix I often want to setup an environment when I am developing some program using guix packages.

As an example lets say I am starting to work on some C code with some dependencies (pkg-config, efl), and create a manifest file with the development dependencies e.g.

(specifications->manifest
  '("gcc-toolchain" "make" "pkg-config" "efl"))

I can then call guix shell using this file with:

guix shell -m manifest.scm

This will start a shell with all the dependencies I need to build my project.

Later I might create an actual package for my software project, e.g. defined in guix.scm in my repository. Here is a silly (and incomplete) example

(package
  (name "hello")
  (version "dev")
  (source %project-files)
  ; build time inputs
  (inputs
    (list efl gcc-toolchain pkg-config))
  (build-system gnu-build-system)
  (synopsis "little hello example in efl")
  (description "....")
  (home-page "...")
  (license license:gpl3))

Notice my inputs are the same packages used in manifest.scm i.e. they are the dependencies needed to build this package. Now that I have this package recipe I can change the previous manifest.scm to rely on it instead:

(package->development-manifest (load "guix.scm"))

However I sometimes need more tools in my development environment. For example I want gdb to debug some issues. So I can change manifest.scm to include this too:

(define %dev-manifest (package->development-manifest (load "guix.scm")))
(define %tools-manifest (specifications->manifest '("gdb")))
(concatenate-manifests (list %dev-manifest %tools-manifest))

and that is it.

References

=> https://guix.gnu.org/manual/en/html_node/Writing-Manifests.html#package_002ddevelopment_002dmanifest

Proxy Information
Original URL
gemini://tilde.pink/~rrobin/2025-01-04-development-environements-with-guix-shell.gmi
Status Code
Success (20)
Meta
text/gemini;
Capsule Response Time
36.298263 milliseconds
Gemini-to-HTML Time
0.353931 milliseconds

This content has been proxied by September (ba2dc).