Nixpkgs/Patching Nixpkgs: Difference between revisions
m More indenting tweaks |
replace importing nixpkgs: https://discourse.nixos.org/t/1000-instances-of-nixpkgs/17347 with existing NixOS module param `pkgs`, and replace fetchurl with fetchpatch2 that will do normalization on generated patch |
||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 12: | Line 12: | ||
First you will need to apply the Nixpkgs PR patch to some copy of Nixpkgs. In this example we will assume a | First you will need to apply the Nixpkgs PR patch to some copy of Nixpkgs. In this example we will assume a NixOS modules has parameter <code>pkgs</code> pointing to <code>nixos-unstable</code>. | ||
We will use the [https://noogle.dev/f/pkgs/applyPatches <code>applyPatches</code>] function to apply the unmerged PR changes to | We will use the [https://noogle.dev/f/pkgs/applyPatches <code>applyPatches</code>] function to apply the unmerged PR changes to | ||
<code>nixpkgs-unstable</code>. First we need to covert the PR to a patch, which can be done by appending | <code>nixpkgs-unstable</code>. First we need to covert the PR to a patch, which can be done by appending | ||
<code>.patch</code> to the github PR | <code>.patch</code> to the github PR | ||
url. This will redirect to another link, for example https://github.com/NixOS/nixpkgs/pull/344917.patch will | url. This will redirect to another link, for example https://github.com/NixOS/nixpkgs/pull/344917.patch will | ||
redirect to https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/344917.patch. | redirect to https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/344917.patch. Then we can use <code>[https://nixos.org/manual/nixpkgs/stable/#fetchpatch fetchpatch]</code> or <code>[https://noogle.dev/f/pkgs/fetchpatch2 fetchpatch2]</code> to normalize this patch that generated by GitHub: | ||
<syntaxhighlight lang="nix"> | |||
{ pkgs, ... }: | |||
let | |||
nixpkgs-344917-drv = | |||
pkgs.applyPatches { | |||
src = pkgs.path; | |||
patches = [ | |||
(pkgs.fetchpatch2 { | |||
url = "https://github.com/NixOS/nixpkgs/pull/344917.patch"; | |||
sha256 = "sha256-aws9J5ZNUyz4Z2RqPVEovBTNng4AdhzS03Bqg8jejWQ="; | |||
}) | |||
]; | |||
}; | |||
nixpkgs-344917 = import nixpkgs-344917-drv { inherit (pkgs.stdenv) system; }; | |||
in | |||
# ... | |||
</syntaxhighlight> | |||
</ | |||
In the above example we create a derivation with the patch applied, called <code> | In the above example we create a derivation with the patch applied, called <code>nixpkgs-344917-drv</code>. Pay attention we take the <code>src</code> attribute to get back the original (unpatched) nixpkgs. We then import that new derivation which we assign to <code>nixpkgs-344917</code>. Now we can use <code>nixpkgs-344917</code> to access the | ||
derivation which we assign to <code> | |||
Ghidra 11.2 package, as well as any other packages normally available in nixpkgs. | Ghidra 11.2 package, as well as any other packages normally available in nixpkgs. | ||
| Line 58: | Line 45: | ||
The following are resources that go into more depth on this topic. | The following are resources that go into more depth on this topic. | ||
* [https://ertt.ca/nix/patch-nixpkgs/ Patching <nixpkgs>] | |||