packaging: Factor out mkPackageBuilder

This commit is contained in:
Robert Hensing 2024-10-13 22:40:09 +02:00
parent 0aef34b790
commit e10ff893e5

View file

@ -38,6 +38,10 @@ let
# Indirection for Nixpkgs to override when package.nix files are vendored # Indirection for Nixpkgs to override when package.nix files are vendored
filesetToSource = lib.fileset.toSource; filesetToSource = lib.fileset.toSource;
/** Given a set of layers, create a mkDerivation-like function */
mkPackageBuilder = exts: userFn:
stdenv.mkDerivation (lib.extends (lib.composeManyExtensions exts) userFn);
localSourceLayer = finalAttrs: prevAttrs: localSourceLayer = finalAttrs: prevAttrs:
let let
workDirPath = workDirPath =
@ -62,7 +66,6 @@ let
mesonLayer = finalAttrs: prevAttrs: mesonLayer = finalAttrs: prevAttrs:
{ {
mesonFlags = prevAttrs.mesonFlags or [];
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.buildPackages.meson pkgs.buildPackages.meson
pkgs.buildPackages.ninja pkgs.buildPackages.ninja
@ -182,15 +185,11 @@ scope: {
inherit resolvePath filesetToSource; inherit resolvePath filesetToSource;
mkMesonDerivation = f: let mkMesonDerivation =
exts = [ mkPackageBuilder [
miscGoodPractice miscGoodPractice
bsdNoLinkAsNeeded bsdNoLinkAsNeeded
localSourceLayer localSourceLayer
mesonLayer mesonLayer
]; ];
in stdenv.mkDerivation
(lib.extends
(lib.composeManyExtensions exts)
f);
} }