Use CompressionAlgo enum throughout #15020
Merged
Ericson2314 merged 3 commits intoNixOS:masterfrom Jan 20, 2026
Merged
Conversation
… reality The docs were out of date. Since 8a0c00b Nix supports all compression algorithms exposed by libarchive (if it's built with native support for them). Let's be honest about it in the docs.
Instead of the stringly typed code we should use an enum class, this is
more clear and less error-prone. Also adds settings implementations for
CompressionAlgo and std::optional<CompressionAlgo>. The first is used
for NAR compression, since we never accepted empty strings there:
error: unknown compression method ''
The other one is used for optional .narinfo, .ls, and log/ compression.
Those treated empty strings as compression being disabled. The same exact
semantics is kept.
This has the benefit of improving error messages for incorrect values:
error: option 'compression' has invalid value 'bz'
Did you mean one of br, xz or lz4?
e70285d to
6ba0678
Compare
Ericson2314
reviewed
Jan 20, 2026
| auto info = mkInfo(narHashSink.finish()); | ||
| auto narInfo = make_ref<NarInfo>(info); | ||
| narInfo->compression = config.compression; | ||
| narInfo->compression = config.compression.to_string(); // FIXME: Make NarInfo use CompressionAlgo |
Ericson2314
reviewed
Jan 20, 2026
| { | ||
| std::string url; | ||
| std::string compression; | ||
| std::string compression; // FIXME: Use CompressionAlgo |
Ericson2314
approved these changes
Jan 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Instead of the stringly typed code we should use an enum class, this is
more clear and less error-prone. Also adds settings implementations for
CompressionAlgo and std::optional. The first is used
for NAR compression, since we never accepted empty strings there:
The other one is used for optional .narinfo, .ls, and log/ compression.
Those treated empty strings as compression being disabled. The same exact
semantics is kept.
This has the benefit of improving error messages for incorrect values:
Also updates the documentation of the NAR compression to document that we actually support all algorithms natively supported by libarchive.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.