Skip to content

Add init function for fetchers#5

Open
RossComputerGuy wants to merge 2 commits intointegrationfrom
feat/init-fetchers
Open

Add init function for fetchers#5
RossComputerGuy wants to merge 2 commits intointegrationfrom
feat/init-fetchers

Conversation

@RossComputerGuy
Copy link
Member

@RossComputerGuy RossComputerGuy commented Jan 24, 2026

Depends on https://github.com/DeterminateSystems/nix-src/tree/tristanross/dsp-62-collab-figure-out-static-building-of-determinate-nix

Summary by CodeRabbit

  • Refactor

    • Replace legacy global initialization with the standard library’s thread-safe lazy initialization, improving one-time initialization reliability and thread-safety.
  • Chores

    • Remove the lazy_static dependency across modules.
    • Update the Nix flake input to point to a specific fork/branch.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

📝 Walkthrough

Walkthrough

Replaced lazy_static with std::sync::LazyLock across several nix-bindings crates, added a public init() in nix-bindings-fetchers, and updated flake.nix to point the nix input to a specific fork/branch. Store tests/fixtures adjusted for derivation JSON v4 structure.

Changes

Cohort / File(s) Summary
Manifest removals
\nix-bindings-expr/Cargo.toml`, `nix-bindings-flake/Cargo.toml`, `nix-bindings-store/Cargo.toml``
Removed lazy_static = "1.4" dependency from three crate manifests.
Fetchers init & LazyLock migration
\nix-bindings-fetchers/src/lib.rs``
Added a static INIT: LazyLock<Result<()>>, new public pub fn init() -> Result<()>, and ensured init() is invoked in FetchersSettings::new().
Store LazyLock migration & cache init
\nix-bindings-store/src/store.rs``
Replaced lazy_static statics with LazyLock-backed INIT and STORE_CACHE (closures initialize libstore_init and cache); preserved APIs and cache semantics.
Expr LazyLock migration
\nix-bindings-expr/src/eval_state.rs``
Replaced lazy_static initialization with LazyLock<Result<()>>; moved init logic into LazyLock::new and adjusted imports.
Flake input update
\flake.nix``
Updated nix input URL to github:DeterminateSystems/nix-src/...tristanross/dsp-62-collab-figure-out-static-building-of-determinate-nix.
Store tests/fixture schema update
\nix-bindings-store/src/store.rs` (tests/fixtures)`
Updated derivation JSON schema from v3 to v4 (inputDrvs/inputSrcsinputs.{drvs,srcs}).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cole-h

Poem

🐰 I swapped the statics, soft and quick,
LazyLock now keeps the init slick.
A gentle init() hops into place,
Flake points to a branch with happy grace. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add init function for fetchers' directly aligns with the main change: introducing a new public init() function in nix-bindings-fetchers/src/lib.rs. While the PR also includes refactoring from lazy_static to LazyLock across multiple files, the primary objective is adding the fetchers initialization function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@RossComputerGuy RossComputerGuy force-pushed the feat/init-fetchers branch 3 times, most recently from 58bf429 to 7d6e51e Compare January 24, 2026 04:40
@RossComputerGuy RossComputerGuy marked this pull request as ready for review January 26, 2026 19:04
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
nix-bindings-store/src/store.rs (1)

674-687: Update version gate to 2.33 for v4 JSON test fixtures.
Derivation JSON v4 with the new inputs: { srcs, drvs } shape was introduced in Nix 2.33.0. The current #[cfg(nix_at_least = "2.31")] gating is too permissive—tests emitting v4 JSON will fail on Nix 2.31 and 2.32, which only support v3 (with top-level inputSrcs/inputDrvs). Change the cfg gate to nix_at_least = "2.33" for all v4 JSON fixtures at lines 674-687, 759-783, 837-850, 893-906, 949-962, or provide separate v3-format fixtures for 2.31/2.32 compatibility.

🧹 Nitpick comments (1)
nix-bindings-fetchers/src/lib.rs (1)

37-45: Initialization call is correctly placed.

Calling init()? at the start of new() ensures libfetchers is initialized before settings creation.

Minor style inconsistency: Line 10 uses check_call! (via direct import), while line 41 uses context::check_call!. Consider using consistent macro invocation throughout the file.

♻️ Optional: Consistent macro usage
-        let ptr = unsafe { context::check_call!(raw::fetchers_settings_new(&mut ctx))? };
+        let ptr = unsafe { check_call!(raw::fetchers_settings_new(&mut ctx))? };

@RossComputerGuy RossComputerGuy force-pushed the feat/init-fetchers branch 2 times, most recently from 7ce493e to 0b7880e Compare January 27, 2026 20:18
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nix.url = "github:DeterminateSystems/nix-src";
nix.url = "github:DeterminateSystems/nix-src/tristanross/dsp-62-collab-figure-out-static-building-of-determinate-nix";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR depend on this branch, or were you just playing with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on it for the nix_libfetchers_init function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants