diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc index a34cfde97..b9caad92d 100644 --- a/src/libexpr/flake/lockfile.cc +++ b/src/libexpr/flake/lockfile.cc @@ -66,8 +66,10 @@ std::shared_ptr LockFile::findInput(const InputPath & path) return pos; } -LockFile::LockFile(const nlohmann::json & json, std::string_view path) +LockFile::LockFile(std::string_view contents, std::string_view path) { + auto json = nlohmann::json::parse(contents); + auto version = json.value("version", 0); if (version < 5 || version > 7) throw Error("lock file '%s' has unsupported version %d", path, version); @@ -116,11 +118,6 @@ LockFile::LockFile(const nlohmann::json & json, std::string_view path) // a bit since we don't need to worry about cycles. } -LockFile::LockFile(std::string_view contents, std::string_view path) - : LockFile(nlohmann::json::parse(contents), path) -{ -} - nlohmann::json LockFile::toJSON() const { nlohmann::json nodes; diff --git a/src/libexpr/flake/lockfile.hh b/src/libexpr/flake/lockfile.hh index d51bdb86d..14210cfc9 100644 --- a/src/libexpr/flake/lockfile.hh +++ b/src/libexpr/flake/lockfile.hh @@ -50,7 +50,6 @@ struct LockFile std::shared_ptr root = std::make_shared(); LockFile() {}; - LockFile(const nlohmann::json & json, std::string_view path); LockFile(std::string_view contents, std::string_view path); nlohmann::json toJSON() const;