git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #31778 from chris-martin/pr/patch

nixpkgs manual: how to make a patch file with git

commit9ce33dd8fb41ee9fcf0778a094772ebfbb532499 authorGraham Christensen <graham@grahamc.com> dateFri 17 Nov 2017, 22:50 (9 years ago) parent59add31b43c5e0
1 file changed+25−2
doc/coding-conventions.xml+25−2
doc/coding-conventions.xml+25−2
@@ -661,8 +661,6 @@ src = fetchFromGitHub {
661661</section>
662662
663663<section xml:id="sec-patches"><title>Patches</title>
664− <para>Only patches that are unique to <literal>nixpkgs</literal> should be
665− included in <literal>nixpkgs</literal> source.</para>
666664 <para>Patches available online should be retrieved using
667665 <literal>fetchpatch</literal>.</para>
668666 <para>
@@ -676,5 +674,30 @@ patches = [
676674];
677675</programlisting>
678676 </para>
677+ <para>Otherwise, you can add a <literal>.patch</literal> file to the
678+ <literal>nixpkgs</literal> repository. In the interest of keeping our
679+ maintenance burden to a minimum, only patches that are unique
680+ to <literal>nixpkgs</literal> should be added in this way.</para>
681+<para><programlisting>
682+patches = [ ./0001-changes.patch ];
683+</programlisting></para>
684+ <para>If you do need to do create this sort of patch file,
685+ one way to do so is with git:
686+ <orderedlist>
687+ <listitem><para>Move to the root directory of the source code
688+ you're patching.<screen>
689+$ cd the/program/source</screen></para></listitem>
690+ <listitem><para>If a git repository is not already present,
691+ create one and stage all of the source files.<screen>
692+$ git init
693+$ git add .</screen></para></listitem>
694+ <listitem><para>Edit some files to make whatever changes need
695+ to be included in the patch.</para></listitem>
696+ <listitem><para>Use git to create a diff, and pipe the output
697+ to a patch file:<screen>
698+$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch</screen>
699+ </para></listitem>
700+ </orderedlist></para>
679701</section>
702+
680703</chapter>