Skip to content

ryan4yin/guix-config

Repository files navigation

guix-config

My dotfiles for GNU Guix

Tutorials

Tutorials for Guile Scheme Language:
  • A Scheme Primer: for a basic understanding of Scheme
  • Guile 3.0 Manual: The most important part of this manual is API Reference, when in doubt, check the API Reference.

How to practice Guile Scheme Language(on NixOS):

nix shell nixpkgs#racket-minimal --command "racket"

Tutorials for Guix itself:

How to use Guix on NixOS: https://github.com/ryan4yin/nix-config/blob/main/modules/nixos/desktop/guix.nix

Key community projects

Notes

  1. 'a: a syntax sugar of (quote a), a symbol a is not evaluated.
  2. #t and #f: true and false
  3. '() or null: empty list
  4. (list arg1 arg2 …) or '(arg1 arg2 …): a linked list,
  5. cons* arg1 arg2 …: similar to (list arg1 arg2 …), but its last cons cell is a dotted list, which does not have null for its cdr.
    1. This function is called list* in some other Schemes and in Common LISP.
scheme@(guile-user)> (cons* 1 2 3 4 5)
$4 = (1 2 3 4 . 5)
scheme@(guile-user)> (list 1 2 3 4 5)
$5 = (1 2 3 4 5)
scheme@(guile-user)> '(1 2 3 4 5)
$6 = (1 2 3 4 5)

scheme@(guile-user)> '(1 2)
$7 = (1 2)
scheme@(guile-user)> (cons 1 (cons 2 '()))
$8 = (1 2)
;; a list which does not have `null` for its cdr is called a dotted list.
scheme@(guile-user)> (cons 1 2)
$9 = (1 . 2)

Guix Mirror in China

https://mirror.sjtu.edu.cn/docs/guix

FAQ

1. When should I use cons* instead of list / cons?

  1. cons creates a pair with two elements: its car and cdr
  2. (list a b ...) creates a linked list with multiple elements, and a null is appended to the end
  3. (cons* a b ... g h) creates a linked list with multiple elements, but the last element is not null

cons* is useful when you want to insert multiple elements at the front of a list. For example: (cons* 1 2 3 '(4 5 6)) will insert 1 2 3 at the front of (4 5 6), resulting in (1 2 3 4 5 6)

nonguix’s installation description uses cons* ... %default-channels to insert its channel before Guix’s default channels.

If we use list ... %default-channels, the result has an extra null at the end, which is not what we want.

scheme@(guile-user) [1]> (list 1 2 3 (list 4 5 6))
$13 = (1 2 3 (4 5 6))
scheme@(guile-user) [1]> '(1 2 3 (4 5 6))
$14 = (1 2 3 (4 5 6))
scheme@(guile-user) [1]> (cons* 1 2 3 (list 4 5 6))
$15 = (1 2 3 4 5 6)

2. How to install packages via config.scm?

  1. guix search <package-name> to find the package’s location
    • For example, guix search kitty will show the package’s location is gnu/packages/terminals.scm
  2. Add (use-package-modules terminals) to the top of config.scm
  3. Add kitty to the packages list in config.scm

3. Documentation?

  1. Documentation for use-modules (provided by Guile): https://www.gnu.org/software/guile/manual/html_node/Using-Modules.html
  2. Documentation for use-service-modules, use-package-modules & use-system-modules: No official docs, but you can read their definition in source code: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu.scm#n143
  3. Source code:

4. Why is guix pull so sluggish? (Stuck in computing guix derivation)

Learn more: https://guix.gnu.org/manual/en/html_node/Channels-with-Substitutes.html

When executing guix pull, Guix initially compiles the definitions of every available package. This is a resource-intensive process for which substitutes may be accessible.

For nonguix, you can enhance the speed of guix pull by incorporating its official substitutes. Refer to the ‘substitutes’ section in https://gitlab.com/nonguix/nonguix for details.

In NixOS, nix undergoes no compilation phase and functions as a fully interpreted language. Consequently, nix flake update outpaces guix pull in terms of speed.

The substitutes you integrate into config.scm will become effective only after the initial completion of guix system reconfigure! For expediting the inaugural reconfiguration, consult nonguix’s official README.

5. Why is guix system reconfigure so slow? (Stuck in build phase)

Similar to the previous point, you can speed up guix system reconfigure by introducing nonguix’s substitutes.

6. Modularize Your Guix Configuration

Learn more: https://www.gnu.org/software/guile/manual/html_node/Modules.html

7. ice-9/eval.scm:223:20: In procedure proc:

Try guix pull and then guix package -u to update the packages.

References

Other dotfiles that inspired me:

About

My dotfiles for GNU Guix

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors