1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 15:51:15 +02:00

Add support for brotli compression

Build logs on cache.nixos.org are compressed using Brotli (since this
allows them to be decompressed automatically by Chrome and Firefox),
so it's handy if "nix log" can decompress them.
This commit is contained in:
Eelco Dolstra 2017-03-13 14:40:15 +01:00
parent 73d7a51ee6
commit e8186085e0
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
7 changed files with 38 additions and 5 deletions

View file

@ -89,6 +89,11 @@ static ref<std::string> decompressBzip2(const std::string & in)
}
}
static ref<std::string> decompressBrotli(const std::string & in)
{
return make_ref<std::string>(runProgram(BRO, true, {"-d"}, in));
}
ref<std::string> compress(const std::string & method, const std::string & in)
{
StringSink ssink;
@ -106,6 +111,8 @@ ref<std::string> decompress(const std::string & method, const std::string & in)
return decompressXZ(in);
else if (method == "bzip2")
return decompressBzip2(in);
else if (method == "br")
return decompressBrotli(in);
else
throw UnknownCompressionMethod(format("unknown compression method %s") % method);
}