Improving the Guix Home Experience

Updates

Improving the Guix Home Experience

Today I’d like to discuss some ideas I have for how to improve the Guix Home experience for both new and experienced users. If you’ve used Guix Home, I also want to hear your experience and ideas!

Simpler “onboarding” for existing configs

  • Linking existing configuration files
  • Templating existing configuration files
  • Converting to well-designed “home services” for a better experience

Assumption:

  • Some users won’t necessarily want to use a full home service to configure some subset of their programs
  • They may have an existing configuration file that they want to parameterize

Concerns:

  • Should the configuration files be usable on non-Guix systems too?

Check out home-stow-migration-service:

https://issues.guix.gnu.org/issue/60521

Experiment: Simplified home service for existing config files

test-config.scm:

(use-modules
 (gnu home)
 (gnu services)
 (gnu packages base)
 (daviwil home-services template-file))

(define (template-files base-path file-list value-alist)
  (service home-template-file-service-type
           (home-template-file-configuration
            (base-path base-path)
            (files file-list)
            (values value-alist))))

(home-environment
 (packages (list grep))
 (services (list (template-files "/home/daviwil/.dotfiles/.files"
                                 '(".config/dunst/dunstrc"
                                   ".config/qutebrowser/config.py")
                                 '((dunst/font . "Iosevka Aile 18")
                                   (qutebrowser/zoom . "150"))))))

~/.dotfiles/daviwil/utils.scm:

(define-module (daviwil utils)
  #:use-module (gnu packages)
  #:use-module (gnu services)
  #:use-module (gnu home services)
  #:use-module (gnu home services shepherd)
  #:use-module (gnu packages freedesktop)
  #:use-module (gnu services configuration)
  #:use-module (guix gexp)
  #:use-module (ice-9 regex)
  #:use-module (ice-9 pretty-print)
  #:use-module (ice-9 textual-ports)

  #:export (gather-manifest-packages
            apply-template-file))

(define (apply-template template-string value-alist)
  (regexp-substitute/global #f
                            "\\$\\{([A-Za-z/\\-]+)\\}"
                            template-string
                            'pre
                            (lambda (m)
                              (let ((entry (assq (string->symbol (match:substring m 1))
                                                 value-alist)))
                                (if entry
                                    (cdr entry)
                                    "VALUE NOT FOUND")))
                            'post))

(define (apply-template-file file-path value-alist)
  (call-with-input-file file-path
    (lambda (port)
      (apply-template (get-string-all port)
                      value-alist))))

Creating shareable configuration layers

  • This requires well-designed home services, either in the main Guix channel or a community channel

Providing a unified configuration model for both home and system services

Andrew Tropin’s RDE has a concept called “features” to accomplish this:

https://git.sr.ht/~abcdw/rde/tree/master/item/src/rde/features

Does Guix need something similar? Maybe. However, any Guix channel can provide this kind of feature.

Implementing a Guix analogue to Nix Flakes

Set up your entire system with a single command using a URL directly to your dotfiles repo!

An example, benoitj’s Nix Flake configuration:

https://git.sr.ht/~benoit/dotfiles/tree/neo-guix/item/_old/flake.nix

Subscribe to the System Crafters Newsletter!
Stay up to date with the latest System Crafters news and updates! Read the Newsletter page for more information.
Name (optional)
Email Address