Nixpkgs/Patching Nixpkgs: Difference between revisions
m More indenting tweaks |
Add more versatile way of using applyPatches. |
||
| (One intermediate revision by one other user not shown) | |||
| Line 16: | Line 16: | ||
<syntaxHighlight lang=nix> | <syntaxHighlight lang=nix> | ||
inputs = { | inputs = { | ||
# ... | |||
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; | |||
# ... | |||
}; | }; | ||
</syntaxHighlight> | </syntaxHighlight> | ||
| Line 28: | Line 28: | ||
redirect to https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/344917.patch. We can use the latter. | redirect to https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/344917.patch. We can use the latter. | ||
< | <syntaxhighlight lang="nix"> | ||
let | |||
nixpkgs-unstable' = | |||
((import nixpkgs-unstable { | |||
system = "x86_64-linux"; | |||
}).applyPatches | |||
{ | |||
name = "nixpkgs-unstable-patched"; | |||
src = inputs.nixpkgs-unstable; | |||
patches = [ | |||
(builtins.fetchurl { | |||
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/344917.patch"; | |||
sha256 = "sha256-aws9J5ZNUyz4Z2RqPVEovBTNng4AdhzS03Bqg8jejWQ="; | |||
}) | |||
]; | |||
}).src; | |||
patched-lib = nixpkgs-unstable'.lib; | |||
pkgs-unstable = import nixpkgs-unstable' { | |||
system = "x86_64-linux"; | |||
}; | |||
</ | # ... | ||
</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-unstable'</code>. Pay attention we take the <code>src</code> attribute to get back the top-level nixpkgs. We can then access <code>lib</code> functions normally. We then import that new | ||
derivation which we assign to <code>pkgs-unstable</code>. Now we can use <code>pkgs-unstable</code> to access the | derivation which we assign to <code>pkgs-unstable</code>. Now we can use <code>pkgs-unstable</code> to access the | ||
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 59: | ||
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>] | |||