1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 10:50:24 -04:00

Add mkMesonPackage for local meson packages

This helper makes it easy to use filesets that include files from
parent directories, which we'll need more of in
https://github.com/NixOS/nix/pull/10973
This commit is contained in:
Robert Hensing 2024-06-29 19:28:09 +02:00
parent 5a16bf86c5
commit e084316130

View file

@ -10,6 +10,33 @@
stdenv, stdenv,
versionSuffix, versionSuffix,
}: }:
let
inherit (pkgs) lib;
localSourceLayer = finalAttrs: prevAttrs:
let
root = ../.;
workDirPath =
# Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has
# the requirement that everything except passthru and meta must be
# serialized by mkDerivation, which doesn't work for this.
prevAttrs.workDir;
workDirSubpath = lib.path.removePrefix root workDirPath;
sources = assert prevAttrs.fileset._type == "fileset"; prevAttrs.fileset;
src = lib.fileset.toSource { fileset = sources; inherit root; };
in
{
sourceRoot = "${src.name}/" + workDirSubpath;
inherit src;
# Clear what `derivation` can't/shouldn't serialize; see prevAttrs.workDir.
fileset = null;
workDir = null;
};
in
scope: { scope: {
inherit stdenv versionSuffix; inherit stdenv versionSuffix;
@ -55,4 +82,6 @@ scope: {
CONFIG_ASH_TEST y CONFIG_ASH_TEST y
''; '';
}); });
mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f);
} }