Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exportReferencesGraph should build onlydrvs when used with unsafeDiscardOutputsDependency #7339

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/libstore/store-api.cc
Expand Up @@ -814,27 +814,6 @@ StorePathSet Store::exportReferences(const StorePathSet & storePaths, const Stor
computeFSClosure({storePath}, paths);
}

/* If there are derivations in the graph, then include their
outputs as well. This is useful if you want to do things
like passing all build-time dependencies of some path to a
derivation that builds a NixOS DVD image. */
auto paths2 = paths;

for (auto & j : paths2) {
if (j.isDerivation()) {
Derivation drv = derivationFromPath(j);
for (auto & k : drv.outputsAndOptPaths(*this)) {
if (!k.second.second)
/* FIXME: I am confused why we are calling
`computeFSClosure` on the output path, rather than
derivation itself. That doesn't seem right to me, so I
won't try to implemented this for CA derivations. */
throw UnimplementedError("exportReferences on CA derivations is not yet implemented");
computeFSClosure(*k.second.second, paths);
}
}
}

return paths;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/export-graph.nix
Expand Up @@ -26,4 +26,20 @@ rec {
exportReferencesGraph = ["refs" (import ./dependencies.nix).drvPath];
};

foo."bar.buildGraphWithoutOutDeps" = let
dep-a = mkDerivation {
name = "dep-a";
buildCommand = "mkdir $out; echo foo > $out/bar";
};

dep-b = mkDerivation rec {
name = "dep-b";
buildCommand = builtins.unsafeDiscardOutputDependency "mkdir $out; echo ${dep-a.drvPath} > $out/bar";
};
in mkDerivation {
name = "dependencies";
builder = builtins.toFile "build-graph-builder" "${printRefs}";
exportReferencesGraph = ["refs" dep-b.drvPath];
};

}
15 changes: 12 additions & 3 deletions tests/export-graph.sh
Expand Up @@ -4,7 +4,7 @@ clearStore
clearProfiles

checkRef() {
nix-store -q --references $TEST_ROOT/result | grep -q "$1" || fail "missing reference $1"
nix-store -q --references $TEST_ROOT/result | grep -q "$1$" || fail "missing reference $1"
}

# Test the export of the runtime dependency graph.
Expand All @@ -22,9 +22,18 @@ nix-store --gc # should force rebuild of input-1

outPath=$(nix-build ./export-graph.nix -A 'foo."bar.buildGraph"' -o $TEST_ROOT/result)

checkRef input-1
checkRef input-1.drv
checkRef input-2
Comment on lines -25 to -27
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ericson2314 Why had I to remove these two checks? This test should build also outputs even after removing that piece of code, right?

checkRef input-2.drv

for i in $(cat $outPath); do checkRef $i; done

# Test the export of the dependency graph when discarding outputs

nix-store --gc

outPath=$(nix-build ./export-graph.nix -A 'foo."bar.buildGraphWithoutOutDeps"' -o $TEST_ROOT/result)

! [[ $(checkRef "dep-a$") ]]
checkRef "dep-a.drv"
! [[ $(checkRef "dep-b") ]]
checkRef "dep-b.drv"