Commit | Line | Data |
---|---|---|
8c01b9d0 ML |
1 | @node Contributing |
2 | @chapter Contributing | |
3 | ||
4 | This project is a cooperative effort, and we need your help to make it | |
5 | grow! Please get in touch with us on @email{guix-devel@@gnu.org} and | |
6 | @code{#guix} on the Freenode IRC network. We welcome ideas, bug | |
7 | reports, patches, and anything that may be helpful to the project. We | |
8 | particularly welcome help on packaging (@pxref{Packaging Guidelines}). | |
9 | ||
e15fcdd1 LC |
10 | @cindex code of conduct, of contributors |
11 | @cindex contributor covenant | |
dcb7119a AS |
12 | We want to provide a warm, friendly, and harassment-free environment, so |
13 | that anyone can contribute to the best of their abilities. To this end | |
14 | our project uses a ``Contributor Covenant'', which was adapted from | |
478af028 | 15 | @url{https://contributor-covenant.org/}. You can find a local version in |
dcb7119a | 16 | the @file{CODE-OF-CONDUCT} file in the source tree. |
e15fcdd1 | 17 | |
dfcdd9c2 LC |
18 | Contributors are not required to use their legal name in patches and |
19 | on-line communication; they can use any name or pseudonym of their | |
20 | choice. | |
21 | ||
8c01b9d0 ML |
22 | @menu |
23 | * Building from Git:: The latest and greatest. | |
24 | * Running Guix Before It Is Installed:: Hacker tricks. | |
25 | * The Perfect Setup:: The right tools. | |
afe7408e | 26 | * Packaging Guidelines:: Growing the distribution. |
8c01b9d0 ML |
27 | * Coding Style:: Hygiene of the contributor. |
28 | * Submitting Patches:: Share your work. | |
a7bde77d | 29 | * Tracking Bugs and Patches:: Using Debbugs. |
2d315cd4 | 30 | * Commit Access:: Pushing to the official repository. |
8c01b9d0 ML |
31 | @end menu |
32 | ||
33 | @node Building from Git | |
34 | @section Building from Git | |
35 | ||
36 | If you want to hack Guix itself, it is recommended to use the latest | |
dbfcadfc LC |
37 | version from the Git repository: |
38 | ||
39 | @example | |
40 | git clone https://git.savannah.gnu.org/git/guix.git | |
41 | @end example | |
42 | ||
b3011dbb LC |
43 | @cindex authentication, of a Guix checkout |
44 | How do you ensure that you obtained a genuine copy of the repository? | |
3e9c6ee1 | 45 | To do that, run @command{guix git authenticate}, passing it the commit |
63c799c1 LC |
46 | and OpenPGP fingerprint of the @dfn{channel introduction} |
47 | (@pxref{Invoking guix git authenticate}): | |
b3011dbb | 48 | |
63c799c1 LC |
49 | @c The commit and fingerprint below must match those of the channel |
50 | @c introduction in '%default-channels'. | |
b3011dbb | 51 | @example |
3e9c6ee1 | 52 | git fetch origin keyring:keyring |
63c799c1 LC |
53 | guix git authenticate 9edb3f66fd807b096b48283debdcddccfea34bad \ |
54 | "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA" | |
b3011dbb LC |
55 | @end example |
56 | ||
57 | @noindent | |
63c799c1 LC |
58 | This command completes with exit code zero on success; it prints an |
59 | error message and exits with a non-zero code otherwise. | |
60 | ||
61 | As you can see, there is a chicken-and-egg problem: you first need to | |
62 | have Guix installed. Typically you would install Guix System | |
63 | (@pxref{System Installation}) or Guix on top of another distro | |
64 | (@pxref{Binary Installation}); in either case, you would verify the | |
65 | OpenPGP signature on the installation medium. This ``bootstraps'' the | |
66 | trust chain. | |
b3011dbb | 67 | |
5fb95cc5 LC |
68 | The easiest way to set up a development environment for Guix is, of |
69 | course, by using Guix! The following command starts a new shell where | |
70 | all the dependencies and appropriate environment variables are set up to | |
71 | hack on Guix: | |
8c01b9d0 | 72 | |
5fb95cc5 | 73 | @example |
43ec98ef | 74 | guix environment guix --pure |
5fb95cc5 LC |
75 | @end example |
76 | ||
77 | @xref{Invoking guix environment}, for more information on that command. | |
0636742b FP |
78 | |
79 | If you are unable to use Guix when building Guix from a checkout, the | |
80 | following are the required packages in addition to those mentioned in the | |
81 | installation instructions (@pxref{Requirements}). | |
82 | ||
83 | @itemize | |
21656ffa VS |
84 | @item @url{https://gnu.org/software/autoconf/, GNU Autoconf}; |
85 | @item @url{https://gnu.org/software/automake/, GNU Automake}; | |
86 | @item @url{https://gnu.org/software/gettext/, GNU Gettext}; | |
87 | @item @url{https://gnu.org/software/texinfo/, GNU Texinfo}; | |
88 | @item @url{https://www.graphviz.org/, Graphviz}; | |
89 | @item @url{https://www.gnu.org/software/help2man/, GNU Help2man (optional)}. | |
0636742b FP |
90 | @end itemize |
91 | ||
92 | On Guix, extra dependencies can be added by instead running @command{guix | |
93 | environment} with @option{--ad-hoc}: | |
5fb95cc5 LC |
94 | |
95 | @example | |
43ec98ef | 96 | guix environment guix --pure --ad-hoc help2man git strace |
5fb95cc5 LC |
97 | @end example |
98 | ||
99 | Run @command{./bootstrap} to generate the build system infrastructure | |
100 | using Autoconf and Automake. If you get an error like this one: | |
8c01b9d0 ML |
101 | |
102 | @example | |
103 | configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES | |
104 | @end example | |
105 | ||
5fb95cc5 | 106 | @noindent |
8c01b9d0 | 107 | it probably means that Autoconf couldn’t find @file{pkg.m4}, which is |
5fb95cc5 LC |
108 | provided by pkg-config. Make sure that @file{pkg.m4} is available. The |
109 | same holds for the @file{guile.m4} set of macros provided by Guile. For | |
110 | instance, if you installed Automake in @file{/usr/local}, it wouldn’t | |
111 | look for @file{.m4} files in @file{/usr/share}. In that case, you have | |
112 | to invoke the following command: | |
8c01b9d0 ML |
113 | |
114 | @example | |
115 | export ACLOCAL_PATH=/usr/share/aclocal | |
116 | @end example | |
117 | ||
aabe6d38 | 118 | @xref{Macro Search Path,,, automake, The GNU Automake Manual}, for |
8c01b9d0 ML |
119 | more information. |
120 | ||
3a25c631 LC |
121 | Then, run @command{./configure} as usual. Make sure to pass |
122 | @code{--localstatedir=@var{directory}} where @var{directory} is the | |
123 | @code{localstatedir} value used by your current installation (@pxref{The | |
0758a70c | 124 | Store}, for information about this). We recommend to use the value |
125 | @code{/var}. | |
8c01b9d0 | 126 | |
3a25c631 LC |
127 | Finally, you have to invoke @code{make check} to run tests |
128 | (@pxref{Running the Test Suite}). If anything | |
8c01b9d0 ML |
129 | fails, take a look at installation instructions (@pxref{Installation}) |
130 | or send a message to the @email{guix-devel@@gnu.org, mailing list}. | |
131 | ||
33391ee5 LC |
132 | From there on, you can authenticate all the commits included in your |
133 | checkout by running: | |
134 | ||
135 | @example | |
136 | make authenticate | |
137 | @end example | |
138 | ||
139 | The first run takes a couple of minutes, but subsequent runs are faster. | |
140 | ||
141 | @quotation Note | |
142 | You are advised to run @command{make authenticate} after every | |
143 | @command{git pull} invocation. This ensures you keep receiving valid | |
144 | changes to the repository. | |
145 | @end quotation | |
146 | ||
8c01b9d0 ML |
147 | |
148 | @node Running Guix Before It Is Installed | |
149 | @section Running Guix Before It Is Installed | |
150 | ||
151 | In order to keep a sane working environment, you will find it useful to | |
152 | test the changes made in your local source tree checkout without | |
153 | actually installing them. So that you can distinguish between your | |
154 | ``end-user'' hat and your ``motley'' costume. | |
155 | ||
156 | To that end, all the command-line tools can be used even if you have not | |
0207768f LC |
157 | run @code{make install}. To do that, you first need to have an environment |
158 | with all the dependencies available (@pxref{Building from Git}), and then | |
159 | simply prefix each command with | |
8c01b9d0 | 160 | @command{./pre-inst-env} (the @file{pre-inst-env} script lives in the |
0636742b FP |
161 | top build tree of Guix; it is generated by @command{./configure}). |
162 | An example@footnote{The @option{-E} flag to | |
67441b9a LC |
163 | @command{sudo} guarantees that @code{GUILE_LOAD_PATH} is correctly set |
164 | such that @command{guix-daemon} and the tools it uses can find the Guile | |
165 | modules they need.}: | |
8c01b9d0 ML |
166 | |
167 | @example | |
67441b9a | 168 | $ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild |
8c01b9d0 ML |
169 | $ ./pre-inst-env guix build hello |
170 | @end example | |
171 | ||
172 | @noindent | |
0636742b | 173 | Similarly, an example for a Guile session using the Guix modules: |
8c01b9d0 ML |
174 | |
175 | @example | |
176 | $ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))' | |
96856613 LC |
177 | |
178 | ;;; ("x86_64-linux") | |
179 | @end example | |
180 | ||
181 | @noindent | |
182 | @cindex REPL | |
183 | @cindex read-eval-print loop | |
184 | @dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile | |
185 | Reference Manual}): | |
186 | ||
187 | @example | |
188 | $ ./pre-inst-env guile | |
189 | scheme@@(guile-user)> ,use(guix) | |
190 | scheme@@(guile-user)> ,use(gnu) | |
191 | scheme@@(guile-user)> (define snakes | |
192 | (fold-packages | |
193 | (lambda (package lst) | |
194 | (if (string-prefix? "python" | |
195 | (package-name package)) | |
196 | (cons package lst) | |
197 | lst)) | |
198 | '())) | |
199 | scheme@@(guile-user)> (length snakes) | |
200 | $1 = 361 | |
8c01b9d0 ML |
201 | @end example |
202 | ||
203 | The @command{pre-inst-env} script sets up all the environment variables | |
204 | necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}. | |
205 | ||
ef54b61d | 206 | Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the |
75e24d7b | 207 | local source tree; it simply updates the @file{~/.config/guix/current} |
ef54b61d | 208 | symlink (@pxref{Invoking guix pull}). Run @command{git pull} instead if |
75e24d7b | 209 | you want to upgrade your local source tree. |
ef54b61d | 210 | |
8c01b9d0 ML |
211 | |
212 | @node The Perfect Setup | |
213 | @section The Perfect Setup | |
214 | ||
215 | The Perfect Setup to hack on Guix is basically the perfect setup used | |
216 | for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference | |
217 | Manual}). First, you need more than an editor, you need | |
21656ffa VS |
218 | @url{https://www.gnu.org/software/emacs, Emacs}, empowered by the |
219 | wonderful @url{https://nongnu.org/geiser/, Geiser}. To set that up, run: | |
f73ab814 LC |
220 | |
221 | @example | |
222 | guix package -i emacs guile emacs-geiser | |
223 | @end example | |
8c01b9d0 ML |
224 | |
225 | Geiser allows for interactive and incremental development from within | |
226 | Emacs: code compilation and evaluation from within buffers, access to | |
227 | on-line documentation (docstrings), context-sensitive completion, | |
228 | @kbd{M-.} to jump to an object definition, a REPL to try out your code, | |
229 | and more (@pxref{Introduction,,, geiser, Geiser User Manual}). For | |
230 | convenient Guix development, make sure to augment Guile’s load path so | |
231 | that it finds source files from your checkout: | |
232 | ||
233 | @lisp | |
234 | ;; @r{Assuming the Guix checkout is in ~/src/guix.} | |
bb38ece4 AK |
235 | (with-eval-after-load 'geiser-guile |
236 | (add-to-list 'geiser-guile-load-path "~/src/guix")) | |
8c01b9d0 ML |
237 | @end lisp |
238 | ||
239 | To actually edit the code, Emacs already has a neat Scheme mode. But in | |
240 | addition to that, you must not miss | |
c2c73f58 | 241 | @url{https://www.emacswiki.org/emacs/ParEdit, Paredit}. It provides |
8c01b9d0 ML |
242 | facilities to directly operate on the syntax tree, such as raising an |
243 | s-expression or wrapping it, swallowing or rejecting the following | |
244 | s-expression, etc. | |
245 | ||
42cdcdff RW |
246 | @cindex code snippets |
247 | @cindex templates | |
248 | @cindex reducing boilerplate | |
249 | We also provide templates for common git commit messages and package | |
250 | definitions in the @file{etc/snippets} directory. These templates can | |
21656ffa | 251 | be used with @url{https://joaotavora.github.io/yasnippet/, YASnippet} to |
42cdcdff RW |
252 | expand short trigger strings to interactive text snippets. You may want |
253 | to add the snippets directory to the @var{yas-snippet-dirs} variable in | |
254 | Emacs. | |
255 | ||
256 | @lisp | |
257 | ;; @r{Assuming the Guix checkout is in ~/src/guix.} | |
258 | (with-eval-after-load 'yasnippet | |
259 | (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets")) | |
260 | @end lisp | |
261 | ||
262 | The commit message snippets depend on @url{https://magit.vc/, Magit} to | |
263 | display staged files. When editing a commit message type @code{add} | |
264 | followed by @kbd{TAB} to insert a commit message template for adding a | |
265 | package; type @code{update} followed by @kbd{TAB} to insert a template | |
9286c295 AI |
266 | for updating a package; type @code{https} followed by @kbd{TAB} to |
267 | insert a template for changing the home page URI of a package to HTTPS. | |
42cdcdff RW |
268 | |
269 | The main snippet for @code{scheme-mode} is triggered by typing | |
270 | @code{package...} followed by @kbd{TAB}. This snippet also inserts the | |
271 | trigger string @code{origin...}, which can be expanded further. The | |
272 | @code{origin} snippet in turn may insert other trigger strings ending on | |
273 | @code{...}, which also can be expanded further. | |
274 | ||
9a397114 OP |
275 | @cindex insert or update copyright |
276 | @cindex @code{M-x guix-copyright} | |
277 | @cindex @code{M-x copyright-update} | |
4f4fb215 | 278 | We additionally provide insertion and automatic update of a copyright in |
9a397114 OP |
279 | @file{etc/copyright.el}. You may want to set your full name, mail, and |
280 | load a file. | |
281 | ||
282 | @lisp | |
283 | (setq user-full-name "Alice Doe") | |
284 | (setq user-mail-address "alice@@mail.org") | |
285 | ;; @r{Assuming the Guix checkout is in ~/src/guix.} | |
286 | (load-file "~/src/guix/etc/copyright.el") | |
287 | @end lisp | |
288 | ||
289 | To insert a copyright at the current line invoke @code{M-x guix-copyright}. | |
290 | ||
291 | To update a copyright you need to specify a @code{copyright-names-regexp}. | |
292 | ||
293 | @lisp | |
294 | (setq copyright-names-regexp | |
295 | (format "%s <%s>" user-full-name user-mail-address)) | |
296 | @end lisp | |
297 | ||
298 | You can check if your copyright is up to date by evaluating @code{M-x | |
299 | copyright-update}. If you want to do it automatically after each buffer | |
300 | save then add @code{(add-hook 'after-save-hook 'copyright-update)} in | |
301 | Emacs. | |
8c01b9d0 | 302 | |
afe7408e LC |
303 | @node Packaging Guidelines |
304 | @section Packaging Guidelines | |
305 | ||
306 | @cindex packages, creating | |
307 | The GNU distribution is nascent and may well lack some of your favorite | |
308 | packages. This section describes how you can help make the distribution | |
309 | grow. | |
310 | ||
311 | Free software packages are usually distributed in the form of | |
312 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
313 | all the source files. Adding a package to the distribution means | |
314 | essentially two things: adding a @dfn{recipe} that describes how to | |
315 | build the package, including a list of other packages required to build | |
316 | it, and adding @dfn{package metadata} along with that recipe, such as a | |
317 | description and licensing information. | |
318 | ||
319 | In Guix all this information is embodied in @dfn{package definitions}. | |
320 | Package definitions provide a high-level view of the package. They are | |
321 | written using the syntax of the Scheme programming language; in fact, | |
322 | for each package we define a variable bound to the package definition, | |
323 | and export that variable from a module (@pxref{Package Modules}). | |
324 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
325 | creating packages. For more information on package definitions, | |
326 | @pxref{Defining Packages}. | |
327 | ||
328 | Once a package definition is in place, stored in a file in the Guix | |
329 | source tree, it can be tested using the @command{guix build} command | |
330 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
331 | called @code{gnew}, you may run this command from the Guix build tree | |
332 | (@pxref{Running Guix Before It Is Installed}): | |
333 | ||
334 | @example | |
335 | ./pre-inst-env guix build gnew --keep-failed | |
336 | @end example | |
337 | ||
338 | Using @code{--keep-failed} makes it easier to debug build failures since | |
339 | it provides access to the failed build tree. Another useful | |
340 | command-line option when debugging is @code{--log-file}, to access the | |
341 | build log. | |
342 | ||
343 | If the package is unknown to the @command{guix} command, it may be that | |
344 | the source file contains a syntax error, or lacks a @code{define-public} | |
345 | clause to export the package variable. To figure it out, you may load | |
346 | the module from Guile to get more information about the actual error: | |
347 | ||
348 | @example | |
349 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
350 | @end example | |
351 | ||
352 | Once your package builds correctly, please send us a patch | |
353 | (@pxref{Submitting Patches}). Well, if you need help, we will be happy to | |
354 | help you too. Once the patch is committed in the Guix repository, the | |
355 | new package automatically gets built on the supported platforms by | |
44b5f28a | 356 | @url{@value{SUBSTITUTE-SERVER}, our continuous integration system}. |
afe7408e LC |
357 | |
358 | @cindex substituter | |
359 | Users can obtain the new package definition simply by running | |
360 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
361 | @code{@value{SUBSTITUTE-SERVER}} is done building the package, installing the | |
362 | package automatically downloads binaries from there | |
363 | (@pxref{Substitutes}). The only place where human intervention is | |
364 | needed is to review and apply the patch. | |
365 | ||
366 | ||
367 | @menu | |
368 | * Software Freedom:: What may go into the distribution. | |
369 | * Package Naming:: What's in a name? | |
370 | * Version Numbers:: When the name is not enough. | |
371 | * Synopses and Descriptions:: Helping users find the right package. | |
372 | * Python Modules:: A touch of British comedy. | |
373 | * Perl Modules:: Little pearls. | |
374 | * Java Packages:: Coffee break. | |
8d1b22b2 | 375 | * Rust Crates:: Beware of oxidation. |
afe7408e LC |
376 | * Fonts:: Fond of fonts. |
377 | @end menu | |
378 | ||
379 | @node Software Freedom | |
380 | @subsection Software Freedom | |
381 | ||
382 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. | |
383 | @cindex free software | |
384 | The GNU operating system has been developed so that users can have | |
385 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
21656ffa | 386 | users have the @url{https://www.gnu.org/philosophy/free-sw.html,four |
afe7408e LC |
387 | essential freedoms}: to run the program, to study and change the program |
388 | in source code form, to redistribute exact copies, and to distribute | |
389 | modified versions. Packages found in the GNU distribution provide only | |
390 | software that conveys these four freedoms. | |
391 | ||
392 | In addition, the GNU distribution follow the | |
21656ffa | 393 | @url{https://www.gnu.org/distros/free-system-distribution-guidelines.html,free |
afe7408e LC |
394 | software distribution guidelines}. Among other things, these guidelines |
395 | reject non-free firmware, recommendations of non-free software, and | |
396 | discuss ways to deal with trademarks and patents. | |
397 | ||
398 | Some otherwise free upstream package sources contain a small and optional | |
399 | subset that violates the above guidelines, for instance because this subset | |
400 | is itself non-free code. When that happens, the offending items are removed | |
401 | with appropriate patches or code snippets in the @code{origin} form of the | |
402 | package (@pxref{Defining Packages}). This way, @code{guix | |
403 | build --source} returns the ``freed'' source rather than the unmodified | |
404 | upstream source. | |
405 | ||
406 | ||
407 | @node Package Naming | |
408 | @subsection Package Naming | |
409 | ||
410 | @cindex package name | |
411 | A package has actually two names associated with it: | |
412 | First, there is the name of the @emph{Scheme variable}, the one following | |
413 | @code{define-public}. By this name, the package can be made known in the | |
414 | Scheme code, for instance as input to another package. Second, there is | |
415 | the string in the @code{name} field of a package definition. This name | |
416 | is used by package management commands such as | |
417 | @command{guix package} and @command{guix build}. | |
418 | ||
419 | Both are usually the same and correspond to the lowercase conversion of | |
420 | the project name chosen upstream, with underscores replaced with | |
421 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
422 | SDL_net as @code{sdl-net}. | |
423 | ||
424 | We do not add @code{lib} prefixes for library packages, unless these are | |
425 | already part of the official project name. But @pxref{Python | |
426 | Modules} and @ref{Perl Modules} for special rules concerning modules for | |
427 | the Python and Perl languages. | |
428 | ||
429 | Font package names are handled differently, @pxref{Fonts}. | |
430 | ||
431 | ||
432 | @node Version Numbers | |
433 | @subsection Version Numbers | |
434 | ||
435 | @cindex package version | |
436 | We usually package only the latest version of a given free software | |
437 | project. But sometimes, for instance for incompatible library versions, | |
438 | two (or more) versions of the same package are needed. These require | |
439 | different Scheme variable names. We use the name as defined | |
440 | in @ref{Package Naming} | |
441 | for the most recent version; previous versions use the same name, suffixed | |
442 | by @code{-} and the smallest prefix of the version number that may | |
443 | distinguish the two versions. | |
444 | ||
445 | The name inside the package definition is the same for all versions of a | |
446 | package and does not contain any version number. | |
447 | ||
448 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: | |
449 | ||
8ba31e8b | 450 | @lisp |
afe7408e LC |
451 | (define-public gtk+ |
452 | (package | |
453 | (name "gtk+") | |
454 | (version "3.9.12") | |
455 | ...)) | |
456 | (define-public gtk+-2 | |
457 | (package | |
458 | (name "gtk+") | |
459 | (version "2.24.20") | |
460 | ...)) | |
8ba31e8b | 461 | @end lisp |
afe7408e | 462 | If we also wanted GTK+ 3.8.2, this would be packaged as |
8ba31e8b | 463 | @lisp |
afe7408e LC |
464 | (define-public gtk+-3.8 |
465 | (package | |
466 | (name "gtk+") | |
467 | (version "3.8.2") | |
468 | ...)) | |
8ba31e8b | 469 | @end lisp |
afe7408e LC |
470 | |
471 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>, | |
472 | @c for a discussion of what follows. | |
473 | @cindex version number, for VCS snapshots | |
474 | Occasionally, we package snapshots of upstream's version control system | |
475 | (VCS) instead of formal releases. This should remain exceptional, | |
476 | because it is up to upstream developers to clarify what the stable | |
477 | release is. Yet, it is sometimes necessary. So, what should we put in | |
478 | the @code{version} field? | |
479 | ||
480 | Clearly, we need to make the commit identifier of the VCS snapshot | |
481 | visible in the version string, but we also need to make sure that the | |
482 | version string is monotonically increasing so that @command{guix package | |
483 | --upgrade} can determine which version is newer. Since commit | |
484 | identifiers, notably with Git, are not monotonically increasing, we add | |
485 | a revision number that we increase each time we upgrade to a newer | |
486 | snapshot. The resulting version string looks like this: | |
487 | ||
488 | @example | |
489 | 2.0.11-3.cabba9e | |
490 | ^ ^ ^ | |
491 | | | `-- upstream commit ID | |
492 | | | | |
493 | | `--- Guix package revision | |
494 | | | |
495 | latest upstream version | |
496 | @end example | |
497 | ||
498 | It is a good idea to strip commit identifiers in the @code{version} | |
499 | field to, say, 7 digits. It avoids an aesthetic annoyance (assuming | |
500 | aesthetics have a role to play here) as well as problems related to OS | |
501 | limits such as the maximum shebang length (127 bytes for the Linux | |
ba2104aa | 502 | kernel). It is best to use the full commit identifiers in |
afe7408e LC |
503 | @code{origin}s, though, to avoid ambiguities. A typical package |
504 | definition may look like this: | |
505 | ||
8ba31e8b | 506 | @lisp |
afe7408e LC |
507 | (define my-package |
508 | (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7") | |
509 | (revision "1")) ;Guix package revision | |
510 | (package | |
511 | (version (git-version "0.9" revision commit)) | |
512 | (source (origin | |
513 | (method git-fetch) | |
514 | (uri (git-reference | |
515 | (url "git://example.org/my-package.git") | |
516 | (commit commit))) | |
517 | (sha256 (base32 "1mbikn@dots{}")) | |
518 | (file-name (git-file-name name version)))) | |
519 | ;; @dots{} | |
520 | ))) | |
8ba31e8b | 521 | @end lisp |
afe7408e LC |
522 | |
523 | @node Synopses and Descriptions | |
524 | @subsection Synopses and Descriptions | |
525 | ||
526 | @cindex package description | |
527 | @cindex package synopsis | |
528 | As we have seen before, each package in GNU@tie{}Guix includes a | |
529 | synopsis and a description (@pxref{Defining Packages}). Synopses and | |
530 | descriptions are important: They are what @command{guix package | |
531 | --search} searches, and a crucial piece of information to help users | |
532 | determine whether a given package suits their needs. Consequently, | |
533 | packagers should pay attention to what goes into them. | |
534 | ||
535 | Synopses must start with a capital letter and must not end with a | |
536 | period. They must not start with ``a'' or ``the'', which usually does | |
537 | not bring anything; for instance, prefer ``File-frobbing tool'' over ``A | |
538 | tool that frobs files''. The synopsis should say what the package | |
539 | is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is | |
540 | used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines | |
541 | matching a pattern''. | |
542 | ||
543 | Keep in mind that the synopsis must be meaningful for a very wide | |
544 | audience. For example, ``Manipulate alignments in the SAM format'' | |
545 | might make sense for a seasoned bioinformatics researcher, but might be | |
546 | fairly unhelpful or even misleading to a non-specialized audience. It | |
547 | is a good idea to come up with a synopsis that gives an idea of the | |
548 | application domain of the package. In this example, this might give | |
549 | something like ``Manipulate nucleotide sequence alignments'', which | |
550 | hopefully gives the user a better idea of whether this is what they are | |
551 | looking for. | |
552 | ||
553 | Descriptions should take between five and ten lines. Use full | |
554 | sentences, and avoid using acronyms without first introducing them. | |
555 | Please avoid marketing phrases such as ``world-leading'', | |
556 | ``industrial-strength'', and ``next-generation'', and avoid superlatives | |
557 | like ``the most advanced''---they are not helpful to users looking for a | |
558 | package and may even sound suspicious. Instead, try to be factual, | |
559 | mentioning use cases and features. | |
560 | ||
561 | @cindex Texinfo markup, in package descriptions | |
562 | Descriptions can include Texinfo markup, which is useful to introduce | |
563 | ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or | |
564 | hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you | |
565 | should be careful when using some characters for example @samp{@@} and | |
566 | curly braces which are the basic special characters in Texinfo | |
567 | (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces | |
568 | such as @command{guix package --show} take care of rendering it | |
569 | appropriately. | |
570 | ||
571 | Synopses and descriptions are translated by volunteers | |
21656ffa | 572 | @uref{https://translationproject.org/domain/guix-packages.html, at the |
afe7408e LC |
573 | Translation Project} so that as many users as possible can read them in |
574 | their native language. User interfaces search them and display them in | |
575 | the language specified by the current locale. | |
576 | ||
577 | To allow @command{xgettext} to extract them as translatable strings, | |
578 | synopses and descriptions @emph{must be literal strings}. This means | |
579 | that you cannot use @code{string-append} or @code{format} to construct | |
580 | these strings: | |
581 | ||
582 | @lisp | |
583 | (package | |
584 | ;; @dots{} | |
585 | (synopsis "This is translatable") | |
586 | (description (string-append "This is " "*not*" " translatable."))) | |
587 | @end lisp | |
588 | ||
589 | Translation is a lot of work so, as a packager, please pay even more | |
590 | attention to your synopses and descriptions as every change may entail | |
591 | additional work for translators. In order to help them, it is possible | |
592 | to make recommendations or instructions visible to them by inserting | |
593 | special comments like this (@pxref{xgettext Invocation,,, gettext, GNU | |
594 | Gettext}): | |
595 | ||
596 | @example | |
597 | ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated. | |
598 | (description "ARandR is designed to provide a simple visual front end | |
599 | for the X11 resize-and-rotate (RandR) extension. @dots{}") | |
600 | @end example | |
601 | ||
602 | ||
603 | @node Python Modules | |
604 | @subsection Python Modules | |
605 | ||
606 | @cindex python | |
607 | We currently package Python 2 and Python 3, under the Scheme variable names | |
608 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
609 | To avoid confusion and naming clashes with other programming languages, it | |
610 | seems desirable that the name of a package for a Python module contains | |
611 | the word @code{python}. | |
612 | ||
39356057 LF |
613 | Some modules are compatible with only one version of Python, others with |
614 | both. If the package Foo is compiled with Python 3, we name it | |
615 | @code{python-foo}. If it is compiled with Python 2, we name it | |
616 | @code{python2-foo}. Packages should be added when they are necessary; | |
617 | we don't add Python 2 variants of the package unless we are going to use | |
618 | them. | |
afe7408e LC |
619 | |
620 | If a project already contains the word @code{python}, we drop this; | |
621 | for instance, the module python-dateutil is packaged under the names | |
622 | @code{python-dateutil} and @code{python2-dateutil}. If the project name | |
623 | starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as | |
624 | described above. | |
625 | ||
626 | @subsubsection Specifying Dependencies | |
627 | @cindex inputs, for Python packages | |
628 | ||
629 | Dependency information for Python packages is usually available in the | |
630 | package source tree, with varying degrees of accuracy: in the | |
631 | @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}. | |
632 | ||
633 | Your mission, when writing a recipe for a Python package, is to map | |
634 | these dependencies to the appropriate type of ``input'' (@pxref{package | |
635 | Reference, inputs}). Although the @code{pypi} importer normally does a | |
636 | good job (@pxref{Invoking guix import}), you may want to check the | |
637 | following check list to determine which dependency goes where. | |
638 | ||
639 | @itemize | |
640 | ||
641 | @item | |
642 | We currently package Python 2 with @code{setuptools} and @code{pip} | |
643 | installed like Python 3.4 has per default. Thus you don't need to | |
644 | specify either of these as an input. @command{guix lint} will warn you | |
645 | if you do. | |
646 | ||
647 | @item | |
648 | Python dependencies required at run time go into | |
649 | @code{propagated-inputs}. They are typically defined with the | |
650 | @code{install_requires} keyword in @file{setup.py}, or in the | |
651 | @file{requirements.txt} file. | |
652 | ||
653 | @item | |
654 | Python packages required only at build time---e.g., those listed with | |
655 | the @code{setup_requires} keyword in @file{setup.py}---or only for | |
656 | testing---e.g., those in @code{tests_require}---go into | |
657 | @code{native-inputs}. The rationale is that (1) they do not need to be | |
658 | propagated because they are not needed at run time, and (2) in a | |
659 | cross-compilation context, it's the ``native'' input that we'd want. | |
660 | ||
661 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test | |
662 | frameworks. Of course if any of these packages is also required at | |
663 | run-time, it needs to go to @code{propagated-inputs}. | |
664 | ||
665 | @item | |
666 | Anything that does not fall in the previous categories goes to | |
667 | @code{inputs}, for example programs or C libraries required for building | |
668 | Python packages containing C extensions. | |
669 | ||
670 | @item | |
671 | If a Python package has optional dependencies (@code{extras_require}), | |
672 | it is up to you to decide whether to add them or not, based on their | |
673 | usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix | |
674 | size}}). | |
675 | ||
676 | @end itemize | |
677 | ||
678 | ||
679 | @node Perl Modules | |
680 | @subsection Perl Modules | |
681 | ||
682 | @cindex perl | |
683 | Perl programs standing for themselves are named as any other package, | |
684 | using the lowercase upstream name. | |
685 | For Perl packages containing a single class, we use the lowercase class name, | |
686 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
687 | @code{perl-}. | |
688 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
689 | Modules containing several classes keep their lowercase upstream name and | |
690 | are also prepended by @code{perl-}. Such modules tend to have the word | |
691 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
692 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
693 | ||
694 | ||
695 | @node Java Packages | |
696 | @subsection Java Packages | |
697 | ||
698 | @cindex java | |
699 | Java programs standing for themselves are named as any other package, | |
700 | using the lowercase upstream name. | |
701 | ||
702 | To avoid confusion and naming clashes with other programming languages, | |
703 | it is desirable that the name of a package for a Java package is | |
704 | prefixed with @code{java-}. If a project already contains the word | |
705 | @code{java}, we drop this; for instance, the package @code{ngsjava} is | |
706 | packaged under the name @code{java-ngs}. | |
707 | ||
708 | For Java packages containing a single class or a small class hierarchy, | |
709 | we use the lowercase class name, replace all occurrences of @code{.} by | |
710 | dashes and prepend the prefix @code{java-}. So the class | |
711 | @code{apache.commons.cli} becomes package | |
712 | @code{java-apache-commons-cli}. | |
713 | ||
714 | ||
8d1b22b2 EF |
715 | @node Rust Crates |
716 | @subsection Rust Crates | |
717 | ||
718 | @cindex rust | |
719 | Rust programs standing for themselves are named as any other package, using the | |
720 | lowercase upstream name. | |
721 | ||
722 | To prevent namespace collisions we prefix all other Rust packages with the | |
723 | @code{rust-} prefix. The name should be changed to lowercase as appropriate and | |
724 | dashes should remain in place. | |
725 | ||
726 | In the rust ecosystem it is common for multiple incompatible versions of a | |
727 | package to be used at any given time, so all packages should have a versioned | |
728 | suffix. If a package has passed version 1.0.0 then just the major version | |
729 | number is sufficient (e.g.@: @code{rust-clap-2}), otherwise the version suffix | |
730 | should contain both the major and minor version (e.g.@: @code{rust-rand-0.6}). | |
731 | ||
732 | Because of the difficulty in reusing rust packages as pre-compiled inputs for | |
733 | other packages the Cargo build system (@pxref{Build Systems, | |
734 | @code{cargo-build-system}}) presents the @code{#:cargo-inputs} and | |
735 | @code{cargo-development-inputs} keywords as build system arguments. It would be | |
736 | helpful to think of these as similar to @code{propagated-inputs} and | |
737 | @code{native-inputs}. Rust @code{dependencies} and @code{build-dependencies} | |
738 | should go in @code{#:cargo-inputs}, and @code{dev-dependencies} should go in | |
739 | @code{#:cargo-development-inputs}. If a Rust package links to other libraries | |
740 | then the standard placement in @code{inputs} and the like should be used. | |
741 | ||
742 | Care should be taken to ensure the correct version of dependencies are used; to | |
743 | this end we try to refrain from skipping the tests or using @code{#:skip-build?} | |
744 | when possible. Of course this is not always possible, as the package may be | |
745 | developed for a different Operating System, depend on features from the Nightly | |
746 | Rust compiler, or the test suite may have atrophied since it was released. | |
747 | ||
748 | ||
afe7408e LC |
749 | @node Fonts |
750 | @subsection Fonts | |
751 | ||
752 | @cindex fonts | |
753 | For fonts that are in general not installed by a user for typesetting | |
754 | purposes, or that are distributed as part of a larger software package, | |
755 | we rely on the general packaging rules for software; for instance, this | |
756 | applies to the fonts delivered as part of the X.Org system or fonts that | |
757 | are part of TeX Live. | |
758 | ||
759 | To make it easier for a user to search for fonts, names for other packages | |
760 | containing only fonts are constructed as follows, independently of the | |
761 | upstream package name. | |
762 | ||
763 | The name of a package containing only one font family starts with | |
764 | @code{font-}; it is followed by the foundry name and a dash @code{-} | |
765 | if the foundry is known, and the font family name, in which spaces are | |
766 | replaced by dashes (and as usual, all upper case letters are transformed | |
767 | to lower case). | |
768 | For example, the Gentium font family by SIL is packaged under the name | |
769 | @code{font-sil-gentium}. | |
770 | ||
771 | For a package containing several font families, the name of the collection | |
772 | is used in the place of the font family name. | |
773 | For instance, the Liberation fonts consist of three families, | |
774 | Liberation Sans, Liberation Serif and Liberation Mono. | |
775 | These could be packaged separately under the names | |
776 | @code{font-liberation-sans} and so on; but as they are distributed together | |
777 | under a common name, we prefer to package them together as | |
778 | @code{font-liberation}. | |
779 | ||
780 | In the case where several formats of the same font family or font collection | |
781 | are packaged separately, a short form of the format, prepended by a dash, | |
782 | is added to the package name. We use @code{-ttf} for TrueType fonts, | |
783 | @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1 | |
784 | fonts. | |
785 | ||
786 | ||
8c01b9d0 ML |
787 | @node Coding Style |
788 | @section Coding Style | |
789 | ||
790 | In general our code follows the GNU Coding Standards (@pxref{Top,,, | |
791 | standards, GNU Coding Standards}). However, they do not say much about | |
792 | Scheme, so here are some additional rules. | |
793 | ||
794 | @menu | |
795 | * Programming Paradigm:: How to compose your elements. | |
796 | * Modules:: Where to store your code? | |
797 | * Data Types and Pattern Matching:: Implementing data structures. | |
798 | * Formatting Code:: Writing conventions. | |
799 | @end menu | |
800 | ||
801 | @node Programming Paradigm | |
802 | @subsection Programming Paradigm | |
803 | ||
804 | Scheme code in Guix is written in a purely functional style. One | |
805 | exception is code that involves input/output, and procedures that | |
806 | implement low-level concepts, such as the @code{memoize} procedure. | |
807 | ||
808 | @node Modules | |
809 | @subsection Modules | |
810 | ||
811 | Guile modules that are meant to be used on the builder side must live in | |
812 | the @code{(guix build @dots{})} name space. They must not refer to | |
813 | other Guix or GNU modules. However, it is OK for a ``host-side'' module | |
814 | to use a build-side module. | |
815 | ||
816 | Modules that deal with the broader GNU system should be in the | |
817 | @code{(gnu @dots{})} name space rather than @code{(guix @dots{})}. | |
818 | ||
819 | @node Data Types and Pattern Matching | |
820 | @subsection Data Types and Pattern Matching | |
821 | ||
822 | The tendency in classical Lisp is to use lists to represent everything, | |
823 | and then to browse them ``by hand'' using @code{car}, @code{cdr}, | |
824 | @code{cadr}, and co. There are several problems with that style, | |
825 | notably the fact that it is hard to read, error-prone, and a hindrance | |
826 | to proper type error reports. | |
827 | ||
828 | Guix code should define appropriate data types (for instance, using | |
829 | @code{define-record-type*}) rather than abuse lists. In addition, it | |
830 | should use pattern matching, via Guile’s @code{(ice-9 match)} module, | |
831 | especially when matching lists. | |
832 | ||
833 | @node Formatting Code | |
834 | @subsection Formatting Code | |
835 | ||
7bb2b10c LC |
836 | @cindex formatting code |
837 | @cindex coding style | |
8c01b9d0 ML |
838 | When writing Scheme code, we follow common wisdom among Scheme |
839 | programmers. In general, we follow the | |
21656ffa | 840 | @url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp |
8c01b9d0 ML |
841 | Style Rules}. This document happens to describe the conventions mostly |
842 | used in Guile’s code too. It is very thoughtful and well written, so | |
843 | please do read it. | |
844 | ||
845 | Some special forms introduced in Guix, such as the @code{substitute*} | |
846 | macro, have special indentation rules. These are defined in the | |
8ca0c88a AK |
847 | @file{.dir-locals.el} file, which Emacs automatically uses. Also note |
848 | that Emacs-Guix provides @code{guix-devel-mode} mode that indents and | |
849 | highlights Guix code properly (@pxref{Development,,, emacs-guix, The | |
850 | Emacs-Guix Reference Manual}). | |
7bb2b10c LC |
851 | |
852 | @cindex indentation, of code | |
853 | @cindex formatting, of code | |
854 | If you do not use Emacs, please make sure to let your editor knows these | |
855 | rules. To automatically indent a package definition, you can also run: | |
856 | ||
857 | @example | |
557d9c8d | 858 | ./etc/indent-code.el gnu/packages/@var{file}.scm @var{package} |
7bb2b10c LC |
859 | @end example |
860 | ||
861 | @noindent | |
862 | This automatically indents the definition of @var{package} in | |
557d9c8d LC |
863 | @file{gnu/packages/@var{file}.scm} by running Emacs in batch mode. To |
864 | indent a whole file, omit the second argument: | |
865 | ||
866 | @example | |
867 | ./etc/indent-code.el gnu/services/@var{file}.scm | |
868 | @end example | |
8c01b9d0 | 869 | |
60912a88 LC |
870 | @cindex Vim, Scheme code editing |
871 | If you are editing code with Vim, we recommend that you run @code{:set | |
872 | autoindent} so that your code is automatically indented as you type. | |
873 | Additionally, | |
874 | @uref{https://www.vim.org/scripts/script.php?script_id=3998, | |
875 | @code{paredit.vim}} may help you deal with all these parentheses. | |
876 | ||
8c01b9d0 ML |
877 | We require all top-level procedures to carry a docstring. This |
878 | requirement can be relaxed for simple private procedures in the | |
879 | @code{(guix build @dots{})} name space, though. | |
880 | ||
881 | Procedures should not have more than four positional parameters. Use | |
882 | keyword parameters for procedures that take more than four parameters. | |
883 | ||
884 | ||
885 | @node Submitting Patches | |
886 | @section Submitting Patches | |
887 | ||
888 | Development is done using the Git distributed version control system. | |
889 | Thus, access to the repository is not strictly necessary. We welcome | |
890 | contributions in the form of patches as produced by @code{git | |
230efa87 | 891 | format-patch} sent to the @email{guix-patches@@gnu.org} mailing list. |
2d315cd4 LC |
892 | Seasoned Guix developers may also want to look at the section on commit |
893 | access (@pxref{Commit Access}). | |
230efa87 | 894 | |
a7bde77d LC |
895 | This mailing list is backed by a Debbugs instance, which allows us to |
896 | keep track of submissions (@pxref{Tracking Bugs and Patches}). Each | |
897 | message sent to that mailing list gets a new tracking number assigned; | |
898 | people can then follow up on the submission by sending email to | |
899 | @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is the tracking | |
900 | number (@pxref{Sending a Patch Series}). | |
230efa87 | 901 | |
8c01b9d0 ML |
902 | Please write commit logs in the ChangeLog format (@pxref{Change Logs,,, |
903 | standards, GNU Coding Standards}); you can check the commit history for | |
904 | examples. | |
905 | ||
906 | Before submitting a patch that adds or modifies a package definition, | |
fcc58db6 LC |
907 | please run through this check list: |
908 | ||
909 | @enumerate | |
308c08d3 RW |
910 | @item |
911 | If the authors of the packaged software provide a cryptographic | |
912 | signature for the release tarball, make an effort to verify the | |
913 | authenticity of the archive. For a detached GPG signature file this | |
914 | would be done with the @code{gpg --verify} command. | |
915 | ||
cbd02397 LC |
916 | @item |
917 | Take some time to provide an adequate synopsis and description for the | |
918 | package. @xref{Synopses and Descriptions}, for some guidelines. | |
919 | ||
fcc58db6 LC |
920 | @item |
921 | Run @code{guix lint @var{package}}, where @var{package} is the | |
8c01b9d0 | 922 | name of the new or modified package, and fix any errors it reports |
fcc58db6 LC |
923 | (@pxref{Invoking guix lint}). |
924 | ||
925 | @item | |
926 | Make sure the package builds on your platform, using @code{guix build | |
927 | @var{package}}. | |
928 | ||
89339a35 DM |
929 | @item |
930 | We recommend you also try building the package on other supported | |
931 | platforms. As you may not have access to actual hardware platforms, we | |
932 | recommend using the @code{qemu-binfmt-service-type} to emulate them. In | |
933 | order to enable it, add the following service to the list of services in | |
934 | your @code{operating-system} configuration: | |
935 | ||
8ba31e8b | 936 | @lisp |
89339a35 DM |
937 | (service qemu-binfmt-service-type |
938 | (qemu-binfmt-configuration | |
03e64049 | 939 | (platforms (lookup-qemu-platforms "arm" "aarch64")) |
89339a35 | 940 | (guix-support? #t))) |
8ba31e8b | 941 | @end lisp |
89339a35 DM |
942 | |
943 | Then reconfigure your system. | |
944 | ||
945 | You can then build packages for different platforms by specifying the | |
946 | @code{--system} option. For example, to build the "hello" package for | |
b28e4e3c EF |
947 | the armhf, aarch64, or mips64 architectures, you would run the following |
948 | commands, respectively: | |
89339a35 DM |
949 | @example |
950 | guix build --system=armhf-linux --rounds=2 hello | |
951 | guix build --system=aarch64-linux --rounds=2 hello | |
89339a35 DM |
952 | @end example |
953 | ||
d222522e LC |
954 | @item |
955 | @cindex bundling | |
956 | Make sure the package does not use bundled copies of software already | |
957 | available as separate packages. | |
958 | ||
959 | Sometimes, packages include copies of the source code of their | |
960 | dependencies as a convenience for users. However, as a distribution, we | |
961 | want to make sure that such packages end up using the copy we already | |
962 | have in the distribution, if there is one. This improves resource usage | |
963 | (the dependency is built and stored only once), and allows the | |
964 | distribution to make transverse changes such as applying security | |
965 | updates for a given software package in a single place and have them | |
966 | affect the whole system---something that bundled copies prevent. | |
967 | ||
fcc58db6 LC |
968 | @item |
969 | Take a look at the profile reported by @command{guix size} | |
970 | (@pxref{Invoking guix size}). This will allow you to notice references | |
971 | to other packages unwillingly retained. It may also help determine | |
972 | whether to split the package (@pxref{Packages with Multiple Outputs}), | |
024e358c | 973 | and which optional dependencies should be used. In particular, avoid adding |
0afeb746 PN |
974 | @code{texlive} as a dependency: because of its extreme size, use |
975 | @code{texlive-tiny} or @code{texlive-union} instead. | |
fcc58db6 LC |
976 | |
977 | @item | |
978 | For important changes, check that dependent package (if applicable) are | |
979 | not affected by the change; @code{guix refresh --list-dependent | |
8c01b9d0 ML |
980 | @var{package}} will help you do that (@pxref{Invoking guix refresh}). |
981 | ||
916b5eba LC |
982 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>. |
983 | @cindex branching strategy | |
984 | @cindex rebuild scheduling strategy | |
985 | Depending on the number of dependent packages and thus the amount of | |
986 | rebuilding induced, commits go to different branches, along these lines: | |
987 | ||
988 | @table @asis | |
989 | @item 300 dependent packages or less | |
990 | @code{master} branch (non-disruptive changes). | |
991 | ||
bb9a99e6 | 992 | @item between 300 and 1,800 dependent packages |
916b5eba | 993 | @code{staging} branch (non-disruptive changes). This branch is intended |
bb9a99e6 | 994 | to be merged in @code{master} every 6 weeks or so. Topical changes |
916b5eba LC |
995 | (e.g., an update of the GNOME stack) can instead go to a specific branch |
996 | (say, @code{gnome-updates}). | |
997 | ||
bb9a99e6 | 998 | @item more than 1,800 dependent packages |
916b5eba LC |
999 | @code{core-updates} branch (may include major and potentially disruptive |
1000 | changes). This branch is intended to be merged in @code{master} every | |
bb9a99e6 | 1001 | 6 months or so. |
916b5eba LC |
1002 | @end table |
1003 | ||
44b5f28a | 1004 | All these branches are @uref{@value{SUBSTITUTE-SERVER}, |
38ab778f | 1005 | tracked by our build farm} and merged into @code{master} once |
189b1543 LC |
1006 | everything has been successfully built. This allows us to fix issues |
1007 | before they hit users, and to reduce the window during which pre-built | |
1008 | binaries are not available. | |
1009 | ||
38ab778f MB |
1010 | Generally, branches other than @code{master} are considered |
1011 | @emph{frozen} if there has been a recent evaluation, or there is a | |
1012 | corresponding @code{-next} branch. Please ask on the mailing list or | |
1013 | IRC if unsure where to place a patch. | |
1014 | @c TODO: It would be good with badges on the website that tracks these | |
1015 | @c branches. Or maybe even a status page. | |
1016 | ||
d23c20f1 | 1017 | @item |
5b74fe06 LC |
1018 | @cindex determinism, of build processes |
1019 | @cindex reproducible builds, checking | |
d23c20f1 LC |
1020 | Check whether the package's build process is deterministic. This |
1021 | typically means checking whether an independent build of the package | |
1022 | yields the exact same result that you obtained, bit for bit. | |
1023 | ||
5b74fe06 LC |
1024 | A simple way to do that is by building the same package several times in |
1025 | a row on your machine (@pxref{Invoking guix build}): | |
1026 | ||
1027 | @example | |
1028 | guix build --rounds=2 my-package | |
1029 | @end example | |
1030 | ||
1031 | This is enough to catch a class of common non-determinism issues, such | |
1032 | as timestamps or randomly-generated output in the build result. | |
1033 | ||
1034 | Another option is to use @command{guix challenge} (@pxref{Invoking guix | |
1035 | challenge}). You may run it once the package has been committed and | |
0bc02bec | 1036 | built by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same |
5b74fe06 LC |
1037 | result as you did. Better yet: Find another machine that can build it |
1038 | and run @command{guix publish}. Since the remote build machine is | |
1039 | likely different from yours, this can catch non-determinism issues | |
1040 | related to the hardware---e.g., use of different instruction set | |
1041 | extensions---or to the operating system kernel---e.g., reliance on | |
1042 | @code{uname} or @file{/proc} files. | |
d23c20f1 | 1043 | |
3c2d03a2 LC |
1044 | @item |
1045 | When writing documentation, please use gender-neutral wording when | |
1046 | referring to people, such as | |
1047 | @uref{https://en.wikipedia.org/wiki/Singular_they, singular | |
1048 | ``they''@comma{} ``their''@comma{} ``them''}, and so forth. | |
1049 | ||
3a78fab8 | 1050 | @item |
1051 | Verify that your patch contains only one set of related changes. | |
1052 | Bundling unrelated changes together makes reviewing harder and slower. | |
1053 | ||
1054 | Examples of unrelated changes include the addition of several packages, | |
1055 | or a package update along with fixes to that package. | |
1056 | ||
7bb2b10c LC |
1057 | @item |
1058 | Please follow our code formatting rules, possibly running the | |
557d9c8d | 1059 | @command{etc/indent-code.el} script to do that automatically for you |
7bb2b10c LC |
1060 | (@pxref{Formatting Code}). |
1061 | ||
4feb589b PN |
1062 | @item |
1063 | When possible, use mirrors in the source URL (@pxref{Invoking guix download}). | |
1064 | Use reliable URLs, not generated ones. For instance, GitHub archives are not | |
1065 | necessarily identical from one generation to the next, so in this case it's | |
1066 | often better to clone the repository. Don't use the @command{name} field in | |
1067 | the URL: it is not very useful and if the name changes, the URL will probably | |
1068 | be wrong. | |
1069 | ||
bf99d7e0 | 1070 | @item |
da31e7d9 PN |
1071 | Check if Guix builds (@pxref{Building from Git}) and address the |
1072 | warnings, especially those about use of undefined symbols. | |
bf99d7e0 | 1073 | |
9fcf2820 PN |
1074 | @item |
1075 | Make sure your changes do not break Guix and simulate a @code{guix pull} with: | |
1076 | @example | |
1077 | guix pull --url=/path/to/your/checkout --profile=/tmp/guix.master | |
1078 | @end example | |
1079 | ||
fcc58db6 LC |
1080 | @end enumerate |
1081 | ||
a40424bd | 1082 | When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as |
a1891cbf BW |
1083 | a subject, if your patch is to be applied on a branch other than |
1084 | @code{master}, say @code{core-updates}, specify it in the subject like | |
1085 | @samp{[PATCH core-updates] @dots{}}. You may use your email client or | |
1086 | the @command{git send-email} command (@pxref{Sending a Patch Series}). | |
1087 | We prefer to get patches in plain text messages, either inline or as | |
1088 | MIME attachments. You are advised to pay attention if your email client | |
1089 | changes anything like line breaks or indentation which could potentially | |
1090 | break the patches. | |
5a183a1e | 1091 | |
4619b59c JN |
1092 | When a bug is resolved, please close the thread by sending an email to |
1093 | @email{@var{NNN}-done@@debbugs.gnu.org}. | |
1094 | ||
5a183a1e JN |
1095 | @unnumberedsubsec Sending a Patch Series |
1096 | @anchor{Sending a Patch Series} | |
1097 | @cindex patch series | |
1098 | @cindex @code{git send-email} | |
1099 | @cindex @code{git-send-email} | |
1100 | ||
1101 | When sending a patch series (e.g., using @code{git send-email}), please | |
1102 | first send one message to @email{guix-patches@@gnu.org}, and then send | |
1103 | subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure | |
1104 | they are kept together. See | |
1105 | @uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation} | |
fb8b99a5 AB |
1106 | for more information. You can install @command{git send-email} with |
1107 | @command{guix install git:send-email}. | |
5a183a1e | 1108 | @c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html |
a7bde77d LC |
1109 | |
1110 | @node Tracking Bugs and Patches | |
1111 | @section Tracking Bugs and Patches | |
1112 | ||
1113 | @cindex bug reports, tracking | |
1114 | @cindex patch submissions, tracking | |
1115 | @cindex issue tracking | |
1116 | @cindex Debbugs, issue tracking system | |
1117 | Bug reports and patch submissions are currently tracked using the | |
1118 | Debbugs instance at @uref{https://bugs.gnu.org}. Bug reports are filed | |
1119 | against the @code{guix} ``package'' (in Debbugs parlance), by sending | |
1120 | email to @email{bug-guix@@gnu.org}, while patch submissions are filed | |
1121 | against the @code{guix-patches} package by sending email to | |
1122 | @email{guix-patches@@gnu.org} (@pxref{Submitting Patches}). | |
1123 | ||
1124 | A web interface (actually @emph{two} web interfaces!) are available to | |
1125 | browse issues: | |
1126 | ||
1127 | @itemize | |
1128 | @item | |
cdea5265 LC |
1129 | @url{https://issues.guix.gnu.org} provides a pleasant |
1130 | interface@footnote{The web interface at | |
1131 | @url{https://issues.guix.gnu.org} is powered by Mumi, a nice piece of | |
1132 | software written in Guile, and you can help! See | |
1133 | @url{https://git.elephly.net/gitweb.cgi?p=software/mumi.git}.} to browse | |
1134 | bug reports and patches, and to participate in discussions; | |
1135 | @item | |
a7bde77d LC |
1136 | @url{https://bugs.gnu.org/guix} lists bug reports; |
1137 | @item | |
1138 | @url{https://bugs.gnu.org/guix-patches} lists patch submissions. | |
1139 | @end itemize | |
1140 | ||
cdea5265 LC |
1141 | To view discussions related to issue number @var{n}, go to |
1142 | @indicateurl{https://issues.guix.gnu.org/@var{n}} or | |
a7bde77d LC |
1143 | @indicateurl{https://bugs.gnu.org/@var{n}}. |
1144 | ||
1145 | If you use Emacs, you may find it more convenient to interact with | |
1146 | issues using @file{debbugs.el}, which you can install with: | |
1147 | ||
1148 | @example | |
1149 | guix install emacs-debbugs | |
1150 | @end example | |
1151 | ||
1152 | For example, to list all open issues on @code{guix-patches}, hit: | |
1153 | ||
1154 | @example | |
1155 | @kbd{C-u} @kbd{M-x} debbugs-gnu @kbd{RET} @kbd{RET} guix-patches @kbd{RET} n y | |
1156 | @end example | |
1157 | ||
1158 | @xref{Top,,, debbugs-ug, Debbugs User Guide}, for more information on | |
1159 | this nifty tool! | |
2d315cd4 LC |
1160 | |
1161 | @node Commit Access | |
1162 | @section Commit Access | |
1163 | ||
1164 | @cindex commit access, for developers | |
1165 | For frequent contributors, having write access to the repository is | |
ef09cb86 LC |
1166 | convenient. When you deem it necessary, consider applying for commit |
1167 | access by following these steps: | |
1168 | ||
1169 | @enumerate | |
1170 | @item | |
1171 | Find three committers who would vouch for you. You can view the list of | |
1172 | committers at | |
1173 | @url{https://savannah.gnu.org/project/memberlist.php?group=guix}. Each | |
1174 | of them should email a statement to @email{guix-maintainers@@gnu.org} (a | |
1175 | private alias for the collective of maintainers), signed with their | |
1176 | OpenPGP key. | |
1177 | ||
1178 | Committers are expected to have had some interactions with you as a | |
1179 | contributor and to be able to judge whether you are sufficiently | |
1180 | familiar with the project's practices. It is @emph{not} a judgment on | |
1181 | the value of your work, so a refusal should rather be interpreted as | |
1182 | ``let's try again later''. | |
1183 | ||
1184 | @item | |
1185 | Send @email{guix-maintainers@@gnu.org} a message stating your intent, | |
1186 | listing the three committers who support your application, signed with | |
1187 | the OpenPGP key you will use to sign commits, and giving its fingerprint | |
1188 | (see below). See @uref{https://emailselfdefense.fsf.org/en/}, for an | |
1189 | introduction to public-key cryptography with GnuPG. | |
1190 | ||
4a84deda LC |
1191 | @c See <https://sha-mbles.github.io/>. |
1192 | Set up GnuPG such that it never uses the SHA1 hash algorithm for digital | |
1193 | signatures, which is known to be unsafe since 2019, for instance by | |
1194 | adding the following line to @file{~/.gnupg/gpg.conf} (@pxref{GPG | |
1195 | Esoteric Options,,, gnupg, The GNU Privacy Guard Manual}): | |
1196 | ||
1197 | @example | |
1198 | digest-algo sha512 | |
1199 | @end example | |
1200 | ||
ef09cb86 LC |
1201 | @item |
1202 | Maintainers ultimately decide whether to grant you commit access, | |
1203 | usually following your referrals' recommendation. | |
1204 | ||
1205 | @item | |
84133320 | 1206 | @cindex OpenPGP, signed commits |
ef09cb86 LC |
1207 | If and once you've been given access, please send a message to |
1208 | @email{guix-devel@@gnu.org} to say so, again signed with the OpenPGP key | |
1209 | you will use to sign commits (do that before pushing your first commit). | |
1210 | That way, everyone can notice and ensure you control that OpenPGP key. | |
1211 | ||
84133320 LC |
1212 | @quotation Important |
1213 | Before you can push for the first time, maintainers must: | |
1214 | ||
1215 | @enumerate | |
1216 | @item | |
1217 | add your OpenPGP key to the @code{keyring} branch; | |
1218 | @item | |
1219 | add your OpenPGP fingerprint to the @file{.guix-authorizations} file of | |
1220 | the branch(es) you will commit to. | |
1221 | @end enumerate | |
1222 | @end quotation | |
ef09cb86 LC |
1223 | |
1224 | @item | |
1225 | Make sure to read the rest of this section and... profit! | |
1226 | @end enumerate | |
1227 | ||
1228 | @quotation Note | |
1229 | Maintainers are happy to give commit access to people who have been | |
1230 | contributing for some time and have a track record---don't be shy and | |
1231 | don't underestimate your work! | |
1232 | ||
1233 | However, note that the project is working towards a more automated patch | |
1234 | review and merging system, which, as a consequence, may lead us to have | |
1235 | fewer people with commit access to the main repository. Stay tuned! | |
1236 | @end quotation | |
1237 | ||
1238 | If you get commit access, please make sure to follow | |
2d315cd4 LC |
1239 | the policy below (discussions of the policy can take place on |
1240 | @email{guix-devel@@gnu.org}). | |
1241 | ||
1242 | Non-trivial patches should always be posted to | |
1243 | @email{guix-patches@@gnu.org} (trivial patches include fixing typos, | |
1244 | etc.). This mailing list fills the patch-tracking database | |
1245 | (@pxref{Tracking Bugs and Patches}). | |
1246 | ||
1247 | For patches that just add a new package, and a simple one, it's OK to | |
1248 | commit, if you're confident (which means you successfully built it in a | |
1249 | chroot setup, and have done a reasonable copyright and license | |
1250 | auditing). Likewise for package upgrades, except upgrades that trigger | |
1251 | a lot of rebuilds (for example, upgrading GnuTLS or GLib). We have a | |
1252 | mailing list for commit notifications (@email{guix-commits@@gnu.org}), | |
1253 | so people can notice. Before pushing your changes, make sure to run | |
1254 | @code{git pull --rebase}. | |
1255 | ||
1256 | All commits that are pushed to the central repository on Savannah must | |
1257 | be signed with an OpenPGP key, and the public key should be uploaded to | |
1258 | your user account on Savannah and to public key servers, such as | |
1259 | @code{keys.openpgp.org}. To configure Git to automatically sign | |
1260 | commits, run: | |
1261 | ||
1262 | @example | |
1263 | git config commit.gpgsign true | |
1264 | git config user.signingkey CABBA6EA1DC0FF33 | |
1265 | @end example | |
1266 | ||
1267 | You can prevent yourself from accidentally pushing unsigned commits to | |
1268 | Savannah by using the pre-push Git hook called located at | |
1269 | @file{etc/git/pre-push}: | |
1270 | ||
1271 | @example | |
1272 | cp etc/git/pre-push .git/hooks/pre-push | |
1273 | @end example | |
1274 | ||
1275 | When pushing a commit on behalf of somebody else, please add a | |
1276 | @code{Signed-off-by} line at the end of the commit log message---e.g., | |
1277 | with @command{git am --signoff}. This improves tracking of who did | |
1278 | what. | |
1279 | ||
1ad5209d LC |
1280 | When adding channel news entries (@pxref{Channels, Writing Channel |
1281 | News}), make sure they are well-formed by running the following command | |
1282 | right before pushing: | |
1283 | ||
1284 | @example | |
1285 | make check-channel-news | |
1286 | @end example | |
1287 | ||
2d315cd4 LC |
1288 | For anything else, please post to @email{guix-patches@@gnu.org} and |
1289 | leave time for a review, without committing anything (@pxref{Submitting | |
1290 | Patches}). If you didn’t receive any reply after two weeks, and if | |
1291 | you're confident, it's OK to commit. | |
1292 | ||
1293 | That last part is subject to being adjusted, allowing individuals to commit | |
1294 | directly on non-controversial changes on parts they’re familiar with. | |
98ebcf1c LC |
1295 | |
1296 | One last thing: the project keeps moving forward because committers not | |
1297 | only push their own awesome changes, but also offer some of their time | |
1298 | @emph{reviewing} and pushing other people's changes. As a committer, | |
1299 | you're welcome to use your expertise and commit rights to help other | |
1300 | contributors, too! |