Environments are part of Guix, and installed by default.
1. downloading or building packages in environment
$ guix environment --ad-hoc python python-numpy
--ad-hoc argument means that you want
python-numpy as immediate packages. Without this argument, Guix will give you the dependencies of
numpy themselves, which are those packages needed for compiling python and numpy. You don’t want to compile them, rather, you want to use them for your project, hence the
2. In the following example guix will remove all existing environment variables predefined in your shell. Which means the new environment is pure. You won’t be able to access any existing commands in your system except for python3.
$ guix environment --ad-hoc python python-numpy --pure
3. You can write down your needed package in a file possibly named “foo-manifest.scm” like this one:
(specifications->manifest '("emacs" "python-numpy" "python" "python-flake8"))
$ guix environment --manifest=foo-manifest.scm
4. Create an environment for the package or list of packages that the code within file evaluates to.
(When we want to develop a special package ex: gdb it would be better to using this definition for environment)
;;package.scm (use-modules (guix) (gnu packages gdb) (gnu packages autotools) (gnu packages texinfo)) ;; Augment the package definition of GDB with the build tools ;; needed when developing GDB (and which are not needed when ;; simply installing it.) (package (inherit gdb) (native-inputs `(("autoconf" ,autoconf-2.64) ("automake" ,automake) ("texinfo" ,texinfo) ,@(package-native-inputs gdb))))
$ guix environment -l package.scm
5. Run command within an isolated container:
guix will create a environment with changed root. Which means you won’t be able to see any files other than those within your working directory and its sub-directories.
$ guix environment --ad-hoc python python-numpy --container
guix environment defines the GUIX_ENVIRONMENT variable in the shell it spawns; its value is the file name of the profile of this environment. This allows users to, say, define a specific prompt for development environments in their .bashrc
An active environment is indicated with
[env] in your command line.
You can browse the current, environment-specific profile using:
$ ls "$GUIX_ENVIRONMENT/bin"