all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: Maxime Devos <maximedevos@telenet.be>, Guix-devel <guix-devel@gnu.org>
Cc: blake@reproduciblemedia.com,
	"Julien Lepiller" <julien@lepiller.eu>,
	Ludovic_Courtès <ludo@gnu.org>,
	"Philip McGrath" <philip@philipmcgrath.com>
Subject: [PATCH] doc: Update contribution guidelines on patches, etc.
Date: Sat, 6 Aug 2022 08:55:03 +0200	[thread overview]
Message-ID: <2fe4881ad87876ae70ef4f3340b34d589a65bb71.camel@gmail.com> (raw)
In-Reply-To: <98da36a2-d0cc-77da-77bf-6984253131ac@telenet.be>

* doc/contributing.texi ("Snippets versus Phases"): Replaced with...
("Modifying Sources"): ... this.  List more use cases and some principles.
---
 doc/contributing.texi | 85 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 72 insertions(+), 13 deletions(-)

diff --git a/doc/contributing.texi b/doc/contributing.texi
index 02c7c5ae59..7a03715abf 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -441,7 +441,7 @@ needed is to review and apply the patch.
 * Package Naming::              What's in a name?
 * Version Numbers::             When the name is not enough.
 * Synopses and Descriptions::   Helping users find the right package.
-* Snippets versus Phases::      Whether to use a snippet, or a build phase.
+* Modifying Sources::           When to use patches, snippets, or build phases.
 * Emacs Packages::              Your Elisp fix.
 * Python Modules::              A touch of British comedy.
 * Perl Modules::                Little pearls.
@@ -698,20 +698,79 @@ Gettext}):
 for the X11 resize-and-rotate (RandR) extension. @dots{}")
 @end lisp
 
-@node Snippets versus Phases
-@subsection Snippets versus Phases
+@node Modifying Sources
+@subsection Modifying Sources
 
+@cindex patches, when to use
 @cindex snippets, when to use
-The boundary between using an origin snippet versus a build phase to
-modify the sources of a package can be elusive.  Origin snippets are
-typically used to remove unwanted files such as bundled libraries,
-nonfree sources, or to apply simple substitutions.  The source derived
-from an origin should produce a source that can be used to build the
-package on any system that the upstream package supports (i.e., act as
-the corresponding source).  In particular, origin snippets must not
-embed store items in the sources; such patching should rather be done
-using build phases.  Refer to the @code{origin} record documentation for
-more information (@pxref{origin Reference}).
+
+Guix has three main ways of modifying the source code of a package,
+that you as a packager may use.  Each one has its strengths and
+drawbacks, along with intended and historically derived use cases.
+These are
+
+@table @asis
+
+@item patches
+If your package has a bug that takes multiple lines to fix, or a fix
+has already been accepted upstream, patches are the preferred way of
+eliminating said bug.  Refer to the @code{origin} record documentation
+(particularly the fields @code{patches}, @code{patch-inputs}, and
+@code{patch-flags}) for more information (@pxref{origin Reference}).
+When adding a patch, do not forget to also list it in
+@code{dist_patch_DATA} of @file{gnu/local.mk}
+
+Patches are limited in that they lack the expressiveness of Guile.
+If all changes are constrained to single lines, a patch might be much
+larger than the equivalent @code{substitute*}.  Furthermore, building
+a package with an additional patch causes two new derivations to be
+built: First the source, then the package.
+
+@item snippets
+If your package contains non-free sources, these need to be removed
+through a snippet.  This snippet should not only remove the sources in
+question, but also references to the removed sources in build scripts,
+documentation, and so on. @ref{Software Freedom}
+
+If your package bundles external libraries, snippets are the preferred
+way of removing said them.  Unlike with non-free sources, it is not a
+requirement to remove @emph{all} bundled libraries, although doing so
+is very much preferred.  Bundled libraries that are kept should be
+clearly indicated, preferrably with a reason as to why the bundled copy
+remains.  As with non-free sources, references to the removed libraries
+should also be updated in the snippet.
+
+Refer to the @code{origin} record documentation
+(particularly the fields @code{snippet} and @code{modules}), for more
+information (@pxref{origin Reference}).
+
+Snippets are limited in that @code{substitute*} can not deal with
+multi-line changes well.  Furthermore, as with patches, modifying the
+snippets causes two derivations to be built.
+
+@item build phases
+For modifications that retain the intended functionality of the
+package, build phases (usually between @code{unpack} and
+@code{configure}, sometimes between @code{configure} and @code{build})
+can be used.  Such changes include, but are not limited to fixes of the
+build script(s) or embeddings of store paths (e.g. replacement of
+@file{/bin/sh} with @code{(search-input-file inputs "bin/sh")}).
+
+If you need to embed a store path, do so only inside a build phase.
+A workaround for patches that span multiple lines, is to use a variable
+such as @code{@@store_path@@} inside the patch and substitute the actual
+store path at build time via @code{substitute*}.
+
+Build phases are limited in that they do not modify the source
+derivation.  Thus, they are inadequate for changes that are to be
+reflected in the source code.  On the other hand, they only cause a
+single rebuild and are thus slightly easier to debug than phases and
+snippets.
+
+@end table
+
+If your change does not neatly fit in any of the categories above, it
+is usually a matter of preference or convenience.
 
 @node Emacs Packages
 @subsection Emacs Packages
