Commit graph

21890 commits

Author SHA1 Message Date
Starnick4444
beca8c8a4c refactor(eval): add get_env to Io trait
Abstracts enviornment access to the IO trait.
It also replaces the unsafe set_var in the test harness.

Change-Id: I3908f2d3cc4392ad2f5bc843c4de63382b692dfd
Reviewed-on: https://cl.snix.dev/c/snix/+/30639
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-08-03 09:49:10 +00:00
Axel Karjalainen
a1b1348979 fix(web/building): mg link
Change-Id: I22ca3d3960d23d5dfc1e20140c28de79896926aa
Reviewed-on: https://cl.snix.dev/c/snix/+/30636
Tested-by: besadii
Autosubmit: Axel Karjalainen <axel@axka.fi>
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-31 21:57:59 +00:00
Florian Klink
fb6d9f5114 chore(3p/nixpkgs): bump channels (2025-07-31)
Change-Id: I1ae84e743281125ecbdc98cdb4f2adf5a96905a7
Reviewed-on: https://cl.snix.dev/c/snix/+/30628
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
2025-07-31 15:56:27 +00:00
Florian Klink
b0edb870ee chore(3p/agenix): bump
This was still using substituteAll, which got removed in the following
nixpkgs bump.

Change-Id: Ia07e2fce8a405973234f2c0d247579f68679446c
Reviewed-on: https://cl.snix.dev/c/snix/+/30629
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
2025-07-31 15:44:56 +00:00
Florian Klink
87411772d7 fix(snix/castore): allow result_large_err for redb create_schema
Passing around boxed errors here would be way more annoying, and we call
this once during database initialization.

Change-Id: I04e65dcc6fbdec591ef553bac9825f51a7d47991
Reviewed-on: https://cl.snix.dev/c/snix/+/30633
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
2025-07-31 15:44:56 +00:00
Florian Klink
c32a23bf63 fix(snix/tracing): fix clippy::result_large_err lint
We still need to unbox before calling ::with_interceptor, the proper fix
will be in https://github.com/hyperium/tonic/issues/2253.

Change-Id: I6de13de79e8ffd9d2f75268b7b232c2f6c91202d
Reviewed-on: https://cl.snix.dev/c/snix/+/30632
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
2025-07-31 15:33:25 +00:00
Florian Klink
74264569ee fix(snix/[ca]store): restore client trace propagation
This broke in cl/11976 and cl/11983, the ::with_interceptor() calls
went missing.

Change-Id: Ic78a88d6c102d79da58fe45d5e595d3879c12af7
Reviewed-on: https://cl.snix.dev/c/snix/+/30631
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
2025-07-31 15:13:22 +00:00
Florian Klink
a9d5c184d5 refactor(snix): address upcoming clippy lints
This uses variables inside `format!()` strings directly,
and switches to using `std::io::Error::other(e.to_string())`
instead of std::io::Error::new(io::ErrorKind::Other, e.to_string()).

It also found an unnecessary `mut` in the test harness.

