forked from lix-project/lix
Merge pull request #8631 from iFreilicht/profile-list
Profile list improvements
This commit is contained in:
commit
6db66ebfc5
|
@ -151,7 +151,7 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
|
||||||
},
|
},
|
||||||
ExtraPathInfoFlake::Flake {
|
ExtraPathInfoFlake::Flake {
|
||||||
.originalRef = flakeRef,
|
.originalRef = flakeRef,
|
||||||
.resolvedRef = getLockedFlake()->flake.lockedRef,
|
.lockedRef = getLockedFlake()->flake.lockedRef,
|
||||||
}),
|
}),
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct ExtraPathInfoFlake : ExtraPathInfoValue
|
||||||
*/
|
*/
|
||||||
struct Flake {
|
struct Flake {
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
FlakeRef resolvedRef;
|
FlakeRef lockedRef;
|
||||||
};
|
};
|
||||||
|
|
||||||
Flake flake;
|
Flake flake;
|
||||||
|
|
|
@ -6,26 +6,48 @@ R""(
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# nix profile list
|
# nix profile list
|
||||||
0 flake:nixpkgs#legacyPackages.x86_64-linux.spotify github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.spotify /nix/store/akpdsid105phbbvknjsdh7hl4v3fhjkr-spotify-1.1.46.916.g416cacf1
|
Index: 0
|
||||||
1 flake:nixpkgs#legacyPackages.x86_64-linux.zoom-us github:NixOS/nixpkgs/c23db78bbd474c4d0c5c3c551877523b4a50db06#legacyPackages.x86_64-linux.zoom-us /nix/store/89pmjmbih5qpi7accgacd17ybpgp4xfm-zoom-us-5.4.53350.1027
|
Flake attribute: legacyPackages.x86_64-linux.gdb
|
||||||
2 flake:blender-bin#packages.x86_64-linux.default github:edolstra/nix-warez/d09d7eea893dcb162e89bc67f6dc1ced14abfc27?dir=blender#packages.x86_64-linux.default /nix/store/zfgralhqjnam662kqsgq6isjw8lhrflz-blender-bin-2.91.0
|
Original flake URL: flake:nixpkgs
|
||||||
|
Locked flake URL: github:NixOS/nixpkgs/7b38b03d76ab71bdc8dc325e3f6338d984cc35ca
|
||||||
|
Store paths: /nix/store/indzcw5wvlhx6vwk7k4iq29q15chvr3d-gdb-11.1
|
||||||
|
|
||||||
|
Index: 1
|
||||||
|
Flake attribute: packages.x86_64-linux.default
|
||||||
|
Original flake URL: flake:blender-bin
|
||||||
|
Locked flake URL: github:edolstra/nix-warez/91f2ffee657bf834e4475865ae336e2379282d34?dir=blender
|
||||||
|
Store paths: /nix/store/i798sxl3j40wpdi1rgf391id1b5klw7g-blender-bin-3.1.2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that you can unambiguously rebuild a package from a profile
|
||||||
|
through its locked flake URL and flake attribute, e.g.
|
||||||
|
|
||||||
|
```console
|
||||||
|
# nix build github:edolstra/nix-warez/91f2ffee657bf834e4475865ae336e2379282d34?dir=blender#packages.x86_64-linux.default
|
||||||
|
```
|
||||||
|
|
||||||
|
will build the package with index 1 shown above.
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|
||||||
This command shows what packages are currently installed in a
|
This command shows what packages are currently installed in a
|
||||||
profile. The output consists of one line per package, with the
|
profile. For each installed package, it shows the following
|
||||||
following fields:
|
information:
|
||||||
|
|
||||||
* An integer that can be used to unambiguously identify the package in
|
* `Index`: An integer that can be used to unambiguously identify the
|
||||||
invocations of `nix profile remove` and `nix profile upgrade`.
|
package in invocations of `nix profile remove` and `nix profile
|
||||||
|
upgrade`.
|
||||||
|
|
||||||
* The original ("unlocked") flake reference and output attribute path
|
* `Flake attribute`: The flake output attribute path that provides the
|
||||||
used at installation time.
|
package (e.g. `packages.x86_64-linux.hello`).
|
||||||
|
|
||||||
* The locked flake reference to which the unlocked flake reference was
|
* `Original flake URL`: The original ("unlocked") flake reference
|
||||||
resolved.
|
specified by the user when the package was first installed via `nix
|
||||||
|
profile install`.
|
||||||
|
|
||||||
* The store path(s) of the package.
|
* `Locked flake URL`: The locked flake reference to which the original
|
||||||
|
flake reference was resolved.
|
||||||
|
|
||||||
|
* `Store paths`: The store path(s) of the package.
|
||||||
|
|
||||||
)""
|
)""
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct ProfileElementSource
|
||||||
{
|
{
|
||||||
FlakeRef originalRef;
|
FlakeRef originalRef;
|
||||||
// FIXME: record original attrpath.
|
// FIXME: record original attrpath.
|
||||||
FlakeRef resolvedRef;
|
FlakeRef lockedRef;
|
||||||
std::string attrPath;
|
std::string attrPath;
|
||||||
ExtendedOutputsSpec outputs;
|
ExtendedOutputsSpec outputs;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ struct ProfileManifest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toJSON(Store & store) const
|
nlohmann::json toJSON(Store & store) const
|
||||||
{
|
{
|
||||||
auto array = nlohmann::json::array();
|
auto array = nlohmann::json::array();
|
||||||
for (auto & element : elements) {
|
for (auto & element : elements) {
|
||||||
|
@ -181,7 +181,7 @@ struct ProfileManifest
|
||||||
obj["priority"] = element.priority;
|
obj["priority"] = element.priority;
|
||||||
if (element.source) {
|
if (element.source) {
|
||||||
obj["originalUrl"] = element.source->originalRef.to_string();
|
obj["originalUrl"] = element.source->originalRef.to_string();
|
||||||
obj["url"] = element.source->resolvedRef.to_string();
|
obj["url"] = element.source->lockedRef.to_string();
|
||||||
obj["attrPath"] = element.source->attrPath;
|
obj["attrPath"] = element.source->attrPath;
|
||||||
obj["outputs"] = element.source->outputs;
|
obj["outputs"] = element.source->outputs;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ struct ProfileManifest
|
||||||
nlohmann::json json;
|
nlohmann::json json;
|
||||||
json["version"] = 2;
|
json["version"] = 2;
|
||||||
json["elements"] = array;
|
json["elements"] = array;
|
||||||
return json.dump();
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
StorePath build(ref<Store> store)
|
StorePath build(ref<Store> store)
|
||||||
|
@ -210,7 +210,7 @@ struct ProfileManifest
|
||||||
|
|
||||||
buildProfile(tempDir, std::move(pkgs));
|
buildProfile(tempDir, std::move(pkgs));
|
||||||
|
|
||||||
writeFile(tempDir + "/manifest.json", toJSON(*store));
|
writeFile(tempDir + "/manifest.json", toJSON(*store).dump());
|
||||||
|
|
||||||
/* Add the symlink tree to the store. */
|
/* Add the symlink tree to the store. */
|
||||||
StringSink sink;
|
StringSink sink;
|
||||||
|
@ -349,7 +349,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
|
||||||
if (auto * info2 = dynamic_cast<ExtraPathInfoFlake *>(&*info)) {
|
if (auto * info2 = dynamic_cast<ExtraPathInfoFlake *>(&*info)) {
|
||||||
element.source = ProfileElementSource {
|
element.source = ProfileElementSource {
|
||||||
.originalRef = info2->flake.originalRef,
|
.originalRef = info2->flake.originalRef,
|
||||||
.resolvedRef = info2->flake.resolvedRef,
|
.lockedRef = info2->flake.lockedRef,
|
||||||
.attrPath = info2->value.attrPath,
|
.attrPath = info2->value.attrPath,
|
||||||
.outputs = info2->value.extendedOutputsSpec,
|
.outputs = info2->value.extendedOutputsSpec,
|
||||||
};
|
};
|
||||||
|
@ -588,14 +588,14 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
|
||||||
assert(infop);
|
assert(infop);
|
||||||
auto & info = *infop;
|
auto & info = *infop;
|
||||||
|
|
||||||
if (element.source->resolvedRef == info.flake.resolvedRef) continue;
|
if (element.source->lockedRef == info.flake.lockedRef) continue;
|
||||||
|
|
||||||
printInfo("upgrading '%s' from flake '%s' to '%s'",
|
printInfo("upgrading '%s' from flake '%s' to '%s'",
|
||||||
element.source->attrPath, element.source->resolvedRef, info.flake.resolvedRef);
|
element.source->attrPath, element.source->lockedRef, info.flake.lockedRef);
|
||||||
|
|
||||||
element.source = ProfileElementSource {
|
element.source = ProfileElementSource {
|
||||||
.originalRef = installable->flakeRef,
|
.originalRef = installable->flakeRef,
|
||||||
.resolvedRef = info.flake.resolvedRef,
|
.lockedRef = info.flake.lockedRef,
|
||||||
.attrPath = info.value.attrPath,
|
.attrPath = info.value.attrPath,
|
||||||
.outputs = installable->extendedOutputsSpec,
|
.outputs = installable->extendedOutputsSpec,
|
||||||
};
|
};
|
||||||
|
@ -635,7 +635,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultProfile
|
struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultProfile, MixJSON
|
||||||
{
|
{
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
|
@ -653,12 +653,22 @@ struct CmdProfileList : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
|
||||||
{
|
{
|
||||||
ProfileManifest manifest(*getEvalState(), *profile);
|
ProfileManifest manifest(*getEvalState(), *profile);
|
||||||
|
|
||||||
for (size_t i = 0; i < manifest.elements.size(); ++i) {
|
if (json) {
|
||||||
auto & element(manifest.elements[i]);
|
std::cout << manifest.toJSON(*store).dump() << "\n";
|
||||||
logger->cout("%d %s %s %s", i,
|
} else {
|
||||||
element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath + element.source->outputs.to_string() : "-",
|
for (size_t i = 0; i < manifest.elements.size(); ++i) {
|
||||||
element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath + element.source->outputs.to_string() : "-",
|
auto & element(manifest.elements[i]);
|
||||||
concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
if (i) logger->cout("");
|
||||||
|
logger->cout("Index: " ANSI_BOLD "%s" ANSI_NORMAL "%s",
|
||||||
|
i,
|
||||||
|
element.active ? "" : " " ANSI_RED "(inactive)" ANSI_NORMAL);
|
||||||
|
if (element.source) {
|
||||||
|
logger->cout("Flake attribute: %s%s", element.source->attrPath, element.source->outputs.to_string());
|
||||||
|
logger->cout("Original flake URL: %s", element.source->originalRef.to_string());
|
||||||
|
logger->cout("Locked flake URL: %s", element.source->lockedRef.to_string());
|
||||||
|
}
|
||||||
|
logger->cout("Store paths: %s", concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,8 +47,9 @@ cp ./config.nix $flake1Dir/
|
||||||
|
|
||||||
# Test upgrading from nix-env.
|
# Test upgrading from nix-env.
|
||||||
nix-env -f ./user-envs.nix -i foo-1.0
|
nix-env -f ./user-envs.nix -i foo-1.0
|
||||||
nix profile list | grep '0 - - .*-foo-1.0'
|
nix profile list | grep -A2 'Index:.*0' | grep 'Store paths:.*foo-1.0'
|
||||||
nix profile install $flake1Dir -L
|
nix profile install $flake1Dir -L
|
||||||
|
nix profile list | grep -A4 'Index:.*1' | grep 'Locked flake URL:.*narHash'
|
||||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||||
[ -e $TEST_HOME/.nix-profile/share/man ]
|
[ -e $TEST_HOME/.nix-profile/share/man ]
|
||||||
(! [ -e $TEST_HOME/.nix-profile/include ])
|
(! [ -e $TEST_HOME/.nix-profile/include ])
|
||||||
|
|
Loading…
Reference in a new issue