nix profile history: Show profile date

This commit is contained in:
Eelco Dolstra 2021-09-14 20:47:33 +02:00
parent 4b738fc7a9
commit b41968f15a
2 changed files with 8 additions and 6 deletions

View file

@ -6,10 +6,10 @@ R""(
```console
# nix profile history
Version 508 -> 509:
Version 508 (2020-04-10):
flake:nixpkgs#legacyPackages.x86_64-linux.awscli: ∅ -> 1.17.13
Version 509 -> 510:
Version 509 (2020-05-16) <- 508:
flake:nixpkgs#legacyPackages.x86_64-linux.awscli: 1.17.13 -> 1.18.211
```

View file

@ -12,6 +12,7 @@
#include <nlohmann/json.hpp>
#include <regex>
#include <iomanip>
using namespace nix;
@ -528,10 +529,11 @@ struct CmdProfileHistory : virtual StoreCommand, EvalCommand, MixDefaultProfile
if (!first) std::cout << "\n";
first = false;
if (prevGen)
std::cout << fmt("Version %d -> %d:\n", prevGen->first.number, gen.number);
else
std::cout << fmt("Version %d:\n", gen.number);
std::cout << fmt("Version %s%d" ANSI_NORMAL " (%s)%s:\n",
gen.number == curGen ? ANSI_GREEN : ANSI_BOLD,
gen.number,
std::put_time(std::gmtime(&gen.creationTime), "%Y-%m-%d"),
prevGen ? fmt(" <- %d", prevGen->first.number) : "");
ProfileManifest::printDiff(
prevGen ? prevGen->second : ProfileManifest(),