about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorChris Martin <ch.martin@gmail.com>2017-11-17 17:11:40 -0500
committerGraham Christensen <graham@grahamc.com>2017-11-17 22:53:02 -0500
commit3aa2fa30726bdf56d66684ace6cf67455072f06a (patch)
tree24a87dbdf748cc5519c36bee53ac9510cca12706 /doc
parenta2845aa0327713f5ca1a0631241559fe7950b203 (diff)
nixpkgs manual: how to make a patch file with git
This addresses #31684.

(cherry picked from commit b43c5e016096abd9f5729e3206e183727b961e94)
Diffstat (limited to 'doc')
-rw-r--r--doc/coding-conventions.xml27
1 files changed, 25 insertions, 2 deletions
diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml
index 0776e70f14e10..765fc56c3bb3c 100644
--- a/doc/coding-conventions.xml
+++ b/doc/coding-conventions.xml
@@ -661,8 +661,6 @@ src = fetchFromGitHub {
 </section>
 
 <section xml:id="sec-patches"><title>Patches</title>
-  <para>Only patches that are unique to <literal>nixpkgs</literal> should be
-    included in <literal>nixpkgs</literal> source.</para>
   <para>Patches available online should be retrieved using
     <literal>fetchpatch</literal>.</para>
   <para>
@@ -676,5 +674,30 @@ patches = [
 ];
 </programlisting>
   </para>
+  <para>Otherwise, you can add a <literal>.patch</literal> file to the
+  <literal>nixpkgs</literal> repository. In the interest of keeping our
+  maintenance burden to a minimum, only patches that are unique
+  to <literal>nixpkgs</literal> should be added in this way.</para>
+<para><programlisting>
+patches = [ ./0001-changes.patch ];
+</programlisting></para>
+  <para>If you do need to do create this sort of patch file,
+  one way to do so is with git:
+  <orderedlist>
+    <listitem><para>Move to the root directory of the source code
+    you're patching.<screen>
+$ cd the/program/source</screen></para></listitem>
+    <listitem><para>If a git repository is not already present,
+    create one and stage all of the source files.<screen>
+$ git init
+$ git add .</screen></para></listitem>
+    <listitem><para>Edit some files to make whatever changes need
+    to be included in the patch.</para></listitem>
+    <listitem><para>Use git to create a diff, and pipe the output
+    to a patch file:<screen>
+$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch</screen>
+    </para></listitem>
+  </orderedlist></para>
 </section>
+
 </chapter>