Add resolvePath, filesetToSource indirections for Nixpkgs

This commit is contained in:
Robert Hensing 2024-07-06 17:49:58 +02:00
parent 0729f0a113
commit bea54d116e
5 changed files with 18 additions and 5 deletions

View File

@ -14,9 +14,16 @@
let let
inherit (pkgs) lib; inherit (pkgs) lib;
root = ../.;
# Nixpkgs implements this by returning a subpath into the fetched Nix sources.
resolvePath = p: p;
# Indirection for Nixpkgs to override when package.nix files are vendored
filesetToSource = lib.fileset.toSource;
localSourceLayer = finalAttrs: prevAttrs: localSourceLayer = finalAttrs: prevAttrs:
let let
root = ../.;
workDirPath = workDirPath =
# Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has # Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has
# the requirement that everything except passthru and meta must be # the requirement that everything except passthru and meta must be
@ -104,5 +111,7 @@ scope: {
meta.platforms = lib.platforms.all; meta.platforms = lib.platforms.all;
}); });
inherit resolvePath filesetToSource;
mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f); mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f);
} }

View File

@ -18,6 +18,7 @@
# Configuration Options # Configuration Options
, version , version
, resolvePath
}: }:
let let
@ -84,7 +85,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' } ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-expr-tests nix-expr-tests
touch $out touch $out
''; '';

View File

@ -17,6 +17,7 @@
# Configuration Options # Configuration Options
, version , version
, resolvePath
}: }:
let let
@ -82,7 +83,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' } ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-fetchers-tests nix-fetchers-tests
touch $out touch $out
''; '';

View File

@ -17,6 +17,7 @@
# Configuration Options # Configuration Options
, version , version
, resolvePath
}: }:
let let
@ -82,7 +83,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" { run = runCommand "${finalAttrs.pname}-run" {
} '' } ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH" PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data} export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-flake-tests nix-flake-tests
touch $out touch $out
''; '';

View File

@ -19,6 +19,7 @@
# Configuration Options # Configuration Options
, version , version
, filesetToSource
}: }:
let let
@ -86,7 +87,7 @@ mkMesonDerivation (finalAttrs: {
run = let run = let
# Some data is shared with the functional tests: they create it, # Some data is shared with the functional tests: they create it,
# we consume it. # we consume it.
data = lib.fileset.toSource { data = filesetToSource {
root = ../..; root = ../..;
fileset = lib.fileset.unions [ fileset = lib.fileset.unions [
./data ./data