;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019 Ludovic Courtès ;;; Copyright © 2013, 2015 Andreas Enge ;;; Copyright © 2015 Eric Bavier ;;; Copyright © 2015 Sou Bunnbu ;;; Copyright © 2015, 2016, 2017, 2018, 2020 Ricardo Wurmus ;;; Copyright © 2015, 2016, 2017 Mark H Weaver ;;; Copyright © 2015, 2016, 2017, 2018 Efraim Flashner ;;; Copyright © 2015 Raimon Grau ;;; Copyright © 2016 Mathieu Lirzin ;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2016 Jan Nieuwenhuizen ;;; Copyright © 2016, 2017 Nikita ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke ;;; Copyrigh
aboutsummaryrefslogtreecommitdiff
blob: 6770fae222deee2e46a632b90059fa7b9937ef0d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
@node Contributing
@chapter Contributing

This project is a cooperative effort, and we need your help to make it
grow!  Please get in touch with us on @email{guix-devel@@gnu.org} and
@code{#guix} on the Freenode IRC network.  We welcome ideas, bug
reports, patches, and anything that may be helpful to the project.  We
particularly welcome help on packaging (@pxref{Packaging Guidelines}).

@cindex code of conduct, of contributors
@cindex contributor covenant
We want to provide a warm, friendly, and harassment-free environment, so
that anyone can contribute to the best of their abilities.  To this end
our project uses a ``Contributor Covenant'', which was adapted from
@url{http://contributor-covenant.org/}.  You can find a local version in
the @file{CODE-OF-CONDUCT} file in the source tree.

Contributors are not required to use their legal name in patches and
on-line communication; they can use any name or pseudonym of their
choice.

@menu
* Building from Git::           The latest and greatest.
* Running Guix Before It Is Installed::  Hacker tricks.
* The Perfect Setup::           The right tools.
* Packaging Guidelines::        Growing the distribution.
* Coding Style::                Hygiene of the contributor.
* Submitting Patches::          Share your work.
@end menu

@node Building from Git
@section Building from Git

If you want to hack Guix itself, it is recommended to use the latest
version from the Git repository:

@example
git clone https://git.savannah.gnu.org/git/guix.git
@end example

When building Guix from a checkout,
the following packages are required in addition to those mentioned in
the installation instructions (@pxref{Requirements}).

@itemize
@item @url{http://gnu.org/software/autoconf/, GNU Autoconf};
@item @url{http://gnu.org/software/automake/, GNU Automake};
@item @url{http://gnu.org/software/gettext/, GNU Gettext};
@item @url{http://gnu.org/software/texinfo/, GNU Texinfo};
@item @url{http://www.graphviz.org/, Graphviz};
@item @url{http://www.gnu.org/software/help2man/, GNU Help2man (optional)}.
@end itemize

The easiest way to set up a development environment for Guix is, of
course, by using Guix!  The following command starts a new shell where
all the dependencies and appropriate environment variables are set up to
hack on Guix:

@example
guix environment guix --pure
@end example

@xref{Invoking guix environment}, for more information on that command.
Extra dependencies can be added with @option{--ad-hoc}:

@example
guix environment guix --pure --ad-hoc help2man git strace
@end example

Run @command{./bootstrap} to generate the build system infrastructure
using Autoconf and Automake.  If you get an error like this one:

@example
configure.ac:46: error: possibly undefined macro: PKG_CHECK_MODULES
@end example

@noindent
it probably means that Autoconf couldn’t find @file{pkg.m4}, which is
provided by pkg-config.  Make sure that @file{pkg.m4} is available.  The
same holds for the @file{guile.m4} set of macros provided by Guile.  For
instance, if you installed Automake in @file{/usr/local}, it wouldn’t
look for @file{.m4} files in @file{/usr/share}.  In that case, you have
to invoke the following command:

@example
export ACLOCAL_PATH=/usr/share/aclocal
@end example

@xref{Macro Search Path,,, automake, The GNU Automake Manual}, for
more information.

Then, run @command{./configure} as usual.  Make sure to pass
@code{--localstatedir=@var{directory}} where @var{directory} is the
@code{localstatedir} value used by your current installation (@pxref{The
Store}, for information about this).

Finally, you have to invoke @code{make check} to run tests
(@pxref{Running the Test Suite}).  If anything
fails, take a look at installation instructions (@pxref{Installation})
or send a message to the @email{guix-devel@@gnu.org, mailing list}.


@node Running Guix Before It Is Installed
@section Running Guix Before It Is Installed

In order to keep a sane working environment, you will find it useful to
test the changes made in your local source tree checkout without
actually installing them.  So that you can distinguish between your
``end-user'' hat and your ``motley'' costume.

To that end, all the command-line tools can be used even if you have not
run @code{make install}.  To do that, you first need to have an environment
with all the dependencies available (@pxref{Building from Git}), and then
simply prefix each command with
@command{./pre-inst-env} (the @file{pre-inst-env} script lives in the
top build tree of Guix; it is generated by @command{./configure}),
as in@footnote{The @option{-E} flag to
@command{sudo} guarantees that @code{GUILE_LOAD_PATH} is correctly set
such that @command{guix-daemon} and the tools it uses can find the Guile
modules they need.}:

@example
$ sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild
$ ./pre-inst-env guix build hello
@end example

@noindent
Similarly, for a Guile session using the Guix modules:

@example
$ ./pre-inst-env guile -c '(use-modules (guix utils)) (pk (%current-system))'

;;; ("x86_64-linux")
@end example

@noindent
@cindex REPL
@cindex read-eval-print loop
@dots{} and for a REPL (@pxref{Using Guile Interactively,,, guile, Guile
Reference Manual}):

@example
$ ./pre-inst-env guile
scheme@@(guile-user)> ,use(guix)
scheme@@(guile-user)> ,use(gnu)
scheme@@(guile-user)> (define snakes
                       (fold-packages
                         (lambda (package lst)
                           (if (string-prefix? "python"
                                               (package-name package))
                               (cons package lst)
                               lst))
                         '()))
scheme@@(guile-user)> (length snakes)
$1 = 361
@end example

The @command{pre-inst-env} script sets up all the environment variables
necessary to support this, including @env{PATH} and @env{GUILE_LOAD_PATH}.

Note that @command{./pre-inst-env guix pull} does @emph{not} upgrade the
local source tree; it simply updates the @file{~/.config/guix/current}
symlink (@pxref{Invoking guix pull}).  Run @command{git pull} instead if
you want to upgrade your local source tree.


@node The Perfect Setup
@section The Perfect Setup

The Perfect Setup to hack on Guix is basically the perfect setup used
for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
Manual}).  First, you need more than an editor, you need
@url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
wonderful @url{http://nongnu.org/geiser/, Geiser}.  To set that up, run:

@example
guix package -i emacs guile emacs-geiser
@end example

Geiser allows for interactive and incremental development from within
Emacs: code compilation and evaluation from within buffers, access to
on-line documentation (docstrings), context-sensitive completion,
@kbd{M-.} to jump to an object definition, a REPL to try out your code,
and more (@pxref{Introduction,,, geiser, Geiser User Manual}).  For
convenient Guix development, make sure to augment Guile’s load path so
that it finds source files from your checkout:

@lisp
;; @r{Assuming the Guix checkout is in ~/src/guix.}
(with-eval-after-load 'geiser-guile
  (add-to-list 'geiser-guile-load-path "~/src/guix"))
@end lisp

To actually edit the code, Emacs already has a neat Scheme mode.  But in
addition to that, you must not miss
@url{http://www.emacswiki.org/emacs/ParEdit, Paredit}.  It provides
facilities to directly operate on the syntax tree, such as raising an
s-expression or wrapping it, swallowing or rejecting the following
s-expression, etc.

@cindex code snippets
@cindex templates
@cindex reducing boilerplate
We also provide templates for common git commit messages and package
definitions in the @file{etc/snippets} directory.  These templates can
be used with @url{http://joaotavora.github.io/yasnippet/, YASnippet} to
expand short trigger strings to interactive text snippets.  You may want
to add the snippets directory to the @var{yas-snippet-dirs} variable in
Emacs.

@lisp
;; @r{Assuming the Guix checkout is in ~/src/guix.}
(with-eval-after-load 'yasnippet
  (add-to-list 'yas-snippet-dirs "~/src/guix/etc/snippets"))
@end lisp

The commit message snippets depend on @url{https://magit.vc/, Magit} to
display staged files.  When editing a commit message type @code{add}
followed by @kbd{TAB} to insert a commit message template for adding a
package; type @code{update} followed by @kbd{TAB} to insert a template
for updating a package; type @code{https} followed by @kbd{TAB} to
insert a template for changing the home page URI of a package to HTTPS.

The main snippet for @code{scheme-mode} is triggered by typing
@code{package...} followed by @kbd{TAB}.  This snippet also inserts the
trigger string @code{origin...}, which can be expanded further.  The
@code{origin} snippet in turn may insert other trigger strings ending on
@code{...}, which also can be expanded further.


@node Packaging Guidelines
@section Packaging Guidelines

@cindex packages, creating
The GNU distribution is nascent and may well lack some of your favorite
packages.  This section describes how you can help make the distribution
grow.

Free software packages are usually distributed in the form of
@dfn{source code tarballs}---typically @file{tar.gz} files that contain
all the source files.  Adding a package to the distribution means
essentially two things: adding a @dfn{recipe} that describes how to
build the package, including a list of other packages required to build
it, and adding @dfn{package metadata} along with that recipe, such as a
description and licensing information.

In Guix all this information is embodied in @dfn{package definitions}.
Package definitions provide a high-level view of the package.  They are
written using the syntax of the Scheme programming language; in fact,
for each package we define a variable bound to the package definition,
and export that variable from a module (@pxref{Package Modules}).
However, in-depth Scheme knowledge is @emph{not} a prerequisite for
creating packages.  For more information on package definitions,
@pxref{Defining Packages}.

Once a package definition is in place, stored in a file in the Guix
source tree, it can be tested using the @command{guix build} command
(@pxref{Invoking guix build}).  For example, assuming the new package is
called @code{gnew}, you may run this command from the Guix build tree
(@pxref{Running Guix Before It Is Installed}):

@example
./pre-inst-env guix build gnew --keep-failed
@end example

Using @code{--keep-failed} makes it easier to debug build failures since
it provides access to the failed build tree.  Another useful
command-line option when debugging is @code{--log-file}, to access the
build log.

If the package is unknown to the @command{guix} command, it may be that
the source file contains a syntax error, or lacks a @code{define-public}
clause to export the package variable.  To figure it out, you may load
the module from Guile to get more information about the actual error:

@example
./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
@end example

Once your package builds correctly, please send us a patch
(@pxref{Submitting Patches}).  Well, if you need help, we will be happy to
help you too.  Once the patch is committed in the Guix repository, the
new package automatically gets built on the supported platforms by
@url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
system}.

@cindex substituter
Users can obtain the new package definition simply by running
@command{guix pull} (@pxref{Invoking guix pull}).  When
@code{@value{SUBSTITUTE-SERVER}} is done building the package, installing the
package automatically downloads binaries from there
(@pxref{Substitutes}).  The only place where human intervention is
needed is to review and apply the patch.


@menu
* Software Freedom::            What may go into the distribution.
* Package Naming::              What's in a name?
* Version Numbers::             When the name is not enough.
* Synopses and Descriptions::   Helping users find the right package.
* Python Modules::              A touch of British comedy.
* Perl Modules::                Little pearls.
* Java Packages::               Coffee break.
* Fonts::                       Fond of fonts.
@end menu

@node Software Freedom
@subsection Software Freedom

@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
@cindex free software
The GNU operating system has been developed so that users can have
freedom in their computing.  GNU is @dfn{free software}, meaning that
users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
essential freedoms}: to run the program, to study and change the program
in source code form, to redistribute exact copies, and to distribute
modified versions.  Packages found in the GNU distribution provide only
software that conveys these four freedoms.

In addition, the GNU distribution follow the
@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
software distribution guidelines}.  Among other things, these guidelines
reject non-free firmware, recommendations of non-free software, and
discuss ways to deal with trademarks and patents.

Some otherwise free upstream package sources contain a small and optional
subset that violates the above guidelines, for instance because this subset
is itself non-free code.  When that happens, the offending items are removed
with appropriate patches or code snippets in the @code{origin} form of the
package (@pxref{Defining Packages}).  This way, @code{guix
build --source} returns the ``freed'' source rather than the unmodified
upstream source.


@node Package Naming
@subsection Package Naming

@cindex package name
A package has actually two names associated with it:
First, there is the name of the @emph{Scheme variable}, the one following
@code{define-public}.  By this name, the package can be made known in the
Scheme code, for instance as input to another package.  Second, there is
the string in the @code{name} field of a package definition.  This name
is used by package management commands such as
@command{guix package} and @command{guix build}.

Both are usually the same and correspond to the lowercase conversion of
the project name chosen upstream, with underscores replaced with
hyphens.  For instance, GNUnet is available as @code{gnunet}, and
SDL_net as @code{sdl-net}.

We do not add @code{lib} prefixes for library packages, unless these are
already part of the official project name.  But @pxref{Python
Modules} and @ref{Perl Modules} for special rules concerning modules for
the Python and Perl languages.

Font package names are handled differently, @pxref{Fonts}.


@node Version Numbers
@subsection Version Numbers

@cindex package version
We usually package only the latest version of a given free software
project.  But sometimes, for instance for incompatible library versions,
two (or more) versions of the same package are needed.  These require
different Scheme variable names.  We use the name as defined
in @ref{Package Naming}
for the most recent version; previous versions use the same name, suffixed
by @code{-} and the smallest prefix of the version number that may
distinguish the two versions.

The name inside the package definition is the same for all versions of a
package and does not contain any version number.

For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:

@example
(define-public gtk+
  (package
    (name "gtk+")
    (version "3.9.12")
    ...))
(define-public gtk+-2
  (package
    (name "gtk+")
    (version "2.24.20")
    ...))
@end example
If we also wanted GTK+ 3.8.2, this would be packaged as
@example
(define-public gtk+-3.8
  (package
    (name "gtk+")
    (version "3.8.2")
    ...))
@end example

@c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
@c for a discussion of what follows.
@cindex version number, for VCS snapshots
Occasionally, we package snapshots of upstream's version control system
(VCS) instead of formal releases.  This should remain exceptional,
because it is up to upstream developers to clarify what the stable
release is.  Yet, it is sometimes necessary.  So, what should we put in
the @code{version} field?

Clearly, we need to make the commit identifier of the VCS snapshot
visible in the version string, but we also need to make sure that the
version string is monotonically increasing so that @command{guix package
--upgrade} can determine which version is newer.  Since commit
identifiers, notably with Git, are not monotonically increasing, we add
a revision number that we increase each time we upgrade to a newer
snapshot.  The resulting version string looks like this:

@example
2.0.11-3.cabba9e
  ^    ^    ^
  |    |    `-- upstream commit ID
  |    |
  |    `--- Guix package revision
  |
latest upstream version
@end example

It is a good idea to strip commit identifiers in the @code{version}
field to, say, 7 digits.  It avoids an aesthetic annoyance (assuming
aesthetics have a role to play here) as well as problems related to OS
limits such as the maximum shebang length (127 bytes for the Linux
kernel.)  It is best to use the full commit identifiers in
@code{origin}s, though, to avoid ambiguities.  A typical package
definition may look like this:

@example
(define my-package
  (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
        (revision "1"))          ;Guix package revision
    (package
      (version (git-version "0.9" revision commit))
      (source (origin
                (method git-fetch)
                (uri (git-reference
                      (url "git://example.org/my-package.git")
                      (commit commit)))
                (sha256 (base32 "1mbikn@dots{}"))
                (file-name (git-file-name name version))))
      ;; @dots{}
      )))
@end example

@node Synopses and Descriptions
@subsection Synopses and Descriptions

@cindex package description
@cindex package synopsis
As we have seen before, each package in GNU@tie{}Guix includes a
synopsis and a description (@pxref{Defining Packages}).  Synopses and
descriptions are important: They are what @command{guix package
--search} searches, and a crucial piece of information to help users
determine whether a given package suits their needs.  Consequently,
packagers should pay attention to what goes into them.

Synopses must start with a capital letter and must not end with a
period.  They must not start with ``a'' or ``the'', which usually does
not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
tool that frobs files''.  The synopsis should say what the package
is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
matching a pattern''.

Keep in mind that the synopsis must be meaningful for a very wide
audience.  For example, ``Manipulate alignments in the SAM format''
might make sense for a seasoned bioinformatics researcher, but might be
fairly unhelpful or even misleading to a non-specialized audience.  It
is a good idea to come up with a synopsis that gives an idea of the
application domain of the package.  In this example, this might give
something like ``Manipulate nucleotide sequence alignments'', which
hopefully gives the user a better idea of whether this is what they are
looking for.

Descriptions should take between five and ten lines.  Use full
sentences, and avoid using acronyms without first introducing them.
Please avoid marketing phrases such as ``world-leading'',
``industrial-strength'', and ``next-generation'', and avoid superlatives
like ``the most advanced''---they are not helpful to users looking for a
package and may even sound suspicious.  Instead, try to be factual,
mentioning use cases and features.

@cindex Texinfo markup, in package descriptions
Descriptions can include Texinfo markup, which is useful to introduce
ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}).  However you
should be careful when using some characters for example @samp{@@} and
curly braces which are the basic special characters in Texinfo
(@pxref{Special Characters,,, texinfo, GNU Texinfo}).  User interfaces
such as @command{guix package --show} take care of rendering it
appropriately.

Synopses and descriptions are translated by volunteers
@uref{http://translationproject.org/domain/guix-packages.html, at the
Translation Project} so that as many users as possible can read them in
their native language.  User interfaces search them and display them in
the language specified by the current locale.

To allow @command{xgettext} to extract them as translatable strings,
synopses and descriptions @emph{must be literal strings}.  This means
that you cannot use @code{string-append} or @code{format} to construct
these strings:

@lisp
(package
  ;; @dots{}
  (synopsis "This is translatable")
  (description (string-append "This is " "*not*" " translatable.")))
@end lisp

Translation is a lot of work so, as a packager, please pay even more
attention to your synopses and descriptions as every change may entail
additional work for translators.  In order to help them, it is possible
to make recommendations or instructions visible to them by inserting
special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
Gettext}):

@example
;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
(description "ARandR is designed to provide a simple visual front end
for the X11 resize-and-rotate (RandR) extension. @dots{}")
@end example


@node Python Modules
@subsection Python Modules

@cindex python
We currently package Python 2 and Python 3, under the Scheme variable names
@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
To avoid confusion and naming clashes with other programming languages, it
seems desirable that the name of a package for a Python module contains
the word @code{python}.

Some modules are compatible with only one version of Python, others with both.
If the package Foo compiles only with Python 3, we name it
@code{python-foo}; if it compiles only with Python 2, we name it
@code{python2-foo}. If it is compatible with both versions, we create two
packages with the corresponding names.

If a project already contains the word @code{python}, we drop this;
for instance, the module python-dateutil is packaged under the names
@code{python-dateutil} and @code{python2-dateutil}.  If the project name
starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
described above.

@subsubsection Specifying Dependencies
@cindex inputs, for Python packages

Dependency information for Python packages is usually available in the
package source tree, with varying degrees of accuracy: in the
@file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.

Your mission, when writing a recipe for a Python package, is to map
these dependencies to the appropriate type of ``input'' (@pxref{package
Reference, inputs}).  Although the @code{pypi} importer normally does a
good job (@pxref{Invoking guix import}), you may want to check the
following check list to determine which dependency goes where.

@itemize

@item
We currently package Python 2 with @code{setuptools} and @code{pip}
installed like Python 3.4 has per default.  Thus you don't need to
specify either of these as an input.  @command{guix lint} will warn you
if you do.

@item
Python dependencies required at run time go into
@code{propagated-inputs}.  They are typically defined with the
@code{install_requires} keyword in @file{setup.py}, or in the
@file{requirements.txt} file.

@item
Python packages required only at build time---e.g., those listed with
the @code{setup_requires} keyword in @file{setup.py}---or only for
testing---e.g., those in @code{tests_require}---go into
@code{native-inputs}.  The rationale is that (1) they do not need to be
propagated because they are not needed at run time, and (2) in a
cross-compilation context, it's the ``native'' input that we'd want.

Examples are the @code{pytest}, @code{mock}, and @code{nose} test
frameworks.  Of course if any of these packages is also required at
run-time, it needs to go to @code{propagated-inputs}.

@item
Anything that does not fall in the previous categories goes to
@code{inputs}, for example programs or C libraries required for building
Python packages containing C extensions.

@item
If a Python package has optional dependencies (@code{extras_require}),
it is up to you to decide whether to add them or not, based on their
usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
size}}).

@end itemize


@node Perl Modules
@subsection Perl Modules

@cindex perl
Perl programs standing for themselves are named as any other package,
using the lowercase upstream name.
For Perl packages containing a single class, we use the lowercase class name,
replace all occurrences of @code{::} by dashes and prepend the prefix
@code{perl-}.
So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
Modules containing several classes keep their lowercase upstream name and
are also prepended by @code{perl-}.  Such modules tend to have the word
@code{perl} somewhere in their name, which gets dropped in favor of the
prefix.  For instance, @code{libwww-perl} becomes @code{perl-libwww}.


@node Java Packages
@subsection Java Packages

@cindex java
Java programs standing for themselves are named as any other package,
using the lowercase upstream name.

To avoid confusion and naming clashes with other programming languages,
it is desirable that the name of a package for a Java package is
prefixed with @code{java-}.  If a project already contains the word
@code{java}, we drop this; for instance, the package @code{ngsjava} is
packaged under the name @code{java-ngs}.

For Java packages containing a single class or a small class hierarchy,
we use the lowercase class name, replace all occurrences of @code{.} by
dashes and prepend the prefix @code{java-}.  So the class
@code{apache.commons.cli} becomes package
@code{java-apache-commons-cli}.


@node Fonts
@subsection Fonts

@cindex fonts
For fonts that are in general not installed by a user for typesetting
purposes, or that are distributed as part of a larger software package,
we rely on the general packaging rules for software; for instance, this
applies to the fonts delivered as part of the X.Org system or fonts that
are part of TeX Live.

To make it easier for a user to search for fonts, names for other packages
containing only fonts are constructed as follows, independently of the
upstream package name.

The name of a package containing only one font family starts with
@code{font-}; it is followed by the foundry name and a dash @code{-}
if the foundry is known, and the font family name, in which spaces are
replaced by dashes (and as usual, all upper case letters are transformed
to lower case).
For example, the Gentium font family by SIL is packaged under the name
@code{font-sil-gentium}.

For a package containing several font families, the name of the collection
is used in the place of the font family name.
For instance, the Liberation fonts consist of three families,
Liberation Sans, Liberation Serif and Liberation Mono.
These could be packaged separately under the names
@code{font-liberation-sans} and so on; but as they are distributed together
under a common name, we prefer to package them together as
@code{font-liberation}.

In the case where several formats of the same font family or font collection
are packaged separately, a short form of the format, prepended by a dash,
is added to the package name.  We use @code{-ttf} for TrueType fonts,
@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
fonts.


@node Coding Style
@section Coding Style

In general our code follows the GNU Coding Standards (@pxref{Top,,,
standards, GNU Coding Standards}).  However, they do not say much about
Scheme, so here are some additional rules.

@menu
* Programming Paradigm::        How to compose your elements.
* Modules::                     Where to store your code?
* Data Types and Pattern Matching::  Implementing data structures.
* Formatting Code::             Writing conventions.
@end menu

@node Programming Paradigm
@subsection Programming Paradigm

Scheme code in Guix is written in a purely functional style.  One
exception is code that involves input/output, and procedures that
implement low-level concepts, such as the @code{memoize} procedure.

@node Modules
@subsection Modules

Guile modules that are meant to be used on the builder side must live in
the @code{(guix build @dots{})} name space.  They must not refer to
other Guix or GNU modules.  However, it is OK for a ``host-side'' module
to use a build-side module.

Modules that deal with the broader GNU system should be in the
@code{(gnu @dots{})} name space rather than @code{(guix @dots{})}.

@node Data Types and Pattern Matching
@subsection Data Types and Pattern Matching

The tendency in classical Lisp is to use lists to represent everything,
and then to browse them ``by hand'' using @code{car}, @code{cdr},
@code{cadr}, and co.  There are several problems with that style,
notably the fact that it is hard to read, error-prone, and a hindrance
to proper type error reports.

Guix code should define appropriate data types (for instance, using
@code{define-record-type*}) rather than abuse lists.  In addition, it
should use pattern matching, via Guile’s @code{(ice-9 match)} module,
especially when matching lists.

@node Formatting Code
@subsection Formatting Code

@cindex formatting code
@cindex coding style
When writing Scheme code, we follow common wisdom among Scheme
programmers.  In general, we follow the
@url{http://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
Style Rules}.  This document happens to describe the conventions mostly
used in Guile’s code too.  It is very thoughtful and well written, so
please do read it.

Some special forms introduced in Guix, such as the @code{substitute*}
macro, have special indentation rules.  These are defined in the
@file{.dir-locals.el} file, which Emacs automatically uses.  Also note
that Emacs-Guix provides @code{guix-devel-mode} mode that indents and
highlights Guix code properly (@pxref{Development,,, emacs-guix, The
Emacs-Guix Reference Manual}).

@cindex indentation, of code
@cindex formatting, of code
If you do not use Emacs, please make sure to let your editor knows these
rules.  To automatically indent a package definition, you can also run:

@example
./etc/indent-code.el gnu/packages/@var{file}.scm @var{package}
@end example

@noindent
This automatically indents the definition of @var{package} in
@file{gnu/packages/@var{file}.scm} by running Emacs in batch mode.  To
indent a whole file, omit the second argument:

@example
./etc/indent-code.el gnu/services/@var{file}.scm
@end example

@cindex Vim, Scheme code editing
If you are editing code with Vim, we recommend that you run @code{:set
autoindent} so that your code is automatically indented as you type.
Additionally,
@uref{https://www.vim.org/scripts/script.php?script_id=3998,
@code{paredit.vim}} may help you deal with all these parentheses.

We require all top-level procedures to carry a docstring.  This
requirement can be relaxed for simple private procedures in the
@code{(guix build @dots{})} name space, though.

Procedures should not have more than four positional parameters.  Use
keyword parameters for procedures that take more than four parameters.


@node Submitting Patches
@section Submitting Patches

Development is done using the Git distributed version control system.
Thus, access to the repository is not strictly necessary.  We welcome
contributions in the form of patches as produced by @code{git
format-patch} sent to the @email{guix-patches@@gnu.org} mailing list.

This mailing list is backed by a Debbugs instance accessible at
@uref{https://bugs.gnu.org/guix-patches}, which allows us to keep track
of submissions.  Each message sent to that mailing list gets a new
tracking number assigned; people can then follow up on the submission by
sending email to @code{@var{NNN}@@debbugs.gnu.org}, where @var{NNN} is
the tracking number (@pxref{Sending a Patch Series}).

Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
standards, GNU Coding Standards}); you can check the commit history for
examples.

Before submitting a patch that adds or modifies a package definition,
please run through this check list:

@enumerate
@item
If the authors of the packaged software provide a cryptographic
signature for the release tarball, make an effort to verify the
authenticity of the archive.  For a detached GPG signature file this
would be done with the @code{gpg --verify} command.

@item
Take some time to provide an adequate synopsis and description for the
package.  @xref{Synopses and Descriptions}, for some guidelines.

@item
Run @code{guix lint @var{package}}, where @var{package} is the
name of the new or modified package, and fix any errors it reports
(@pxref{Invoking guix lint}).

@item
Make sure the package builds on your platform, using @code{guix build
@var{package}}.

@item
We recommend you also try building the package on other supported
platforms.  As you may not have access to actual hardware platforms, we
recommend using the @code{qemu-binfmt-service-type} to emulate them.  In
order to enable it, add the following service to the list of services in
your @code{operating-system} configuration:

@example
(service qemu-binfmt-service-type
 (qemu-binfmt-configuration
   (platforms (lookup-qemu-platforms "arm" "aarch64" "mips64el"))
   (guix-support? #t)))
@end example

Then reconfigure your system.

You can then build packages for different platforms by specifying the
@code{--system} option.  For example, to build the "hello" package for
the armhf, aarch64, or mips64 architectures, you would run the following
commands, respectively:
@example
guix build --system=armhf-linux --rounds=2 hello
guix build --system=aarch64-linux --rounds=2 hello
guix build --system=mips64el-linux --rounds=2 hello
@end example

@item
@cindex bundling
Make sure the package does not use bundled copies of software already
available as separate packages.

Sometimes, packages include copies of the source code of their
dependencies as a convenience for users.  However, as a distribution, we
want to make sure that such packages end up using the copy we already
have in the distribution, if there is one.  This improves resource usage
(the dependency is built and stored only once), and allows the
distribution to make transverse changes such as applying security
updates for a given software package in a single place and have them
affect the whole system---something that bundled copies prevent.

@item
Take a look at the profile reported by @command{guix size}
(@pxref{Invoking guix size}).  This will allow you to notice references
to other packages unwillingly retained.  It may also help determine
whether to split the package (@pxref{Packages with Multiple Outputs}),
and which optional dependencies should be used.  In particular, avoid adding
@code{texlive} as a dependency: because of its extreme size, use
@code{texlive-tiny} or @code{texlive-union} instead.

@item
For important changes, check that dependent package (if applicable) are
not affected by the change; @code{guix refresh --list-dependent
@var{package}} will help you do that (@pxref{Invoking guix refresh}).

@c See <https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00933.html>.
@cindex branching strategy
@cindex rebuild scheduling strategy
Depending on the number of dependent packages and thus the amount of
rebuilding induced, commits go to different branches, along these lines:

@table @asis
@item 300 dependent packages or less
@code{master} branch (non-disruptive changes).

@item between 300 and 1,200 dependent packages
@code{staging} branch (non-disruptive changes).  This branch is intended
to be merged in @code{master} every 3 weeks or so.  Topical changes
(e.g., an update of the GNOME stack) can instead go to a specific branch
(say, @code{gnome-updates}).

@item more than 1,200 dependent packages
@code{core-updates} branch (may include major and potentially disruptive
changes).  This branch is intended to be merged in @code{master} every
2.5 months or so.
@end table

All these branches are @uref{https://hydra.gnu.org/project/gnu,
tracked by our build farm} and merged into @code{master} once
everything has been successfully built.  This allows us to fix issues
before they hit users, and to reduce the window during which pre-built
binaries are not available.

Generally, branches other than @code{master} are considered
@emph{frozen} if there has been a recent evaluation, or there is a
corresponding @code{-next} branch.  Please ask on the mailing list or
IRC if unsure where to place a patch.
@c TODO: It would be good with badges on the website that tracks these
@c branches.  Or maybe even a status page.

@item
@cindex determinism, of build processes
@cindex reproducible builds, checking
Check whether the package's build process is deterministic.  This
typically means checking whether an independent build of the package
yields the exact same result that you obtained, bit for bit.

A simple way to do that is by building the same package several times in
a row on your machine (@pxref{Invoking guix build}):

@example
guix build --rounds=2 my-package
@end example

This is enough to catch a class of common non-determinism issues, such
as timestamps or randomly-generated output in the build result.

Another option is to use @command{guix challenge} (@pxref{Invoking guix
challenge}).  You may run it once the package has been committed and
built by @code{@value{SUBSTITUTE-SERVER}} to check whether it obtains the same
result as you did.  Better yet: Find another machine that can build it
and run @command{guix publish}.  Since the remote build machine is
likely different from yours, this can catch non-determinism issues
related to the hardware---e.g., use of different instruction set
extensions---or to the operating system kernel---e.g., reliance on
@code{uname} or @file{/proc} files.

@item
When writing documentation, please use gender-neutral wording when
referring to people, such as
@uref{https://en.wikipedia.org/wiki/Singular_they, singular
``they''@comma{} ``their''@comma{} ``them''}, and so forth.

@item
Verify that your patch contains only one set of related changes.
Bundling unrelated changes together makes reviewing harder and slower.

Examples of unrelated changes include the addition of several packages,
or a package update along with fixes to that package.

@item
Please follow our code formatting rules, possibly running the
@command{etc/indent-code.el} script to do that automatically for you
(@pxref{Formatting Code}).

@item
When possible, use mirrors in the source URL (@pxref{Invoking guix download}).
Use reliable URLs, not generated ones.  For instance, GitHub archives are not
necessarily identical from one generation to the next, so in this case it's
often better to clone the repository.  Don't use the @command{name} field in
the URL: it is not very useful and if the name changes, the URL will probably
be wrong.

@end enumerate

When posting a patch to the mailing list, use @samp{[PATCH] @dots{}} as
a subject.  You may use your email client or the @command{git
send-email} command (@pxref{Sending a Patch Series}).  We prefer to get
patches in plain text messages, either inline or as MIME attachments.
You are advised to pay attention if your email client changes anything
like line breaks or indentation which could potentially break the
patches.

When a bug is resolved, please close the thread by sending an email to
@email{@var{NNN}-done@@debbugs.gnu.org}.

@unnumberedsubsec Sending a Patch Series
@anchor{Sending a Patch Series}
@cindex patch series
@cindex @code{git send-email}
@cindex @code{git-send-email}

When sending a patch series (e.g., using @code{git send-email}), please
first send one message to @email{guix-patches@@gnu.org}, and then send
subsequent patches to @email{@var{NNN}@@debbugs.gnu.org} to make sure
they are kept together.  See
@uref{https://debbugs.gnu.org/Advanced.html, the Debbugs documentation}
for more information.
@c Debbugs bug: https://debbugs.gnu.org/db/15/15361.html
version "/jaxen-" version "-sources.jar")) (sha256 (base32 "18pa8mks3gfhazmkyil8wsp6j1g1x7rggqxfv4k2mnixkrj5x1kx")))) (build-system ant-build-system) (arguments `(#:jar-name "jaxen.jar" #:source-dir "src" #:tests? #f; no tests #:phases (modify-phases %standard-phases (add-before 'build 'remove-dom4j (lambda _ (delete-file-recursively "src/org/jaxen/dom4j") (delete-file-recursively "src/org/jaxen/xom") #t))))) (inputs `(("java-jdom" ,java-jdom))) (home-page "https://github.com/jaxen-xpath/jaxen") (synopsis "XPath library") (description "Jaxen is an XPath library written in Java. It is adaptable to many different object models, including DOM, XOM, dom4j, and JDOM. It is also possible to write adapters that treat non-XML trees such as compiled Java byte code or Java beans as XML, thus enabling you to query these trees with XPath too.") (license license:bsd-3))) (define-public java-jaxen (package (inherit java-jaxen-bootstrap) (name "java-jaxen") (inputs `(("java-jdom" ,java-jdom) ("java-xom" ,java-xom) ("java-dom4j" ,java-dom4j))))) (define-public java-xom (package (name "java-xom") (version "127") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/elharo/xom") (commit (string-append "XOM_" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1jh6y03g5zzdhsb5jm6ms1xnamr460qmn96y3w6aw0ikfwqlg0bq")) (modules '((guix build utils))) (snippet '(begin (for-each delete-file (find-files "." "\\.jar$")) #t)))) (build-system ant-build-system) (arguments `(#:jar-name "xom.jar" #:jdk ,icedtea-8 #:tests? #f ; no tests #:phases (modify-phases %standard-phases (add-after 'unpack 'make-git-checkout-writable (lambda _ (for-each make-file-writable (find-files ".")) #t)) (add-before 'configure 'fix-tagsoup-dep (lambda _ ;; FIXME: Where is tagsoup source? (delete-file "src/nu/xom/tools/XHTMLJavaDoc.java") #t))))) (inputs `(("java-jdom" ,java-jdom) ("java-junit" ,java-junit) ("java-classpathx-servletapi" ,java-classpathx-servletapi) ("java-jaxen-bootstrap" ,java-jaxen-bootstrap) ("java-xerces" ,java-xerces))) (home-page "https://xom.nu/") (synopsis "XML Object Model") (description "XOM is a new XML Object Model for processing XML with Java that strives for correctness and simplicity.") ;; 2.1 only (license license:lgpl2.1))) (define-public java-xsdlib (package (name "java-xsdlib") (version "2013.2") (source (origin (method url-fetch) (uri (string-append "https://repo1.maven.org/maven2/com/sun/msv/" "datatype/xsd/xsdlib/" version "/xsdlib-" version "-sources.jar")) (sha256 (base32 "185i48p1xp09wbq03i9zgfl701qa262rq46yf4cajzmk3336kqim")))) (build-system ant-build-system) (arguments `(#:tests? #f; no tests #:jar-name "xsdlib.jar" #:jdk ,icedtea-8)) (inputs `(("java-xerces" ,java-xerces))) (home-page (string-append "https://web.archive.org/web/20161127144537/" "https://msv.java.net//")) (synopsis "Sun Multi-Schema Validator") (description "Xsdlib contains an implementation of sun.com.msv, an XML validator.") (license license:bsd-2))) (define-public java-xpp3 (package (name "java-xpp3") (version "1.1.4") (source (origin (method url-fetch) (uri (string-append "http://www.extreme.indiana.edu/dist/" "java-repository/xpp3/distributions/xpp3-" version "_src.tgz")) (sha256 (base32 "1b99zrhyij5qwyhilyjdl1ykxvhk902vsvflh6gx4fir8hfvdl5p")) (modules '((guix build utils))) (snippet '(begin ;; Delete bundled jar archives. (for-each delete-file (find-files "." ".*\\.jar")) #t)))) (build-system ant-build-system) (arguments `(#:tests? #f; no tests #:build-target "jar" #:phases (modify-phases %standard-phases (replace 'install (install-jars "build"))))) (home-page "http://www.extreme.indiana.edu/xgws/xsoap/xpp/") (synopsis "Streaming pull XML parser") (description "Xml Pull Parser (in short XPP) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements (for example in SOAP processors). This package is a stable XmlPull parsing engine that is based on ideas from XPP and in particular XPP2 but completely revised and rewritten to take the best advantage of JIT JVMs.") (license (license:non-copyleft "file://LICENSE.txt")))) (define-public java-xmlpull2 (package (name "java-xmlpull2") (version "2.1.10") (source (origin (method url-fetch) (uri (string-append "http://www.extreme.indiana.edu/xgws/xsoap/" "PullParser/PullParser" version ".tgz")) (sha256 (base32 "1kw9nhyqb7bzhn2zjbwlpi5vp5rzj89amzi3hadw2acyh2dmd0md")) (modules '((guix build utils))) (snippet '(begin ;; Delete bundled jar archives. (for-each delete-file (find-files "." ".*\\.jar")) #t)))) (build-system ant-build-system) (arguments `(#:tests? #f; no tests #:build-target "impl" #:phases (modify-phases %standard-phases (replace 'install (install-jars "build/lib"))))) (home-page "http://www.extreme.indiana.edu/xgws/xsoap/xpp/") (synopsis "Streaming pull XML parser") (description "Xml Pull Parser (in short XPP) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements (for example in SOAP processors). This package is in maintenance mode.") (license (license:non-copyleft "file:///LICENSE.txt")))) (define-public java-xmlpull-api-v1 (package (name "java-xmlpull-api-v1") (version "1.1.3.4b") (source (origin ;; The package is originally from Extreme! Lab, but the website ;; is now gone. This repositories contains the sources of the ;; latest version. (method git-fetch) (uri (git-reference (url "https://github.com/aslom/xmlpull-api-v1") ;; No releases, this is the latest commit (commit "abeaa4aa87b2625af70c32f658f44e11355fe568"))) (file-name (git-file-name name version)) (sha256 (base32 "15bdqxfncnakskna4m9gsh4f9iczxy83qxn2anqiqd15z406a5ih")) (modules '((guix build utils))) (snippet `(begin (delete-file-recursively "lib") (mkdir-p "lib") ;; prevents a failure in "dist_lite" (substitute* "build.xml" (("README.html") "README.md")))))) (build-system ant-build-system) (arguments `(#:test-target "junit" #:build-target "dist" #:phases (modify-phases %standard-phases (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (doc (string-append out "/share/doc/" ,name "-" ,version)) (java (string-append out "/share/java")) (project (string-append "xmlpull_" ,(string-join (string-split version #\.) "_")))) (mkdir-p doc) (copy-recursively (string-append "build/dist/" project "/doc/") doc) (mkdir-p java) (copy-file (string-append "build/dist/" project "/" project ".jar") (string-append java "/" project ".jar"))) ))))) (home-page "https://github.com/aslom/xmlpull-api-v1") (synopsis "XML pull parsing API") (description "XmlPull v1 API is a simple to use XML pull parsing API. XML pull parsing allows incremental (sometimes called streaming) parsing of XML where application is in control - the parsing can be interrupted at any given moment and resumed when application is ready to consume more input.") (license license:public-domain))) (define-public java-dom4j (package (name "java-dom4j") (version "2.1.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dom4j/dom4j") (commit (string-append "version-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0q907srj9v4hwicpcrn4slyld5npf2jv7hzchsgrg29q2xmbwkdl")) (modules '((guix build utils))) (snippet '(begin ;; Delete bundled jar archives. (for-each delete-file (find-files "." ".*\\.jar")) #t)))) (build-system ant-build-system) (arguments `(#:jar-name "dom4j.jar" #:jdk ,icedtea-8 #:source-dir "src/main/java" ;; FIXME: Requires xalan, but xalan depends on java-cup which has a ;; dependency on itself through jflex. #:tests? #f #:phases (modify-phases %standard-phases (add-before 'build 'copy-jaxen-sources ;; java-jaxen-bootstrap is not enough. These files have a circular ;; dependency and there is no subset of dom4j that would allow ;; breaking the circle. (lambda* (#:key inputs #:allow-other-keys) (mkdir-p "jaxen-sources") (with-directory-excursion "jaxen-sources" (system* "jar" "xf" (assoc-ref inputs "java-jaxen-sources"))) (mkdir-p "src/main/java/org/jaxen/dom4j") (copy-file "jaxen-sources/org/jaxen/dom4j/DocumentNavigator.java" "src/main/java/org/jaxen/dom4j/DocumentNavigator.java") (copy-file "jaxen-sources/org/jaxen/dom4j/Dom4jXPath.java" "src/main/java/org/jaxen/dom4j/Dom4jXPath.java") #t)) (add-before 'build 'fix-old-xpp2 (lambda _ ;; This package normally depends on xpp2 2.0, but version 2.1.10 ;; is the only version whose source code is published. (substitute* "src/main/java/org/dom4j/xpp/ProxyXmlStartTag.java" (("public void resetStartTag") "public boolean removeAttributeByRawName(String name) {\n return false;\n }\n public boolean removeAttributeByName(String name, String name2) {\n return false;\n }\n\npublic void resetStartTag") (("Atttribute") "Attribute")) #t))))) (inputs `(("java-jaxen-bootstrap" ,java-jaxen-bootstrap) ("java-jaxen-sources" ,(package-source java-jaxen-bootstrap)) ("java-xmlpull2" ,java-xmlpull2) ("java-xpp3" ,java-xpp3) ("java-xsdlib" ,java-xsdlib))) (native-inputs `(("java-testng" ,java-testng) ("java-xerces" ,java-xerces))) (home-page "https://dom4j.github.io/") (synopsis "Flexible XML framework for Java") (description "Dom4j is a flexible XML framework for Java. DOM4J works with DOM, SAX, XPath, and XSLT. It can parse large XML documents with very low memory footprint.") ;; some BSD-like 5-clause license (license (license:non-copyleft "file://LICENSE")))) (define-public java-kxml2 (package (name "java-kxml2") (version "2.4.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/stefanhaustein/kxml2") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0g6d8c9r9sh3x04sf4wdpgwvhkqvk11k3kq9skx91i60h4vn01hg")))) (build-system ant-build-system) (arguments `(#:jar-name "kxml2.jar" #:source-dir "src/main/java" #:test-include (list "TestWb.java") ;; Test failure: it was expected to get an XML entity but got the ;; equivalent Unicode character instead. #:tests? #f #:phases (modify-phases %standard-phases (add-after 'unpack 'make-git-checkout-writable (lambda _ (for-each make-file-writable (find-files ".")) #t)) (add-before 'build 'copy-resources (lambda _ (copy-recursively "src/main/resources" "build/classes") #t))))) (inputs `(("java-xpp3" ,java-xpp3))) (native-inputs `(("java-junit" ,java-junit))) (home-page "http://kxml.org") (synopsis "XML pull parser") (description "kXML is a small XML pull parser, specially designed for constrained environments such as Applets, Personal Java or devices compliant with the Mobile Information Device Profile (MIDP).") (license license:expat))) (define-public java-stax (package (name "java-stax") (version "1.2.0") (source (origin (method url-fetch) (uri (string-append "https://repo1.maven.org/maven2/stax/stax/" version "/stax-" version "-sources.jar")) (sha256 (base32 "04ba4qvbrps45j8bldbakxq31k7gjlsay9pppa9yn13fr00q586z")))) (build-system ant-build-system) (arguments `(#:jar-name "stax.jar" #:tests? #f; no tests #:phases (modify-phases %standard-phases (add-before 'configure 'fix-utf8 (lambda _ ;; This file is ISO-8859-1 but java expects UTF-8. ;; Remove special characters in comments. (with-fluids ((%default-port-encoding "ISO-8859-1")) (substitute* "src/com/wutka/dtd/Scanner.java" (("//.*") "\n"))) #t))))) (home-page "https://repo1.maven.org/maven2/stax/stax/") (synopsis "Streaming API for XML") (description "This package provides the reference implementation of the @dfn{Streaming API for XML} (StAX). It is used for streaming XML data to and from a Java application. It provides a standard pull parser interface.") (license license:asl2.0))) (define-public java-jettison (package (name "java-jettison") (version "1.3.7") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/codehaus/jettison") (commit (string-append "jettison-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "15sydmi5chdh4126qc7v8bsrp7fp4ldaya8a05iby4pq2324q0qw")))) (build-system ant-build-system) (arguments `(#:jar-name "jettison.jar" #:source-dir "src/main/java" #:test-exclude (list "**/Abstract*.java" ;; Abstract classes "**/DOMTest.java" "**/BadgerFishDOMTest.java" "**/MappedDOMTest.java"))) (native-inputs `(("java-junit" ,java-junit))) (home-page "https://github.com/codehaus/jettison") (synopsis "StAX implementation for JSON") (description "Jettison is a Java library for converting XML to JSON and vice-versa with the help of the @dfn{Streaming API for XML} (StAX). It implements @code{XMLStreamWriter} and @code{XMLStreamReader} and supports @code{Mapped} and @code{BadgerFish} conventions.") (license license:asl2.0))) (define-public java-jdom2 (package (name "java-jdom") (version "2.0.6") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/hunterhacker/jdom") (commit (string-append "JDOM-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "14vv1kxrsdvwi4cz3rx6r48w5y6fvk9cymil8qhvxwp56xxrgxiq")))) (build-system ant-build-system) (arguments `(#:build-target "package" #:tests? #f ; tests are run as part of the build process #:phases (modify-phases %standard-phases (replace 'install (install-jars "build"))))) (home-page "http://jdom.org/") (synopsis "Access, manipulate, and output XML data") (description "Jdom is a Java-based solution for accessing, manipulating, and outputting XML data from Java code.") (license license:bsd-4))) (define-public java-xstream (package (name "java-xstream") (version "1.4.16") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/x-stream/xstream") (commit (string-append "XSTREAM_" (string-map (lambda (x) (if (eq? x #\.) #\_ x)) version))))) (file-name (git-file-name name version)) (sha256 (base32 "16k2mc63h2fw7lxv74qmhg4p8q9hfrw114daa6nxwnpv08cnq755")))) (build-system ant-build-system) (arguments `(#:jar-name "xstream.jar" ;; FIXME: Tests are not in a java subdirectory as assumed by ant-build-system. #:tests? #f #:jdk ,icedtea-8 #:source-dir "xstream/src/java")) (inputs `(("java-jdom" ,java-jdom) ("java-jdom2" ,java-jdom2) ("java-cglib" ,java-cglib) ("java-joda-time" ,java-joda-time) ("java-jettison" ,java-jettison) ("java-xom" ,java-xom) ("java-mxparser" ,java-mxparser) ("java-xpp3" ,java-xpp3) ("java-dom4j" ,java-dom4j) ("java-stax2-api" ,java-stax2-api) ("java-woodstox-core" ,java-woodstox-core) ("java-kxml2" ,java-kxml2) ("java-stax" ,java-stax))) (home-page "https://x-stream.github.io") (synopsis "XML serialization library") (description "XStream is a simple library to serialize Java objects to XML and back again.") (license license:bsd-3))) (define-public java-mxparser (package (name "java-mxparser") (version "1.2.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/x-stream/mxparser") (commit (string-append "v-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0i3jrjbz4hgf62fm1ix7nlcmhi4kcv4flqsfvh7a3l2v7nsp5ryb")))) (build-system ant-build-system) (arguments `(#:jar-name "mxparser.jar" #:source-dir "src/main/java" #:test-dir "src/test" #:phases (modify-phases %standard-phases (add-before 'build 'copy-resources (lambda _ (copy-recursively "src/main/resources" "build/classes") #t))))) (propagated-inputs `(("java-xmlpull-api-v1" ,java-xmlpull-api-v1))) (native-inputs `(("java-junit" ,java-junit))) (home-page "https://github.com/x-stream/mxparser") (synopsis "Streaming pull XML parser forked from @code{java-xpp3}") (description "Xml Pull Parser (in short XPP) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements (for example in SOAP processors). This package is a stable XmlPull parsing engine that is based on ideas from XPP and in particular XPP2 but completely revised and rewritten to take the best advantage of JIT JVMs. MXParser is a fork of xpp3_min 1.1.7 containing only the parser with merged changes of the Plexus fork. It is an implementation of the XMLPULL V1 API (parser only).") (license (license:non-copyleft "file://LICENSE.txt")))) (define-public xmlrpc-c (package (name "xmlrpc-c") (version "1.43.08") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/xmlrpc-c/Xmlrpc-c%20Super%20Stable/" version "/xmlrpc-c-" version ".tgz")) (sha256 (base32 "18zwbj6i2hpcn5riiyp8i6rml0sfv60dd7phw1x8g4r4lj2bbxf9")))) (build-system gnu-build-system) (inputs `(("curl" ,curl))) (native-inputs `(;; For tools, if ever needed. ("perl" ,perl))) (arguments `(#:make-flags ; Add $libdir to the RUNPATH of all the executables. (list (string-append "LDFLAGS_PERSONAL=-Wl,-rpath=" %output "/lib")) #:phases (modify-phases %standard-phases (add-after 'unpack 'fix-/bin/sh-in-tests (lambda _ (substitute* "GNUmakefile" (("#! /bin/sh") (which "sh"))) #t))))) (home-page "http://xmlrpc-c.sourceforge.net/") (synopsis "Lightweight RPC library based on XML and HTTP") (description "XML-RPC is a quick-and-easy way to make procedure calls over the Internet. It converts the procedure call into an XML document, sends it to a remote server using HTTP, and gets back the response as XML. This library provides a modular implementation of XML-RPC for C and C++.") (license (list license:psfl license:expat)))) (define-public opensp (package (name "opensp") (version "1.5.2") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/openjade/opensp/" version "/OpenSP-" version ".tar.gz")) (sha256 (base32 "1khpasr6l0a8nfz6kcf3s81vgdab8fm2dj291n5r2s53k228kx2p")))) (outputs '("out" "doc")) (build-system gnu-build-system) (native-inputs `(("docbook-xml" ,docbook-xml-4.1.2) ("docbook-xsl" ,docbook-xsl) ("libxml2" ,libxml2) ;for XML_CATALOG_DIR ("xmlto" ,xmlto) ;; Dependencies to regenerate the 'configure' script. ("autoconf" ,autoconf) ("automake" ,automake) ("gettext" ,gettext-minimal) ("libtool" ,libtool))) (arguments `( ;; Note: we cannot use '--enable-full-doc-build' as this would require ;; Openjade, which in turn requires this package. ;; Skip the tests that are known to fail (see: ;; https://sourceforge.net/p/openjade/mailman/message/6182316/) #:make-flags '("TESTS_THAT_FAIL=") #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-docbook-paths (lambda* (#:key inputs #:allow-other-keys) (let ((xmldoc (string-append (assoc-ref inputs "docbook-xml") "/xml/dtd/docbook")) (xsldoc (string-append (assoc-ref inputs "docbook-xsl") "/xml/xsl/docbook-xsl-" ,(package-version docbook-xsl)))) (substitute* (find-files "docsrc" "\\.xml$") (("/usr/share/sgml/docbook/xml-dtd-4.1.2") xmldoc) (("http://.*/docbookx\\.dtd") (string-append xmldoc "/docbookx.dtd"))) #t))) (add-after 'patch-docbook-paths 'delete-configure ;; The configure script in the release was made with an older ;; Autoconf and lacks support for the `--docdir' option. (lambda _ (delete-file "configure") #t)) (add-after 'delete-configure 'honor-docdir ;; docdir is not honored due to being hardcoded in the various ;; Makefile.am (see: https://sourceforge.net/p/openjade/bugs/147/). (lambda _ (substitute* '("Makefile.am" "doc/Makefile.am" "docsrc/Makefile.am") (("^docdir = .*") "docdir = @docdir@\n")) #t)) (add-after 'delete-configure 'fix-tests-makefile.am ;; Remove the trailing $(SHELL) from the TESTS_ENVIRONMENT variable ;; definition. Otherwise, when targets are built using ;; "$(am__check_pre) $(LOG_DRIVER) [...]", there would be two ;; $(SHELL) expansion which fails the build. (lambda _ (substitute* "tests/Makefile.am" (("^\tOSGMLNORM=`echo osgmlnorm\\|sed '\\$\\(transform\\)'`\\\\") "\tOSGMLNORM=`echo osgmlnorm|sed '$(transform)'`") (("^\t\\$\\(SHELL\\)\n") "")) #t))))) ;; $SGML_CATALOG_FILES lists 'catalog' or 'CATALOG' or '*.cat' files found ;; under the 'sgml' sub-directory of any given package. (native-search-paths (list (search-path-specification (variable "SGML_CATALOG_FILES") (separator ":") (files '("sgml")) (file-pattern "^catalog$|^CATALOG$|^.*\\.cat$") (file-type 'regular)))) (home-page "http://openjade.sourceforge.net/") (synopsis "Suite of SGML/XML processing tools") (description "OpenSP is an object-oriented toolkit for SGML parsing and entity management. It is a fork of James Clark's SP suite. The tools it contains can be used to parse, validate, and normalize SGML and XML files. The central program included in this package is @code{onsgmls}, which replaces @code{sgmls}, @code{ospam}, @code{ospent}, @code{osgmlnorm}, and @code{osx}.") (license ;; expat license with added clause regarding advertising (license:non-copyleft "file://COPYING" "See COPYING in the distribution.")))) (define-public python-elementpath (package (name "python-elementpath") (version "1.4.0") (source (origin (method url-fetch) (uri (pypi-uri "elementpath" version)) (sha256 (base32 "15h7d41v48q31hzjay7qzixdv531hnga3h35hksk7x52pgqcrkz7")))) (build-system python-build-system) (home-page "https://github.com/sissaschool/elementpath") (synopsis "XPath 1.0/2.0 parsers and selectors for ElementTree and lxml") (description "The proposal of this package is to provide XPath 1.0 and 2.0 selectors for Python's ElementTree XML data structures, both for the standard ElementTree library and for the @uref{http://lxml.de, lxml.etree} library. For lxml.etree this package can be useful for providing XPath 2.0 selectors, because lxml.etree already has it's own implementation of XPath 1.0.") (license license:expat))) (define-public python-lxml (package (name "python-lxml") (version "4.4.2") (source (origin (method url-fetch) (uri (pypi-uri "lxml" version)) (sha256 (base32 "01nvb5j8vs9nk4z5s3250b1m22b4d08kffa36if3g1mdygdrvxpg")))) (build-system python-build-system) (arguments `(#:phases (modify-phases %standard-phases (replace 'check (lambda _ (invoke "make" "test")))))) (inputs `(("libxml2" ,libxml2) ("libxslt" ,libxslt))) (home-page "https://lxml.de/") (synopsis "Python XML processing library") (description "The lxml XML toolkit is a Pythonic binding for the C libraries libxml2 and libxslt.") (license license:bsd-3))) ; and a few more, see LICENSES.txt (define-public python2-lxml (package-with-python2 python-lxml)) (define-public python-xmlschema (package (name "python-xmlschema") (version "1.1.2") (source (origin ;; Unit tests are not distributed with the PyPI archive. (method git-fetch) (uri (git-reference (url "https://github.com/sissaschool/xmlschema") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "03bz5mp45y4shmlc1gxq1h69vjx60z1acg9cy4kq7fczgx8qg9jw")))) (build-system python-build-system) (arguments '(#:phases (modify-phases %standard-phases (replace 'check (lambda* (#:key (tests? #t) #:allow-other-keys) (if tests? (begin (setenv "PYTHONPATH" (string-append "./build/lib:" (getenv "PYTHONPATH"))) (invoke "python" "-m" "unittest" "-v")) (format #t "test suite not run~%")) #t))))) (native-inputs `(("python-lxml" ,python-lxml))) ;for tests (propagated-inputs `(("python-elementpath" ,python-elementpath))) (home-page "https://github.com/sissaschool/xmlschema") (synopsis "XML Schema validator and data conversion library") (description "The @code{xmlschema} library is an implementation of @url{https://www.w3.org/2001/XMLSchema, XML Schema} for Python. It has full support for the XSD 1.0 and 1.1 standards, an XPath-based API for finding schema's elements and attributes; and can encode and decode XML data to JSON and other formats.") (license license:expat))) (define-public python-xmltodict (package (name "python-xmltodict") (version "0.12.0") (source (origin (method url-fetch) (uri (pypi-uri "xmltodict" version)) (sha256 (base32 "08cadlb9vsb4pmzc99lz3a2lx6qcfazyvgk10pcqijvyxlwcdn2h")))) (build-system python-build-system) (native-inputs `(("python-coverage" ,python-coverage) ("python-nose" ,python-nose))) (home-page "https://github.com/martinblech/xmltodict") (synopsis "Work with XML like you are working with JSON") (description "This package provides a Python library to convert XML to @code{OrderedDict}.") (license license:expat)))