6.1 Guix-profiler i praktiken
Guix provides a very useful feature that may be quite foreign to newcomers:
profiles. They are a way to group package installations together and
all users on the same system are free to use as many profiles as they want.
Whether you’re a developer or not, you may find that multiple profiles bring
you great power and flexibility. While they shift the paradigm somewhat
compared to traditional package managers, they are very convenient to
use once you’ve understood how to set them up.
Observera: This section is an opinionated guide on the use of multiple profiles. It
predates guix shell
and its fast profile cache (see Invoking
guix shell in GNU Guix Reference Manual).
In many cases, you may find that using guix shell
to set up the
environment you need, when you need it, is less work that maintaining a
dedicated profile. Your call!
If you are familiar with Python’s ‘virtualenv’, you can think of a
profile as a kind of universal ‘virtualenv’ that can hold any kind of
software whatsoever, not just Python software. Furthermore, profiles are
self-sufficient: they capture all the runtime dependencies which guarantees
that all programs within a profile will always work at any point in time.
Multiple profiles have many benefits:
- Clean semantic separation of the various packages a user needs for different
contexts.
- Multiple profiles can be made available into the environment either on login
or within a dedicated shell.
- Profiles can be loaded on demand. For instance, the user can use multiple
shells, each of them running different profiles.
- Isolation: Programs from one profile will not use programs from the other,
and the user can even install different versions of the same programs to the
two profiles without conflict.
- Deduplication: Profiles share dependencies that happens to be the exact
same. This makes multiple profiles storage-efficient.
- Reproducible: when used with declarative manifests, a profile can be fully
specified by the Guix commit that was active when it was set up. This means
that the exact same profile can be
set up anywhere and anytime, with just the commit information. See the
section on Reproducerbara profiler.
- Easier upgrades and maintenance: Multiple profiles make it easy to keep
package listings at hand and make upgrades completely frictionless.
Concretely, here follows some typical profiles:
- The dependencies of a project you are working on.
- Your favourite programming language libraries.
- Laptop-specific programs (like ‘powertop’) that you don’t need on a
desktop.
- TeXlive (this one can be really useful when you need to install just one
package for this one document you’ve just received over email).
- Spel.
Let’s dive in the set up!