mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-29 14:57:28 +03:00
trivial-builders: add the applyPatches function
applyPatches applies a list of patches to a source directory.
For example to patch nixpkgs you can use:
applyPatches {
src = pkgs.path;
patches = [
(pkgs.fetchpatch {
url = "1f770d2055
.patch";
sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
})
];
}
This commit is contained in:
parent
0a8e54d1c6
commit
05393ca217
@ -381,4 +381,37 @@ rec {
|
||||
# Copy a list of paths to the Nix store.
|
||||
copyPathsToStore = builtins.map copyPathToStore;
|
||||
|
||||
/* Applies a list of patches to a source directory.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* # Patching nixpkgs:
|
||||
* applyPatches {
|
||||
* src = pkgs.path;
|
||||
* patches = [
|
||||
* (pkgs.fetchpatch {
|
||||
* url = "https://github.com/NixOS/nixpkgs/commit/1f770d20550a413e508e081ddc08464e9d08ba3d.patch";
|
||||
* sha256 = "1nlzx171y3r3jbk0qhvnl711kmdk57jlq4na8f8bs8wz2pbffymr";
|
||||
* })
|
||||
* ];
|
||||
* }
|
||||
*/
|
||||
applyPatches =
|
||||
{ src
|
||||
, name ? (if builtins.typeOf src == "path"
|
||||
then builtins.baseNameOf src
|
||||
else
|
||||
if builtins.isAttrs src && builtins.hasAttr "name" src
|
||||
then src.name
|
||||
else throw "applyPatches: please supply a `name` argument because a default name can only be computed when the `src` is a path or is an attribute set with a `name` attribute."
|
||||
) + "-patched"
|
||||
, patches ? []
|
||||
, postPatch ? ""
|
||||
}: stdenvNoCC.mkDerivation {
|
||||
inherit name src patches postPatch;
|
||||
preferLocalBuild = true;
|
||||
allowSubstitutes = false;
|
||||
phases = "unpackPhase patchPhase installPhase";
|
||||
installPhase = "cp -R ./ $out";
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user