Change-Id: I406c709091e87ec64bfbdbcdc7f460af9b83d3bc
Reviewed-on: https://cl.snix.dev/c/snix/+/30630
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
2025-07-31 15:01:21 +00:00
Axel Karjalainen
632bc09350 fix(web/about): add missing "reach out" link
Change-Id: I1a7a0ee88a30379b9c4b18ff0a304d5deb3b1648
Reviewed-on: https://cl.snix.dev/c/snix/+/30627
Autosubmit: Axel Karjalainen <axel@axka.fi>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-31 09:12:47 +00:00
Florian Klink
a2ace425cb feat(ops/machines/*01): install kitty terminfo
Change-Id: If9e2ca897e52ae9aa4da033b52dee6f17e66f636
Reviewed-on: https://cl.snix.dev/c/snix/+/30623
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
Tested-by: besadii
2025-07-29 11:47:25 +00:00
Florian Klink
723ef9146b fix(ops/gerrit-webhook-to-irccat): fix json parsing
patchset and change numbers are numbers in the JSON, trying to deserialize them into a string fails:

Jul 28 20:34:03 gerrit01 gerrit-webhook-to-irccat[2430441]: time=2025-07-28T20:34:03.675Z level=WARN msg="failed to parse body" error="json: cannot unmarshal number into Go struct field PatchSet.patchSet.number of type string"

Update our library dependency to a version containing the fixed types.

Also add tests for the three messages we care about.

Change-Id: Iac44e6ad01a8590b4cafa4d301c9f45000f335d0
Reviewed-on: https://cl.snix.dev/c/snix/+/30624
Tested-by: besadii
Reviewed-by: Ryan Lahfa <ryan@lahfa.xyz>
Reviewed-by: Jade Lovelace <jade@lix.systems>
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-29 11:47:24 +00:00
Florian Klink
a1aa231b3f refactor(snix/clippy): stop allowing blocks_in_conditions
This was a workaround, the workaround is not needed anymore.

Change-Id: I4a839f3733ec6cb0a26ba87dadafe304ff5ccfbe
Reviewed-on: https://cl.snix.dev/c/snix/+/30603
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Yureka <snix@yuka.dev>
Tested-by: besadii
2025-07-29 10:19:46 +00:00
Florian Klink
90eabc9ae0 chore(snix): format TOML files
Change-Id: I4c5bf0a378c69a2a22097000583b1abcee089190
Reviewed-on: https://cl.snix.dev/c/snix/+/30602
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Yureka <snix@yuka.dev>
2025-07-29 10:18:46 +00:00
Florian Klink
fa2ea97ef3 refactor(snix/shell): drop josh functionality
Snix is not provided as a josh workspace, this was only the case for
Tvix, while still in the TVL repo, so we can drop that entrypoint.

Change-Id: Iafc2a6520645e607f26bcf674a3d98b646f5c9f2
Reviewed-on: https://cl.snix.dev/c/snix/+/30601
Reviewed-by: Yureka <snix@yuka.dev>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
2025-07-29 10:18:15 +00:00
Jade Lovelace
7bc461b162 feat(snix/shell.nix): automatically set up the commit-msg hook
Lix does this and it has eliminated anyone ever having to think about
it; it just works.

Change-Id: I24a35d2d0b31f1245172d332bac40fe0b39dc2b9
Reviewed-on: https://cl.snix.dev/c/snix/+/30604
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-28 21:37:42 +00:00
Jade Lovelace
be68d89901 fix(ops/gerrit): send mail with the triggering user's name on it
We found this bug in Lix's config and noticed Snix had the same bug; see
4b9e84fa0a
and b47965fe8f.

Change-Id: I65b14839a62c4e779136c1c34750d15cedaaddc8
Reviewed-on: https://cl.snix.dev/c/snix/+/30605
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-28 20:34:03 +00:00
Florian Klink
afec95e269 doc(README): clarify license situation
Also, drop the top-level MIT license file. With this repository
containing mostly Snix, it's confusing.

Change-Id: I1215cf05f6f65b399ff7e8566d425b848fe9ccb0
Reviewed-on: https://cl.snix.dev/c/snix/+/30600
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
Tested-by: besadii
2025-07-07 16:40:46 +00:00
Florian Klink
099f14194b doc(README): point to website once more
There's no point in replicating redundant information in many different
places. Add some more pointers and encouragement to read the docs where
they live.

Change-Id: I449101cfda7c8a728d3e2f3be71dee00be780ec3
Reviewed-on: https://cl.snix.dev/c/snix/+/30599
Tested-by: besadii
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
Autosubmit: Florian Klink <flokli@flokli.de>
2025-07-07 16:40:46 +00:00
Vova Kryachko
9942014989 fix(build/oci): Propagate passAsFile files into the build sandbox.
fixes #87

Change-Id: Ia8109ae678bddb1072e15f6a3ed63e3e3c862b6a
Reviewed-on: https://cl.snix.dev/c/snix/+/30238
Autosubmit: Vova Kryachko <v.kryachko@gmail.com>
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Yureka <snix@yuka.dev>
2025-07-05 14:45:00 +00:00
Starnick4444
e8642518f8 chore(nix-compat): upgrade to 2024 edition
Part of #114
The lock at `nix-compat/src/nix_daemon/handler.rs:186` gets released later, but
this doesnt seem to change behavior.

Change-Id: If871a090791740d98bca7a043e86af6a9b0c5463
Reviewed-on: https://cl.snix.dev/c/snix/+/30590
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-04 18:23:42 +00:00
Starnick4444
f242bc6df8 chore(contrib): upgrade to 2024 edition
Part of #114
This edition change doesn't affect these crates except for formatting.

Change-Id: I441c967b6803f1f839379c2ec13dee3f0958fb05
Reviewed-on: https://cl.snix.dev/c/snix/+/30593
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
2025-07-04 18:19:41 +00:00
Starnick4444
d829261a09 chore(nix-daemon): upgrade to 2024 edition
Part of #114
This edition change doesn't affect this crate except for formatting.

Change-Id: I8e2650f6de776658a14ee5a11bc7a63ad57fae89
Reviewed-on: https://cl.snix.dev/c/snix/+/30591
Reviewed-by: Florian Klink <flokli@flokli.de>
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Tested-by: besadii
2025-07-04 17:17:35 +00:00
Starnick4444
5602582a9e chore(ops): upgrade to 2024 edition
Part of #114

Change-Id: I2aea31c745af5de71e3a6c153e55aae3457c87e5
Reviewed-on: https://cl.snix.dev/c/snix/+/30594
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
2025-07-04 17:15:04 +00:00
Domen Kožar
ba0a01e7aa fix(eval): avoid stat calls in builtins.readDir
Use entry.file_type() instead of entry.metadata().file_type() to avoid
unnecessary stat syscalls. The file_type() method uses the cached d_type
field from the readdir() syscall when available, eliminating the need
for additional filesystem access.

This matches the behavior described in https://github.com/NixOS/nix/pull/13412
where readDir should only read directory entries without stat'ing each file.

Change-Id: I8983f84a7cff28b2c892d5829b9880ed22be4389
Reviewed-on: https://cl.snix.dev/c/snix/+/30596
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
2025-07-04 16:41:14 +00:00
Starnick4444
e9073eeddd chore(nar-bridge): upgrade to 2024 edition
Part of #114
This edition change doesn't affect this crate except for formatting.

Change-Id: Ia7adca8a62e3cb7cbc1187c539907be45a05ab4b
Reviewed-on: https://cl.snix.dev/c/snix/+/30589
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-07-01 09:04:27 +00:00
Vova Kryachko
33cd666f5c feat(glue): Implement hashed_mirrors download logic for fetchurl.
This is useful for the cases when original urls no longer exist, but nixpkgs still references them.

Change-Id: Ibfbb6784876efe4fc8f65fac84ff9dcb72e78ff7
Reviewed-on: https://cl.snix.dev/c/snix/+/30570
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
Autosubmit: Vova Kryachko <v.kryachko@gmail.com>
2025-06-30 14:06:23 +00:00
Florian Klink
3c1a7176cb feat(snix/eval): proper error handling for invalid regexes
We don't want to crash the evaluator when an invalid regex is passed,
but instead display a user-facing error message. This CL does that.

Change-Id: I81fd8e342fc877344f8d2a3704ef53caf5190aa3
Reviewed-on: https://cl.snix.dev/c/snix/+/30588
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
Tested-by: besadii
Reviewed-by: Bence Nemes <nemes.bence1@gmail.com>
2025-06-30 13:50:12 +00:00
Vincent Ambo
4de1129acb refactor(snix/eval): cache regexes for builtins
Some analysing what is going on in nixpkgs revealed that we recompiled the same
regexes many times, and there aren't that many different regexes anyways.

This was actually visible in flamegraphs, now it's not anymore.

Fixes https://git.snix.dev/snix/snix/issues/151

Change-Id: Ia04b1833fec083017aebac99cdae7e91148966c4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13464
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
(cherry picked from commit aa1eca36c3b3c18d96ba3081d7053b4c639e2f17)
Reviewed-on: https://cl.snix.dev/c/snix/+/30587
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Bence Nemes <nemes.bence1@gmail.com>
2025-06-29 19:59:19 +00:00
Florian Klink
51fc9948cf fix(snix/store/redb): no blocking IO in list() without spawn_blocking
All these functions do blocking IO, and don't yield back to the
executor, so we cannot invoke them directly, but have to use
spawn_blocking and a channel.

Instead of plainly reverting cl/30575, this keeps potential errors being
sent as the last element of the stream.

We need to make our error construction a bit more ergonomic, potentially
allow them to wrap other errors instead of the madness this currently
is, but this is something for a later CL.

Change-Id: Ifb05871741813a389ac00b4f2c468f984a689a18
Reviewed-on: https://cl.snix.dev/c/snix/+/30586
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
Tested-by: besadii
2025-06-29 15:35:18 +00:00
Florian Klink
ae2af10cf8 fix(castore/fs): enter the runtime context before blocking on tasks
fuse-backend-rs spawns multiple threads, but these don't automatically
inherit the tokio runtime context.

Spawning tasks from "the wrong thread" would then cause a panic, as seen
in https://git.snix.dev/snix/snix/issues/147.

However, cl/30575 didn't really fix this, it only removed one place
spawning tasks, without fixing the underlying issue.

PathInfoService / BlobService / DirectoryService are expected to spawn
tasks. We need to simply invoke `.enter()` from all worker threads, and
that's what this CL does.

An alternative would be to manually (re)-enter inside every function of
the FileSystem trait, but that'd be very messy.

A similar fix needs to end up in the virtiofs implementation, but we
don't have control over the (single) thread being spawned by
VhostUserDaemon there, so cannot just enter the runtime context there,
so virtiofs will stay broken for now.

Maybe it's time to re-architect this a bit - have our FileSystem impl
be little code and call to sync endpoints to do the actual work, which
is then handled by workers on another thread - but that's left for
another CL.

Change-Id: I58cdbd952f4ecc39bdc2f2fa69a788caa0cc78ba
Reviewed-on: https://cl.snix.dev/c/snix/+/30585
Tested-by: besadii
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
2025-06-29 15:35:18 +00:00
Florian Klink
95fd048e00 fix(castore/fs): fix names
This is snix-castore, not snix-store.

Change-Id: I4c77adbc8c0c7c450075231ae4ef03ddfa0ea81c
Reviewed-on: https://cl.snix.dev/c/snix/+/30584
Tested-by: besadii
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
2025-06-29 15:18:50 +00:00
Florian Klink
fcd43e8bc8 refactor(ops/gerrit-webhook-to-irccat): use streams data types
The types are different for `gerrit stream-events` and webhooks, so
switch to a fork of go-gerrit containing their definitions.

https://github.com/andygrunwald/go-gerrit/pull/189 is the upstream PR.
Change-Id: I24136af2f2cf5655f2a8278632a3b0f52aa6adcc
Reviewed-on: https://cl.snix.dev/c/snix/+/30544
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
2025-06-29 14:05:48 +00:00
Raito Bezarius
abb2daa4ae feat(modules/monorepo-gerrit): 3.11.0 -> 3.12.0
Changelog: https://www.gerritcodereview.com/3.12.html

We are skipping over the 3.11.1, 3.11.2, 3.11.3 minor releases which
remains available.

This bump was already tested on another Gerrit instance.

No manual intervention is required.

Change-Id: Ia3ce1f1cda36abe6da4edd4210260f664f7b3672
Signed-off-by: Raito Bezarius <raito@lix.systems>
Reviewed-on: https://cl.snix.dev/c/snix/+/30576
Autosubmit: Ryan Lahfa <ryan@lahfa.xyz>
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-06-22 17:55:52 +00:00
rszyma
eee3d466ef fix(snix/store): don't spawn tokio tasks in RedbPathInfoService.list
Fixes a panic in `list` impl of PathInfoService for fuse/virtiofs:
```
thread 'vring_worker' panicked at store/src/pathinfoservice/redb.rs:136:9:
there is no reactor running, must be called from the context of a Tokio 1.x runtime
```

Closes #147.

Change-Id: I2bed5157b30fa185276dcaefd35277159a01fe2d
Reviewed-on: https://cl.snix.dev/c/snix/+/30575
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
2025-06-22 12:42:41 +00:00
rszyma
3f5715fdf9 docs(web): remove dead github mirror link
Closes #149.

Change-Id: Id7296d3a436a75c4642c351ae78a69d3fd35b5eb
Reviewed-on: https://cl.snix.dev/c/snix/+/30573
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: rszyma <rszyma.dev@gmail.com>
2025-06-15 16:49:53 +00:00
Yureka
3045c52230 build/oci: look up subgid from username
the subgid maps are not mapped per group, but per user

Change-Id: Iaf367cff159109eefb5ef99d58033082e6151c5d
Reviewed-on: https://cl.snix.dev/c/snix/+/30568
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Vova Kryachko <v.kryachko@gmail.com>
2025-06-12 07:23:13 +00:00
Florian Klink
8502e487c4 docs(nix-compat/derivation/parser): explain why from_algo_and_mode_and_digest lives here
Change-Id: Id11026115a98703ac0e7d27fcb2286e5afe35f4c
Reviewed-on: https://cl.snix.dev/c/snix/+/30566
Reviewed-by: Yureka <snix@yuka.dev>
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
2025-06-11 12:49:26 +00:00
Florian Klink
859faa8eb1 fix(snix/glue): fix Store Path parsing
All outputs constructed by derivation_to_build_request use inputs_dir as
a prefix (so we cannot use StorePath::from_bytes, which only takes
the basename), and they are relative to their root, so we cannot use
StorePath::from_absolute_path either.

Construct the store paths by stripping inputs_dir early (right after
the call to derivation_to_build_request), and use them later.

Change-Id: I3874e11cf21159c05b02314d9baf26cc98ea7956
Reviewed-on: https://cl.snix.dev/c/snix/+/30569
Reviewed-by: Yureka <snix@yuka.dev>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
2025-06-11 12:24:23 +00:00
Vova Kryachko
d741ca4bb1 feat(glue): Add hashed_mirrors support to eval fetcher
This change adds basic scaffolding to allow configuring hashed_mirrors that will be used
by fetchurl to download artifacts by their hash, this is useful in case certain URLs are
no longer available but required to bootstrap nixpkgs stdenv.

These urls will have higher priority than the url specified in fetchurl(and friends) and
will be attempted before falling back to the actual url specified in fetchurl.

Change-Id: I589bdef609075f274cbdf6b26af602cafaa7496a
Reviewed-on: https://cl.snix.dev/c/snix/+/30567
Tested-by: besadii
Reviewed-by: Florian Klink <flokli@flokli.de>
2025-06-11 09:45:16 +00:00
Florian Klink
3c23b323d5 refactor(nix-compat/nixhash/ca_hash): construct algo and digest separately
This is more readable.

Change-Id: I632afc53c3e4b3c07fd913355a02e0fd575f4e02
Reviewed-on: https://cl.snix.dev/c/snix/+/30565
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Tested-by: besadii
2025-06-05 19:46:15 +00:00
Florian Klink
b90da345ab refactor(nix-compat/nixhash/ca_hash): inline algo_str
This is only used in to_nix_nixbase32_string, and in one place in
narinfo2parquet (though it might be sliced wrongly there too).

This is a partial revert of cl/12041, at least for the narinfo2parquet
parts.

Change-Id: Ic8c57373f7ab79043a491267e8484fa8399cea04
Reviewed-on: https://cl.snix.dev/c/snix/+/30564
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
2025-06-05 19:20:12 +00:00
Florian Klink
63036b3c5e refactor(nix-compat/nixhash): drop (encoded) digest length
We use this for both encoded and unencoded strings (and the error
message was missing), so this usize is pointless.

Change-Id: Id2a1000f1b232896605cdd34349ee114a67dc268
Reviewed-on: https://cl.snix.dev/c/snix/+/30563
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
2025-06-04 21:43:08 +00:00
Florian Klink
16136380ec refactor(nix-compat/nixhash): drop NixHashResult type alias
This one is overkill. `NixHashResult<NixHash>` takes exactly as many
characters as `Result<NixHash, Error>`, so removing the type alias
actually removes the total amount of code.

The only external reference to it is somewhere that should probably live
in nixhash::ca_hash.

Change-Id: I0c4a149294d33129a67cb1b699cc8a645c7c18e1
Reviewed-on: https://cl.snix.dev/c/snix/+/30562
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: edef <edef@edef.eu>
2025-06-04 21:42:38 +00:00
Florian Klink
4a63d85b06 feat(nix-compat/nixhash): digest_length is const
Change-Id: I565f70b4dd7d44b176a1d6fe5009fdf5346c5ab6
Reviewed-on: https://cl.snix.dev/c/snix/+/30561
Reviewed-by: edef <edef@edef.eu>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
2025-06-04 21:42:08 +00:00
Florian Klink
2dfbfebb47 test(nix-compat/nixhash): rework NixHash::from_str tests
The test code was way too complicated. We had testcases manually
constructing different NixHash as an input, extracted digest and algo,
then manually encoded them with various encodings, to then compare to
itself.

Instead, write out these different string inputs as explicit testcases.

Change-Id: I2adeedcb9ddc8b3d50f8bdab09a1e95198cda402
Reviewed-on: https://cl.snix.dev/c/snix/+/30560
Reviewed-by: edef <edef@edef.eu>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
2025-06-04 21:38:07 +00:00
Florian Klink
ea861bba67 refactor(snix/glue/fetchers): cleanup
We can reject early if invalid keys are provided in the attrset, no need
to look at values already.

Also, restructure the code parsing and extracting a sha256 by
destructuring the enum, rather than grabbing a slice and trying to
convert to a fixed-size array.

Change-Id: I1bb067133e398626df25b9c1cf99926c6d836a19
Reviewed-on: https://cl.snix.dev/c/snix/+/30559
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: edef <edef@edef.eu>
Tested-by: besadii
2025-06-04 21:29:36 +00:00
Florian Klink
f6c66af33d refactor(nix-compat/nixhash): move from_ and to_ to NixHash struct
It was a bit confusing to construct NixHash, having them as separate
functions in the module itself, rather than in the NixHash impl.

Also the names were very inconsistent.

This renames parsers to `from_$format_$encoding` and format methods to
`to_$format_$encoding`. It also adds / moves around a few docstrings,
explaining the formats and encodings in the struct docstring itself.

from_str is changed to accept Option<HashAlgo>, not Option<&str>, and
the otherwise unused `from_nix_hash_string` is folded into from_str.
We also simply use from_sri in from_str, as the error path there doesn't
allocate anymore.

Similarly, the from_nix_str function was only a helper function used to
parse a subset of the formats supported in the NixHash::from_str method.
We shouldn't be using it outside of there, all usages (only in tests)
have been replaced with NixHash::from_algo_and_digest.

Change-Id: I36128839dbef19c58b55d5dc5817e38e37a483cc
Reviewed-on: https://cl.snix.dev/c/snix/+/30554
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: edef <edef@edef.eu>
Tested-by: besadii
2025-06-04 21:25:57 +00:00
Florian Klink
6c1bfd778e refactor(nix-compat/nixhash): move serde into serde module
Especially the various specific format serializers/deserializers with
used in path_info.rs shouldn't be living there, but in NixHash, so they
can be used by other consumers of the library wanting to restrict to a
certain format.

Change-Id: Id43ba96e3f6ec68999f028854b625d5335d71554
Reviewed-on: https://cl.snix.dev/c/snix/+/30556
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Tested-by: besadii
Autosubmit: Florian Klink <flokli@flokli.de>
2025-06-03 23:25:01 +00:00
Florian Klink
87d80eb1cc refactor(nix-compat/nixhash): absorb to_plain_hex_string
This is only used inside NixHash::to_nix_hex_string().

Change-Id: I7c9c0cd7d4feaa41b0861bb5c0e99a47ec0caac1
Reviewed-on: https://cl.snix.dev/c/snix/+/30555
Autosubmit: Florian Klink <flokli@flokli.de>
Tested-by: besadii
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
2025-06-03 23:19:00 +00:00
Florian Klink
7b6b94c5ca refactor(nix-compat/nixhash): use a bit more map and ok_or_else
This looks more readable like this.

Change-Id: Iaa750fae66c7263612f169405eb7d38fb9541b04
Reviewed-on: https://cl.snix.dev/c/snix/+/30552
Autosubmit: Florian Klink <flokli@flokli.de>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Tested-by: besadii
2025-06-03 20:59:28 +00:00