Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tareifz/e2a9f2b8a550bf5ec5471bf91f194aa5 to your computer and use it in GitHub Desktop.

Select an option

Save tareifz/e2a9f2b8a550bf5ec5471bf91f194aa5 to your computer and use it in GitHub Desktop.
Guix Desktop-Environment Integration Guide

Guix Desktop-Environment Integration:

A guide to better DE-Integration for the GNU Guix Package Manager.

This has been tried and tested (successfully) in the following desktop environments:

  • GNOME (Debian 10.2 'Buster')
  • MATE, XFCE, KDE (Linux Mint 19 'Tara')
  • Cinnammon (Linux Mint 19.1 'Tessa')
  • Pantheon (Elementary OS 5.0 'Juno')

For all the amazing benifits of GNU Guix, one thing it still lacks is proper integration with the desktop environment of the host system (foreign distros). A GUI program installed using GUIX is not available from the GUI menus of the host system (unlike Flatpak). However, with the following steps, one can integrate Guix-installed-applications with the desktop environment in a pretty decent manner:

  1. Create a new file - guix.sh - in /etc/profile.d, containing the following lines (will require root privileges):
export GUIX_PROFILE="$HOME/.guix-profile"
export GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
export PATH="$HOME/.config/guix/current/bin${PATH:+:}$PATH"
eval `guix package --search-paths=prefix 2> /dev/null`

# set XDG_DATA_DIRS to include Guix installations
export XDG_DATA_DIRS="$GUIX_PROFILE/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"

(or simply copy the guix.sh file below - with further conditional checks - into your /etc/profile.d)

  1. Log out and log back in to see the GUI applications (openshot, aegisub, etc.) in your GUI menus.

Explanation:

  • /etc/profile, is an init file that is executed by all login-shells on a GNU/Linux system. In most modern distros, /etc/profile also reads files ending in .sh residing inside /etc/profile.d. Hence, the file /etc/profile.d/guix.sh; the commands contained therein are executed while logging in to a user-session.
  • The first two lines are just plain-old guix-recommended, basic stuffs. They set the GUIX_PROFILE, and GUIX_LOCPATH environment variables for the user currently logging in.
  • guix package --search-path returns all the environment variables that should be set in order for the programs installed using guix to run properly. Among the other things, it also exports the PATH variable. However, it does not include $HOME/.config/guix/current/bin (which contains the latest version of guix obtained via a guix pull). Hence the 3rd line. This causes the latest guix to run in the subsequent calls to guix in the session.
  • The last line returns a list of all environment variables required to be set for the guix-installed programs to function properly, first. The list is then eval-ed and thus the environment is established: all set and ready for guix-installed packages to function properly.
  • The line that exports the XDG_DATA_DIR is the most important one, that does the DE-integration.

Limitations:

  • While uninstalling an application (guix remove openshot) did remove the application from the menus; subsequent installation and --roll-backs had no effect on the menu whatsoever.

Further Steps:

  • Perhaps triggers could be set in motion after every guix transaction (if the user has opt-ed in for it during installation or via some other configuration) that would take care of the menu, etc. updates?
# _GUIX_PROFILE: `guix pull` profile
_GUIX_PROFILE="$HOME/.config/guix/current"
[ -L $_GUIX_PROFILE ] && export PATH="$_GUIX_PROFILE/bin${PATH:+:}$PATH"
# GUIX_PROFILE: User's default profile
GUIX_PROFILE="$HOME/.guix-profile"
[ -L $GUIX_PROFILE ] || return
GUIX_LOCPATH="$GUIX_PROFILE/lib/locale"
export GUIX_PROFILE GUIX_LOCPATH
eval `guix package --search-paths=prefix 2> /dev/null`
# set XDG_DATA_DIRS to include Guix installations
export XDG_DATA_DIRS="$GUIX_PROFILE/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment