tvl-depot/tvix/nix-compat/Cargo.toml
Florian Klink e03ea11bad feat(nix-compat/nix_http): init parse_nar[info]_str
This moves the URL component parsing code we had in nar-bridge to
nix-compat.

We change the function signature to return an Option, not a
Result<_, StatusCode>.

This allows returning more appropriate error codes, as we can
ok_or(…) at the callsite, which we now do: on an upload to an
invalid path, we now return "unauthorized", while on a GET/HEAD, we
return "not found".

This also adds support to parse compression suffixes. While not
supported in nar-bridge, other users of nix-compat might very well want
to parse these paths.

Also fix the error message when parsing NAR urls, it mentioned 32, not
52, which is a copypasta error from the narinfo URL parsing code.

Change-Id: Id1be9a8044814b54ce68b125c52dfe933c9c4f74
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12260
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
2024-08-21 09:40:32 +00:00

60 lines
1.3 KiB
TOML

[package]
name = "nix-compat"
version = "0.1.0"
edition = "2021"
[features]
# async NAR writer. Also needs the `wire` feature.
async = ["tokio"]
# code emitting low-level packets used in the daemon protocol.
wire = ["tokio", "pin-project-lite"]
# Enable all features by default.
default = ["async", "wire"]
[dependencies]
bitflags = "2.4.1"
bstr = { version = "1.6.0", features = ["alloc", "unicode", "serde"] }
data-encoding = "2.6.0"
ed25519 = "2.2.3"
ed25519-dalek = "2.1.0"
enum-primitive-derive = "0.3.0"
glob = "0.3.0"
mimalloc = "0.1.43"
nom = "7.1.3"
num-traits = "0.2.18"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sha2 = "0.10.6"
thiserror = "1.0.38"
tracing = "0.1.37"
[dependencies.tokio]
optional = true
version = "1.32.0"
features = ["io-util", "macros"]
[dependencies.pin-project-lite]
optional = true
version = "0.2.13"
[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
futures = { version = "0.3.30", default-features = false, features = ["executor"] }
hex-literal = "0.4.1"
lazy_static = "1.4.0"
mimalloc = "0.1.43"
pretty_assertions = "1.4.0"
rstest = "0.19.0"
serde_json = "1.0"
smol_str = "0.2.2"
tokio-test = "0.4.3"
zstd = "^0.13.0"
[[bench]]
name = "derivation_parse_aterm"
harness = false
[[bench]]
name = "narinfo_parse"
harness = false