From 46c665e34e3ec653406570fb77be928a10b01fad Mon Sep 17 00:00:00 2001 From: Eli Kogan-Wang Date: Sat, 9 Sep 2023 13:49:25 +0200 Subject: [PATCH] nix-env to nix profile: maintain priorities --- src/nix/profile.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nix/profile.cc b/src/nix/profile.cc index 324fd6330..cb310156f 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include "strings.hh" @@ -186,6 +187,16 @@ struct ProfileManifest for (auto & packageInfo : packageInfos) { ProfileElement element; element.storePaths = {packageInfo.queryOutPath()}; + Value * priorityV = drvInfo.queryMeta("priority"); + if (priorityV && priorityV->type() == nString) { + auto result = std::from_chars( + priorityV->str().data(), + priorityV->str().data() + priorityV->str().size(), + element.priority); + if (result.ec != std::errc()) { + throw Error("profile manifest '%s' has invalid priority '%s'", manifestPath, priorityV->str()); + } + } addElement(std::move(element)); } }