-- 
2.37.0



  reply	other threads:[~2022-08-06  7:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  3:17 A proposal of a consistent set of clear rules and guidelines involving snippets, phases and patches Maxime Devos
2022-07-25  5:21 ` Julien Lepiller
2022-07-25 11:18   ` Maxime Devos
2022-07-25 11:37     ` Julien Lepiller
2022-08-04  8:51 ` Ludovic Courtès
2022-08-05  3:23 ` Philip McGrath
2022-08-05  8:13   ` Maxime Devos
2022-08-05  3:38 ` Philip McGrath
2022-08-05  8:09   ` Maxime Devos
2022-08-05 10:18 ` Maxime Devos
2022-08-05 13:59 ` v2: " Maxime Devos
2022-08-06  6:55   ` Liliana Marie Prikler [this message]
2022-08-06  6:55     ` [PATCH v2] doc: Update contribution guidelines on patches, etc Liliana Marie Prikler
2022-09-02 13:12       ` Ludovic Courtès
2022-09-02 18:05         ` Maxime Devos
2022-09-05  9:47           ` Ludovic Courtès
2022-09-05 13:12             ` Maxime Devos
2022-09-05 16:05               ` Maxime Devos
2022-08-09 16:45     ` [PATCH] " Maxime Devos
2022-08-09 17:05       ` Liliana Marie Prikler
2022-08-09 18:19         ` Maxime Devos
2022-08-09 19:08           ` Liliana Marie Prikler
2022-08-09 20:30             ` Maxime Devos
2022-08-10  4:25               ` Liliana Marie Prikler
2022-08-09 20:40             ` Maxime Devos
2022-08-08 21:51   ` v2: A proposal of a consistent set of clear rules and guidelines involving snippets, phases and patches Andreas Enge
2022-08-09 15:06     ` Maxime Devos
2022-08-09 17:10       ` Andreas Enge
2022-09-05 13:03     ` Maxime Devos
2022-09-07 12:17       ` Andreas Enge
2022-09-07 18:08         ` Maxime Devos
2022-08-09 18:58   ` david larsson
2022-08-09 20:53     ` Maxime Devos
2022-08-10 11:23       ` david larsson
2022-08-05 16:59 ` blake
2022-08-09 16:30   ` Maxime Devos
2022-09-05 14:06     ` Maxime Devos
2022-08-10  6:10   ` blake
2022-08-10  9:06     ` Maxime Devos
2022-08-10 10:33     ` blake
2022-08-10 10:44       ` Maxime Devos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fe4881ad87876ae70ef4f3340b34d589a65bb71.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=blake@reproduciblemedia.com \
    --cc=guix-devel@gnu.org \
    --cc=julien@lepiller.eu \
    --cc=ludo@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=philip@philipmcgrath.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.