mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 05:56:03 +01:00
Make getDstStore() a virtual method in StoreCommand
This commit is contained in:
parent
76f75e7691
commit
43ad8c5eb2
6 changed files with 26 additions and 21 deletions
|
|
@ -246,21 +246,17 @@ MixProfile::MixProfile()
|
|||
});
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(
|
||||
const StorePath & storePath,
|
||||
ref<Store> store_)
|
||||
void MixProfile::updateProfile(const StorePath & storePath)
|
||||
{
|
||||
if (!profile) return;
|
||||
auto store = store_.dynamic_pointer_cast<LocalFSStore>();
|
||||
auto store = getDstStore().dynamic_pointer_cast<LocalFSStore>();
|
||||
if (!store) throw Error("'--profile' is not supported for this Nix store");
|
||||
auto profile2 = absPath(*profile);
|
||||
switchLink(profile2,
|
||||
createGeneration(*store, profile2, storePath));
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(
|
||||
const BuiltPaths & buildables,
|
||||
ref<Store> store)
|
||||
void MixProfile::updateProfile(const BuiltPaths & buildables)
|
||||
{
|
||||
if (!profile) return;
|
||||
|
||||
|
|
@ -282,7 +278,7 @@ void MixProfile::updateProfile(
|
|||
if (result.size() != 1)
|
||||
throw UsageError("'--profile' requires that the arguments produce a single store path, but there are %d", result.size());
|
||||
|
||||
updateProfile(result[0], store);
|
||||
updateProfile(result[0]);
|
||||
}
|
||||
|
||||
MixDefaultProfile::MixDefaultProfile()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,20 @@ struct StoreCommand : virtual Command
|
|||
{
|
||||
StoreCommand();
|
||||
void run() override;
|
||||
|
||||
/**
|
||||
* Return the default Nix store.
|
||||
*/
|
||||
ref<Store> getStore();
|
||||
|
||||
/**
|
||||
* Return the destination Nix store.
|
||||
*/
|
||||
virtual ref<Store> getDstStore()
|
||||
{
|
||||
return getStore();
|
||||
}
|
||||
|
||||
virtual ref<Store> createStore();
|
||||
/**
|
||||
* Main entry point, with a `Store` provided
|
||||
|
|
@ -68,7 +81,7 @@ struct CopyCommand : virtual StoreCommand
|
|||
|
||||
ref<Store> createStore() override;
|
||||
|
||||
ref<Store> getDstStore();
|
||||
ref<Store> getDstStore() override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -301,15 +314,11 @@ struct MixProfile : virtual StoreCommand
|
|||
MixProfile();
|
||||
|
||||
/* If 'profile' is set, make it point at 'storePath'. */
|
||||
void updateProfile(
|
||||
const StorePath & storePath,
|
||||
ref<Store> store);
|
||||
void updateProfile(const StorePath & storePath);
|
||||
|
||||
/* If 'profile' is set, make it point at the store path produced
|
||||
by 'buildables'. */
|
||||
void updateProfile(
|
||||
const BuiltPaths & buildables,
|
||||
ref<Store> store);
|
||||
void updateProfile(const BuiltPaths & buildables);
|
||||
};
|
||||
|
||||
struct MixDefaultProfile : MixProfile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue