I was considering the idea of moving to GNU GuixSD as my full time operating system for a long time. I tried GuixSD for some time but I gave up because I was frustrated with the config system. (I was un-doubtedly stupid back then)

That was then, This is now

I have finally transitioned to using Guix full time. In fact this essay is from my GUIX system itself. In this essay I will outline couple of things that I found to be a bit difficult for an absolute beginner and a lot of things that I find totally awesome and exciting about GNU Guix.

What is GNU Guix ?

GNU Guix is a package manager. But, make no mistake, it is not a traditional package manager. It is a package manager on steroids. I will explain what I mean by on steroids.

Some of the most important and most powerful features of the Guix package manager IMHO are ...

  • The gnu store (/gnu/store/) is heart of the Guix package manager. This is the directory where all the packages and profile are stored in Guix. Unlike traditional package managers where the packages are stored in either /bin or /usr/bin/ or anything, in Guix all the packages that are installed are installed under the /gnu/store/ directory and the entire system is a web of symbolic links.

  • Per-user profiles In guix packages are not installed globally. Traditionally in GNU/Linux when some package is installed it is available for use by everyone in the system with no exceptions. This makes sense because traditionally the packages are installed in the file-system itself, so there is no way of separating which user has which package.

    Things are quite different on the Guix Land (I apologize to the community for using Guix Land(I couldn't help myself)). In Guix, packages are managed using per-user profiles. This means that every user on the system has their own profile which makes sure that they have the packages that they want to use and nothing else. This also means that in guix installing packages does not need superuser privileges, since everyone can have authority over which packages they want to use. How Guix accomplishes this by using a series of symbolic links the actual binaries which reside in the Gnu Store. So if two users have different packages then it means that they just have different symbolic links pointing to the actual binaries in the gnu store. Same goes for different users having different versions of the same package.

    The per-user-profiles are stored under the directory ~/.guix-profile

  • Purely Functional approach to package management. A pure function is a function that produces the same output every-time given the same set of arguments. Guix embraces this idea. Every package build in guix is treated as a function in which the inputs are the compiler, libraries, build scripts, etc and the output is the built package. This along with isolated build environment (I don't know much about it as I haven't had time to explore it yet) ensures that built packages are bit-identical even when they are built on different machines.

  • Transactional Upgrades and Rollbacks Guix package upgrades are transactional in nature, this means that either the entire upgrade takes place or nothing gets upgraded so in case of a power-failure during upgrade, your system will not be left in a corrupt state.

    Also package upgrades, installs etc can be rolled back (yes! just like in git!!)

  • Guile Guix is completely written in GNU Guile which is a dialect of LISP.

There are lots of more fun stuff that I could write about but

  1. I haven't explored the system enough to talk about it in detail and I do not want to speculate at this point
  2. Things will get really long.. really fast

What is GuixSD ?

GuixSD is the Linux Based Operating system built around the GUIX package manager.

GuixSD or the Guix System Distribution is an advanced distribution of the GNU operating system developed by the GNU Project—which respects the freedom of computer users.

That is what it says on their main website. I don't know much but the core idea of GuixSD is that there should be a configuration file in which users will be able to specify the final state the installed system and the installer should be intelligent enough to figure out how to do that.

This is in addition to the philosophies of the GNU community and Free and Open Source Software. GuixSD runs the Libre Linux Kernel.

Installing Guix

You can follow the instructions on the main Guix page. They are quite good. Over here I will highlight certain key ideas.

The installation was quite simple actually involving 3 major steps

  1. Setting up Networking : Once you boot into the live USB you are required to set up networking because the installation process will download the required files over the internet.

  2. Disk Partitioning : This part is actually quite tricky to get right especially if you are using a UEFI system. During this step one is required to mount the target file system under /mnt and then mount the other related file-systems relative to /mnt. This means that if you want to have a custom boot dir then you would have to mount it at /mnt/boot.

    On the contrary if you are using a UEFI system then you are required to have an esp (efi system partition) and you have to mount it at /boot/efi. This mount point should not be relative. i.e. you should not mount the esp at /mnt/boot/efi but instead at /boot/efi. This was weird for me and this caused a lot of trouble for me.

  3. Final installation In this step we configure our system and install it. The guix System Configuration is the most important thing to get right while installing Guix. This file is responsible for setting up the entire system including users, groups, and services (guix uses Gnu Shepherd as the service manager)

    This config file is nothing but a Scheme file which is read by the Guix package manager when you are installing the system.

    The default configurations that are provided are quite good for normal everyday use. If however you need to use a more complex configuration you can refer to my configuration (my config is a dual-booted uefi setup with Arch Linux)

NOTE: In Guix if you are dual-booting please make sure that the bootloader is installed properly since if it is not, you CAN NOT use the traditional fixes that we are used to (like bootrepair, or grub reinstall etc) because of how the GuixSD system is structured internally.

After Installation

So, installation is only half the trouble. After installation comes the important part of actually using the system. In this section I have put together a list of things that should be essential to a smooth start.

Per-User profile

In the previous section we talked about how you guix maintain packages on a per-user basis. One easy method to maintain per user profiles is to create a manifest file. A manifest file is a scheme file that contains all the packages for a specific user. This way you can specify only the packages that you want to be available globally in the system configuration file and other packages can be installed on a per-user basis using the manifest file.

#bash
$ guix package -m profile.scm

This will tell guix package to install the packages from that file.

Manifest file syntax:

1
2
3
4
5
6
(use-package-modules <module1> <module2>)

(package->manifest
    (list package1
          package2
          package3))

Package modules are the basically the scheme files within which each of the packages are defined. You can find out which package module a given package belongs to by running the guix package -s <package-name> command and looking at the location field.

Here is my Profile.

For example: this is the output of the command guix package -s emacs-neotree

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
$ guix package -s emacs-neotree
name: emacs-neotree
version: 0.5.2
outputs: out
systems: x86_64-linux i686-linux armhf-linux aarch64-linux mips64el-linux
dependencies: 
location: gnu/packages/emacs.scm:4474:2
homepage: https://github.com/jaypei/emacs-neotree
license: GPL 3+
synopsis: Folder tree view for Emacs  
description: This Emacs package provides a folder tree view.
relevance: 4

The file under gnu/packages/ is the module name.

Updating and maintaining

Updating the GuixSD done through the command guix pull.

guix pull will result in Guix pulling all the new changes from the repo and building them locally. This generally takes a long time.

Once this is done then we can run guix system reconfigure <config file>

Running guix pull as a normal user will NOT habe any effect on running guix system reconfigure as root

guix pull can be run as a non root user. However guix system reconfigure must be run as root. Hence when you want to upgrade the system, run guix pull and guix system reconfigure as root. This will ensure that the whole system is upgraded at once.

This command will again take the config file and reset Guix to the state described in the config file.

After this we can again use guix package -m <profile file> to get the updated packages into the user profile.

Conclusion

That should be it for now. I know I am not posting regularly. I was very busy recently. However things are clearing up and I think I will write another essay about Lambda Calculus and Internals of Guix very soon (not so soon!!)!!

:-)