From e0a0ae0467fa8cdcc542f593b9d94283f04508ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Mar 2020 14:03:28 +0200 Subject: Move fetchers from libstore to libfetchers --- src/libfetchers/tree-info.hh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/libfetchers/tree-info.hh (limited to 'src/libfetchers/tree-info.hh') diff --git a/src/libfetchers/tree-info.hh b/src/libfetchers/tree-info.hh new file mode 100644 index 000000000..02e92759b --- /dev/null +++ b/src/libfetchers/tree-info.hh @@ -0,0 +1,26 @@ +#pragma once + +#include "path.hh" + +namespace nix { class Store; } + +namespace nix::fetchers { + +struct TreeInfo +{ + Hash narHash; + std::optional revCount; + std::optional lastModified; + + bool operator ==(const TreeInfo & other) const + { + return + narHash == other.narHash + && revCount == other.revCount + && lastModified == other.lastModified; + } + + StorePath computeStorePath(Store & store) const; +}; + +} -- cgit v1.2.3 From ed13457dbf1a78f47f760e349985b23dfd5f16c4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 Apr 2020 11:51:34 +0200 Subject: nix flake info --json: Show TreeInfo --- src/libfetchers/tree-info.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libfetchers/tree-info.hh') diff --git a/src/libfetchers/tree-info.hh b/src/libfetchers/tree-info.hh index 02e92759b..25cee445e 100644 --- a/src/libfetchers/tree-info.hh +++ b/src/libfetchers/tree-info.hh @@ -1,6 +1,9 @@ #pragma once #include "path.hh" +#include "hash.hh" + +#include namespace nix { class Store; } @@ -21,6 +24,8 @@ struct TreeInfo } StorePath computeStorePath(Store & store) const; + + nlohmann::json toJson() const; }; } -- cgit v1.2.3 From 6d6467d376ff8ccc758c9fce1fe6d9b658956598 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 2 Apr 2020 18:26:39 +0200 Subject: Move parseTreeInfo() --- src/libfetchers/tree-info.hh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/libfetchers/tree-info.hh') diff --git a/src/libfetchers/tree-info.hh b/src/libfetchers/tree-info.hh index 25cee445e..3b62151c6 100644 --- a/src/libfetchers/tree-info.hh +++ b/src/libfetchers/tree-info.hh @@ -25,6 +25,8 @@ struct TreeInfo StorePath computeStorePath(Store & store) const; + static TreeInfo fromJson(const nlohmann::json & json); + nlohmann::json toJson() const; }; -- cgit v1.2.3 From 950b46821f644eb3f92725460584a3102f356179 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 30 May 2020 00:44:11 +0200 Subject: 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. --- src/libfetchers/tree-info.hh | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/libfetchers/tree-info.hh (limited to 'src/libfetchers/tree-info.hh') diff --git a/src/libfetchers/tree-info.hh b/src/libfetchers/tree-info.hh deleted file mode 100644 index 3b62151c6..000000000 --- a/src/libfetchers/tree-info.hh +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "path.hh" -#include "hash.hh" - -#include - -namespace nix { class Store; } - -namespace nix::fetchers { - -struct TreeInfo -{ - Hash narHash; - std::optional revCount; - std::optional lastModified; - - bool operator ==(const TreeInfo & other) const - { - return - narHash == other.narHash - && revCount == other.revCount - && lastModified == other.lastModified; - } - - StorePath computeStorePath(Store & store) const; - - static TreeInfo fromJson(const nlohmann::json & json); - - nlohmann::json toJson() const; -}; - -} -- cgit v1.2.3