2020-03-17 21:54:36 +02:00
|
|
|
#pragma once
|
2023-04-01 06:18:41 +03:00
|
|
|
///@file
|
2020-03-17 21:54:36 +02:00
|
|
|
|
|
|
|
#include "types.hh"
|
2023-06-07 15:26:30 +03:00
|
|
|
#include "hash.hh"
|
2020-03-17 21:54:36 +02:00
|
|
|
|
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
|
2021-06-02 13:09:03 +03:00
|
|
|
#include <optional>
|
|
|
|
|
2020-03-17 21:54:36 +02:00
|
|
|
namespace nix::fetchers {
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
typedef std::variant<std::string, uint64_t, Explicit<bool>> Attr;
|
2023-09-29 04:10:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An `Attrs` can be thought of a JSON object restricted or simplified
|
|
|
|
* to be "flat", not containing any subcontainers (arrays or objects)
|
|
|
|
* and also not containing any `null`s.
|
|
|
|
*/
|
2020-03-17 21:54:36 +02:00
|
|
|
typedef std::map<std::string, Attr> Attrs;
|
|
|
|
|
|
|
|
Attrs jsonToAttrs(const nlohmann::json & json);
|
|
|
|
|
2020-10-28 16:41:18 +02:00
|
|
|
nlohmann::json attrsToJSON(const Attrs & attrs);
|
2020-03-17 21:54:36 +02:00
|
|
|
|
|
|
|
std::optional<std::string> maybeGetStrAttr(const Attrs & attrs, const std::string & name);
|
|
|
|
|
|
|
|
std::string getStrAttr(const Attrs & attrs, const std::string & name);
|
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
std::optional<uint64_t> maybeGetIntAttr(const Attrs & attrs, const std::string & name);
|
2020-03-17 21:54:36 +02:00
|
|
|
|
Remove TreeInfo
The attributes previously stored in TreeInfo (narHash, revCount,
lastModified) are now stored in Input. This makes it less arbitrary
what attributes are stored where.
As a result, the lock file format has changed. An entry like
"info": {
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github"
},
is now stored as
"locked": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be",
"type": "github",
"lastModified": 1585405475,
"narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE="
},
The 'Input' class is now a dumb set of attributes. All the fetcher
implementations subclass InputScheme, not Input. This simplifies the
API.
Also, fix substitution of flake inputs. This was broken since lazy
flake fetching started using fetchTree internally.
2020-05-30 01:44:11 +03:00
|
|
|
uint64_t getIntAttr(const Attrs & attrs, const std::string & name);
|
2020-03-17 21:54:36 +02:00
|
|
|
|
2020-03-17 22:34:38 +02:00
|
|
|
std::optional<bool> maybeGetBoolAttr(const Attrs & attrs, const std::string & name);
|
|
|
|
|
|
|
|
bool getBoolAttr(const Attrs & attrs, const std::string & name);
|
|
|
|
|
2020-04-02 15:56:20 +03:00
|
|
|
std::map<std::string, std::string> attrsToQuery(const Attrs & attrs);
|
|
|
|
|
2023-11-29 13:35:08 +02:00
|
|
|
Hash getRevAttr(const Attrs & attrs, const std::string & name);
|
|
|
|
|
2020-03-17 21:54:36 +02:00
|
|
|
}
|