First steps toward Guix Home
Tags: gnu, guix, devops, tutorial
Published: 2022-11-12 14:20:55

![Guix logo](https://guix.gnu.org/static/base/img/Guix.png)

In this article, I will show you, step by step, how one can simply install and configure software they use with [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html). For the demonstration, I will focus on a single package and a single service.
<!--more-->
_Disclaimer: I'm not an experienced [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) user. So don't take my words for granted. Read manuals, ask questions._

So far, to install a software, say Emacs, for my user, I could simply :
`$ guix install emacs`
Or, I could write a manifest and use it to populate my default user profile (or a custom one) :
`$ guix package --manifest=$HOME/manifest.scm`
Where `manifest.scm` contains the following :
```scheme
(specifications->manifest (list "emacs"))
```
Then, the configuration for the new software had to be edited separately.
Here is a dummy `~/.config/emacs/init.el` :
```lisp 
(setq initial-scratch-message nil)
```
Now, let's use [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) to start managing the whole !

## The blank home

[Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) ask you for two things : a list of packages and a list of home services.
So a blank [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) configuration file (which installs and configures nothing) would look like this :
```scheme
(use-modules (gnu home))

(home-environment
 (packages (list))
 (services (list)))
```
You can save this expressions in a file named `home-configuration.scm`. So you now can invoke [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) to generate a home environment from this blank configuration :
```
$ guix home container home-configuration.scm
```
No worries, this won't affect your current environment. 
Take a few seconds to see how empty this shell is and move on !

Oops, you need to leave the empty shell.
```
$ exit
```
## Installing the software

To tell [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) to add a software package to the generated home environment, you have to edit `home-configuration.scm` and add its name to the package list :
```scheme
(use-modules
 (gnu home)
 (gnu packages emacs))

(home-environment
 (packages
  (list emacs)))
```
You can now try it out.
```
$ guix home container home-configuration.scm
```
In this shell, you can run Emacs, proof that Emacs has been added to the generated home environment.
```
$ emacs -nw
```
Then you can quit the shell.

## Install the software's configuration

From [Guix Home](https://guix.gnu.org/manual/devel/en/html_node/Home-Configuration.html) perspective, things are packages or services. It's time to look for services. Especially one that can handle the process to configure Emacs. Simply put, a service capable of installing the `init.el` file on the right place : `home-xdg-configuration-files-service-type`.

Edit `home-configuration.scm` to be like :
```scheme
(use-modules
 (gnu home)
 (gnu home services)
 (gnu packages emacs)
 (gnu services)
 (guix gexp))

(home-environment
 (packages
  (list emacs))
 (services
  (list (service home-xdg-configuration-files-service-type
		 `(("emacs/init.el" ,(local-file "init.el")))))))
```
Then, create a `init.el` file, with your Emacs configuration, next to the `home-configuration.scm` :
```lisp
(setq initial-scratch-message nil)
```
Try it with :
```
$ guix home container home-configuration.scm
```
Here you can see there is the `init.el` file at `~/.config/emacs/init.el` !
So the Emacs in this environment will use this configuration file at startup… Ok, maybe not in the container, but trust me, it will when running (careful, it will have an effect to your current environment this time) :
```
$ guix home reconfigure home-configuration.scm
```
**Warning :** because there is no shell configuration in the `home-configuration.scm` (yet), you will need to [manually configure](https://guix.gnu.org/manual/devel/en/html_node/Configuring-the-Shell.html) your shell to make it benefits from the generated home environment.

_Thank you very much for reading this article!_

_Don't hesitate to give me your opinion, suggest an idea for improvement, report an error, or ask a question ! I would be so glad to discuss about the topic covered here with you ! You can reach me [here](https://linktr.ee/jeko)._

_Don't miss out on the next ones ! Either via [RSS](https://rednosehacker.com/feed/) or via e-mail !_

_And more importantly, share this blog and tell your friends why they should read this post!_