Mirror of GNU Guix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
7.4 KiB

  1. -*- mode: org; coding: utf-8; -*-
  2. #+TITLE: Hacking GNU Guix and Its Incredible Distro
  3. Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
  4. Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
  5. Copyright © 2014 Pierre-Antoine Rault <par@rigelk.eu>
  6. Copying and distribution of this file, with or without modification,
  7. are permitted in any medium without royalty provided the copyright
  8. notice and this notice are preserved.
  9. * Building from Git
  10. When building Guix from a checkout, the following packages are required in
  11. addition to those mentioned in the installation instructions:
  12. - [[http://www.gnu.org/software/autoconf/][GNU Autoconf]]
  13. - [[http://www.gnu.org/software/automake/][GNU Automake]]
  14. - [[http://www.gnu.org/software/gettext/][GNU Gettext]]
  15. - [[http://www.graphviz.org/][Graphviz]]
  16. - [[http://www.gnu.org/software/help2man/][GNU Help2man]] (optional)
  17. Run ‘./bootstrap’ to download the Nix daemon source code and to generate the
  18. build system infrastructure using autoconf. It reports an error if an
  19. inappropriate version of the above packages is being used.
  20. If you get an error like this one:
  21. configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
  22. it probably means that Autoconf couldn’t find ‘pkg.m4’, which is provided by
  23. pkg-config. Make sure that ‘pkg.m4’ is available. For instance, if you
  24. installed Automake in ‘/usr/local’, it wouldn’t look for ‘.m4’ files in
  25. ‘/usr/share’. So you have to invoke the following command in that case
  26. $ export ACLOCAL_PATH=/usr/share/aclocal
  27. See “info '(automake) Macro Search Path'” for more information.
  28. Then, run ‘./configure’ as usual.
  29. Finally, you have to invoke ‘make check’ to run tests. If anything fails,
  30. take a look at “info '(guix) Installation'” or send a message to
  31. <guix-devel@gnu.org>.
  32. * Running Guix before it is installed
  33. See the same-named section in the manual.
  34. * The Perfect Setup
  35. The Perfect Setup to hack on Guix is basically the perfect setup used
  36. for Guile hacking (info "(guile) Using Guile in Emacs"). First, you
  37. need more than an editor, you need [[http://www.gnu.org/software/emacs][Emacs]], empowered by the wonderful
  38. [[http://nongnu.org/geiser/][Geiser]].
  39. Geiser allows for interactive and incremental development from within
  40. Emacs: code compilation and evaluation from within buffers, access to
  41. on-line documentation (docstrings), context-sensitive completion, M-. to
  42. jump to an object definition, a REPL to try out your code, and more.
  43. To actually edit the code, Emacs already has a neat Scheme mode. But in
  44. addition to that, you must not miss [[http://www.emacswiki.org/emacs/ParEdit][Paredit]]. It provides facilities to
  45. directly operate on the syntax tree, such as raising an s-expression or
  46. wrapping it, swallowing or rejecting the following s-expression, etc.
  47. * Submitting Patches
  48. Development is done using the Git distributed version control system. Thus,
  49. access to the repository is not strictly necessary. We welcome contributions
  50. in the form of patches as produced by ‘git format-patch’ sent to
  51. guix-devel@gnu.org. Please write commit logs in the [[http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs][GNU ChangeLog
  52. format]]; you can check the commit history for examples.
  53. Before submitting a patch that adds or modifies a package definition, please
  54. run ‘guix lint PACKAGE’, where PACKAGE is the name of the new or modified
  55. package, and fix any errors it reports. In addition, please make sure the
  56. package builds on your platform, using ‘guix build’. You may also want to
  57. check that dependent package (if applicable) are not affected by the change;
  58. ‘guix refresh --list-dependent PACKAGE’ will help you do that.
  59. When posting a patch to the mailing list, use "[PATCH] ..." as a subject. You
  60. may use your email client or the ‘git send-mail’ command.
  61. As you become a regular contributor, you may find it convenient to have write
  62. access to the repository (see below.)
  63. * Coding Style
  64. In general our code follows the [[info:standards][GNU Coding Standards]] (GCS). However, the GCS
  65. do not say much about Scheme, so here are some additional rules.
  66. ** Programming Paradigm
  67. Scheme code in Guix is written in a purely functional style. One exception is
  68. code that involves input/output, and procedures that implement low-level
  69. concepts, such as the ‘memoize’ procedure.
  70. ** Modules
  71. Guile modules that are meant to be used on the builder side must live in the
  72. (guix build …) name space. They must not refer to other Guix or GNU modules.
  73. However, it is OK for a “host-side” module to use a build-side module.
  74. Modules that deal with the broader GNU system should be in the (gnu …) name
  75. space rather than (guix …).
  76. ** Data Types and Pattern Matching
  77. The tendency in classical Lisp is to use lists to represent everything, and
  78. then to browse them “by hand” using ‘car’, ‘cdr’, ‘cadr’, and co. There are
  79. several problems with that style, notably the fact that it is hard to read,
  80. error-prone, and a hindrance to proper type error reports.
  81. Guix code should define appropriate data types (for instance, using
  82. ‘define-record-type*’) rather than abuse lists. In addition, it should use
  83. pattern matching, via Guile’s (ice-9 match) module, especially when matching
  84. lists.
  85. ** Formatting Code
  86. When writing Scheme code, we follow common wisdom among Scheme programmers.
  87. In general, we follow the [[http://mumble.net/~campbell/scheme/style.txt][Riastradh's Lisp Style Rules]]. This document happens
  88. to describe the conventions mostly used in Guile’s code too. It is very
  89. thoughtful and well written, so please do read it.
  90. Some special forms introduced in Guix, such as the ‘substitute*’ macro, have
  91. special indentation rules. These are defined in the .dir-locals.el file,
  92. which Emacs automatically uses. If you do not use Emacs, please make sure to
  93. let your editor know the rules.
  94. We require all top-level procedures to carry a docstring. This requirement
  95. can be relaxed for simple private procedures in the (guix build …) name space,
  96. though.
  97. Procedures should not have more than four positional parameters. Use keyword
  98. parameters for procedures that take more than four parameters.
  99. * Commit Access
  100. For frequent contributors, having write access to the repository is
  101. convenient. When you deem it necessary, feel free to ask for it on the
  102. mailing list. When you get commit access, please make sure to follow the
  103. policy below (discussions of the policy can take place on guix-devel@gnu.org.)
  104. Non-trivial patches should always be posted to guix-devel@gnu.org (trivial
  105. patches include fixing typos, etc.)
  106. For patches that just add a new package, and a simple one, it’s OK to commit,
  107. if you’re confident (which means you successfully built it in a chroot setup,
  108. and have done a reasonable copyright and license auditing.) Likewise for
  109. package upgrades, except upgrades that trigger a lot of rebuilds (for example,
  110. upgrading GnuTLS or GLib.) We have a mailing list for commit notifications
  111. (guix-commits@gnu.org), so people can notice. Before pushing your changes,
  112. make sure to run ‘git pull --rebase’.
  113. For anything else, please post to guix-devel@gnu.org and leave time for a
  114. review, without committing anything. If you didn’t receive any reply
  115. after two weeks, and if you’re confident, it’s OK to commit.
  116. That last part is subject to being adjusted, allowing individuals to commit
  117. directly on non-controversial changes on parts they’re familiar with.