Skip to content

Commit

Permalink
Add resolvePath, filesetToSource indirections for Nixpkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth committed Jul 6, 2024
1 parent 0729f0a commit bea54d1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
11 changes: 10 additions & 1 deletion packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
let
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:
let
root = ../.;
workDirPath =
# Ideally we'd pick finalAttrs.workDir, but for now `mkDerivation` has
# the requirement that everything except passthru and meta must be
Expand Down Expand Up @@ -104,5 +111,7 @@ scope: {
meta.platforms = lib.platforms.all;
});

inherit resolvePath filesetToSource;

mkMesonDerivation = f: stdenv.mkDerivation (lib.extends localSourceLayer f);
}
3 changes: 2 additions & 1 deletion tests/unit/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# Configuration Options

, version
, resolvePath
}:

let
Expand Down Expand Up @@ -84,7 +85,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-expr-tests
touch $out
'';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/libfetchers/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Configuration Options

, version
, resolvePath
}:

let
Expand Down Expand Up @@ -82,7 +83,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-fetchers-tests
touch $out
'';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/libflake/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Configuration Options

, version
, resolvePath
}:

let
Expand Down Expand Up @@ -82,7 +83,7 @@ mkMesonDerivation (finalAttrs: {
run = runCommand "${finalAttrs.pname}-run" {
} ''
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
export _NIX_TEST_UNIT_DATA=${./data}
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
nix-flake-tests
touch $out
'';
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/libstore/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Configuration Options

, version
, filesetToSource
}:

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

0 comments on commit bea54d1

Please sign in to comment.