Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ec613603ba32^
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21050846457f
Choose a head ref
  • 2 commits
  • 12 files changed
  • 1 contributor

Commits on May 12, 2021

  1. DerivedPathWithHints -> BuiltPath

    Just a renaming for now
    thufschmitt committed May 12, 2021
    Copy the full SHA
    ec61360 View commit details

Commits on May 17, 2021

  1. Enfore the use of properly built paths in libcmd

    Replace `DerivedPathWithHints` by a new `BuiltPath` type that serves as
    a proof that the corresponding path has been built.
    thufschmitt committed May 17, 2021
    Copy the full SHA
    2105084 View commit details
Showing with 212 additions and 167 deletions.
  1. +24 −21 src/libcmd/command.cc
  2. +9 −9 src/libcmd/command.hh
  3. +78 −75 src/libcmd/installables.cc
  4. +3 −3 src/libcmd/installables.hh
  5. +45 −4 src/libstore/derived-path.cc
  6. +18 −24 src/libstore/derived-path.hh
  7. +2 −2 src/nix/build.cc
  8. +13 −7 src/nix/copy.cc
  9. +4 −13 src/nix/develop.cc
  10. +3 −3 src/nix/log.cc
  11. +2 −2 src/nix/profile.cc
  12. +11 −4 src/nix/realisation.cc
45 changes: 24 additions & 21 deletions src/libcmd/command.cc
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ void StoreCommand::run()
run(getStore());
}

RealisedPathsCommand::RealisedPathsCommand(bool recursive)
BuiltPathsCommand::BuiltPathsCommand(bool recursive)
: recursive(recursive)
{
if (recursive)
@@ -81,39 +81,45 @@ RealisedPathsCommand::RealisedPathsCommand(bool recursive)
});
}

void RealisedPathsCommand::run(ref<Store> store)
void BuiltPathsCommand::run(ref<Store> store)
{
std::vector<RealisedPath> paths;
BuiltPaths paths;
if (all) {
if (installables.size())
throw UsageError("'--all' does not expect arguments");
// XXX: Only uses opaque paths, ignores all the realisations
for (auto & p : store->queryAllValidPaths())
paths.push_back(p);
paths.push_back(BuiltPath::Opaque{p});
} else {
auto pathSet = toRealisedPaths(store, realiseMode, operateOn, installables);
paths = toBuiltPaths(store, realiseMode, operateOn, installables);
if (recursive) {
auto roots = std::move(pathSet);
pathSet = {};
RealisedPath::closure(*store, roots, pathSet);
// XXX: This only computes the store path closure, ignoring
// intermediate realisations
StorePathSet pathsRoots, pathsClosure;
for (auto & root: paths) {
auto rootFromThis = root.outPaths();
pathsRoots.insert(rootFromThis.begin(), rootFromThis.end());
}
store->computeFSClosure(pathsRoots, pathsClosure);
for (auto & path : pathsClosure)
paths.push_back(BuiltPath::Opaque{path});
}
for (auto & path : pathSet)
paths.push_back(path);
}

run(store, std::move(paths));
}

StorePathsCommand::StorePathsCommand(bool recursive)
: RealisedPathsCommand(recursive)
: BuiltPathsCommand(recursive)
{
}

void StorePathsCommand::run(ref<Store> store, std::vector<RealisedPath> paths)
void StorePathsCommand::run(ref<Store> store, BuiltPaths paths)
{
StorePaths storePaths;
for (auto & p : paths)
storePaths.push_back(p.path());
for (auto& builtPath : paths)
for (auto& p : builtPath.outPaths())
storePaths.push_back(p);

run(store, std::move(storePaths));
}
@@ -162,23 +168,20 @@ void MixProfile::updateProfile(const StorePath & storePath)
profile2, storePath));
}

void MixProfile::updateProfile(const DerivedPathsWithHints & buildables)
void MixProfile::updateProfile(const BuiltPaths & buildables)
{
if (!profile) return;

std::vector<StorePath> result;

for (auto & buildable : buildables) {
std::visit(overloaded {
[&](DerivedPathWithHints::Opaque bo) {
[&](BuiltPath::Opaque bo) {
result.push_back(bo.path);
},
[&](DerivedPathWithHints::Built bfd) {
[&](BuiltPath::Built bfd) {
for (auto & output : bfd.outputs) {
/* Output path should be known because we just tried to
build it. */
assert(output.second);
result.push_back(*output.second);
result.push_back(output.second);
}
},
}, buildable.raw());
18 changes: 9 additions & 9 deletions src/libcmd/command.hh
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ private:
};

/* A command that operates on zero or more store paths. */
struct RealisedPathsCommand : public InstallablesCommand
struct BuiltPathsCommand : public InstallablesCommand
{
private:

@@ -156,26 +156,26 @@ protected:

public:

RealisedPathsCommand(bool recursive = false);
BuiltPathsCommand(bool recursive = false);

using StoreCommand::run;

virtual void run(ref<Store> store, std::vector<RealisedPath> paths) = 0;
virtual void run(ref<Store> store, BuiltPaths paths) = 0;

void run(ref<Store> store) override;

bool useDefaultInstallables() override { return !all; }
};

struct StorePathsCommand : public RealisedPathsCommand
struct StorePathsCommand : public BuiltPathsCommand
{
StorePathsCommand(bool recursive = false);

using RealisedPathsCommand::run;
using BuiltPathsCommand::run;

virtual void run(ref<Store> store, std::vector<StorePath> storePaths) = 0;

void run(ref<Store> store, std::vector<RealisedPath> paths) override;
void run(ref<Store> store, BuiltPaths paths) override;
};

/* A command that operates on exactly one store path. */
@@ -216,7 +216,7 @@ static RegisterCommand registerCommand2(std::vector<std::string> && name)
return RegisterCommand(std::move(name), [](){ return make_ref<T>(); });
}

DerivedPathsWithHints build(ref<Store> store, Realise mode,
BuiltPaths build(ref<Store> store, Realise mode,
std::vector<std::shared_ptr<Installable>> installables, BuildMode bMode = bmNormal);

std::set<StorePath> toStorePaths(ref<Store> store,
@@ -231,7 +231,7 @@ std::set<StorePath> toDerivations(ref<Store> store,
std::vector<std::shared_ptr<Installable>> installables,
bool useDeriver = false);

std::set<RealisedPath> toRealisedPaths(
BuiltPaths toBuiltPaths(
ref<Store> store,
Realise mode,
OperateOn operateOn,
@@ -252,7 +252,7 @@ struct MixProfile : virtual StoreCommand

/* If 'profile' is set, make it point at the store path produced
by 'buildables'. */
void updateProfile(const DerivedPathsWithHints & buildables);
void updateProfile(const BuiltPaths & buildables);
};

struct MixDefaultProfile : MixProfile
Loading