Compare commits

...

3 commits

Author SHA1 Message Date
Maximilian Bosch e92ac734e6
Fix build with latest Lix
Since ca1dc3f70bf98e2424b7b2666ee2180675b67451, the NAR parser has moved
the preallocate & receive steps into the file handle class to remove the
assumption that only one file can be handled at a time.
2024-09-26 13:06:07 +02:00
Maximilian Bosch 62d29dd052
flake.lock: Update
Flake lock file updates:

• Updated input 'lix':
    'git+https://git.lix.systems/lix-project/lix?ref=refs/heads/main&rev=02eb07cfd539c34c080cb1baf042e5e780c1fcc2' (2024-09-01)
  → 'git+https://git.lix.systems/lix-project/lix?ref=refs/heads/main&rev=31954b51367737defbae87fba053b068897416fb' (2024-09-26)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/6e99f2a27d600612004fbd2c3282d614bfee6421' (2024-08-30)
  → 'github:NixOS/nixpkgs/759537f06e6999e141588ff1c9be7f3a5c060106' (2024-09-25)
2024-09-26 13:05:37 +02:00
leo60228 ac37e44982 Merge pull request 'Update Lix; fix build' (#7) from ma27/hydra:lix-update into main
Reviewed-on: lix-project/hydra#7
Reviewed-by: leo60228 <leo@60228.dev>
2024-09-02 22:56:03 +00:00
3 changed files with 42 additions and 39 deletions

2
.envrc
View file

@ -1 +1 @@
use flake
use flake .#clang

View file

@ -48,11 +48,11 @@
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1725228396,
"narHash": "sha256-QBXwqyPuHUKBiuyzHBxqH/MpjPY9DQiY2M81P2t6b/0=",
"lastModified": 1727334821,
"narHash": "sha256-80CJtKmLvPOUnqz9O6rLYUoTHtVXI3KCQ/ahPgpDACA=",
"ref": "refs/heads/main",
"rev": "02eb07cfd539c34c080cb1baf042e5e780c1fcc2",
"revCount": 16214,
"rev": "31954b51367737defbae87fba053b068897416fb",
"revCount": 16258,
"type": "git",
"url": "https://git.lix.systems/lix-project/lix"
},
@ -126,11 +126,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1725001927,
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
"lastModified": 1727264057,
"narHash": "sha256-KQPI8CTTnB9CrJ7LrmLC4VWbKZfljEPBXOFGZFRpxao=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
"rev": "759537f06e6999e141588ff1c9be7f3a5c060106",
"type": "github"
},
"original": {

View file

@ -7,8 +7,38 @@
using namespace nix;
struct Extractor : ParseSink
struct Extractor : NARParseVisitor
{
class MyFileHandle : public FileHandle
{
NarMemberData * memberData;
uint64_t expectedSize;
std::unique_ptr<HashSink> hashSink;
public:
MyFileHandle(NarMemberData * memberData, uint64_t size) : memberData(memberData)
{
expectedSize = size;
hashSink = std::make_unique<HashSink>(HashType::SHA256);
}
void receiveContents(std::string_view data) override
{
*memberData->fileSize += data.size();
(*hashSink)(data);
if (memberData->contents) {
memberData->contents->append(data);
}
assert(memberData->fileSize <= expectedSize);
if (memberData->fileSize == expectedSize) {
auto [hash, len] = hashSink->finish();
assert(memberData->fileSize == len);
memberData->sha256 = hash;
hashSink.reset();
}
}
};
std::unordered_set<Path> filesToKeep {
"/nix-support/hydra-build-products",
"/nix-support/hydra-release-name",
@ -16,7 +46,6 @@ struct Extractor : ParseSink
};
NarMemberDatas & members;
NarMemberData * curMember = nullptr;
Path prefix;
Extractor(NarMemberDatas & members, Path prefix)
@ -28,41 +57,15 @@ struct Extractor : ParseSink
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
}
void createRegularFile(const Path & path) override
std::unique_ptr<FileHandle> createRegularFile(const Path & path, uint64_t size, bool executable) override
{
curMember = &members.insert_or_assign(prefix + path, NarMemberData {
auto memberData = &members.insert_or_assign(prefix + path, NarMemberData {
.type = FSAccessor::Type::tRegular,
.fileSize = 0,
.contents = filesToKeep.count(path) ? std::optional("") : std::nullopt,
}).first->second;
}
std::optional<uint64_t> expectedSize;
std::unique_ptr<HashSink> hashSink;
void preallocateContents(uint64_t size) override
{
expectedSize = size;
hashSink = std::make_unique<HashSink>(HashType::SHA256);
}
void receiveContents(std::string_view data) override
{
assert(expectedSize);
assert(curMember);
assert(hashSink);
*curMember->fileSize += data.size();
(*hashSink)(data);
if (curMember->contents) {
curMember->contents->append(data);
}
assert(curMember->fileSize <= expectedSize);
if (curMember->fileSize == expectedSize) {
auto [hash, len] = hashSink->finish();
assert(curMember->fileSize == len);
curMember->sha256 = hash;
hashSink.reset();
}
return std::unique_ptr<MyFileHandle>(new MyFileHandle{memberData, size});
}
void createSymlink(const Path & path, const std::string & target) override