Skip to content

flakeref: parse and render sourcehut references - #688

Queued
Mic92 wants to merge 1 commit into
mainfrom
flakeref-sourcehut
Queued

Mic92 wants to merge 1 commit into
mainfrom
flakeref-sourcehut

Conversation

@Mic92

@Mic92 Mic92 commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

builtins.parseFlakeRef "sourcehut:~a/b" and builtins.flakeRefToString { type = "sourcehut"; … } failed with "not supported", although fetchTree already fetches sourcehut inputs. Nix parses the scheme with the same code as github: and gitlab:, and iets now does the same.

  • The expected output of the new lang test comes from Nix 2.34.9.
  • An unlocked sourcehut input in pure mode now fails with Nix's message, which names the reference.
  • On the command line a sourcehut: flake is still unsupported, like every remote root flake, and classic mode still falls back to Nix.

Found with nix-pbt (#685), where this case stopped three of the five flakeref properties.

Summary by CodeRabbit

  • New Features
    • SourceHut flake references can now be parsed and formatted, including references with revisions, refs, directories, custom hosts, and supported query attributes.
  • Bug Fixes
    • Unlocked SourceHut inputs with a NAR hash now appear in pure-evaluation error messages in the same format as other unlocked inputs.
  • Documentation
    • Updated flake-reference documentation to clarify SourceHut support and when classic mode falls back to Nix.

builtins.parseFlakeRef and builtins.flakeRefToString refused
`sourcehut:~owner/repo` as an unsupported scheme, although fetchTree
already fetches the type. Nix handles it with the same code as github
and gitlab, so iets now does too.

An unlocked sourcehut input in pure mode now fails with Nix's message,
which names the reference.

Found with nix-pbt.

Change-Id: If59b717fb526bf16b1f7dd14f0c6484de3d56f0a
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds Sourcehut references to flake-reference parsing and rendering. It updates pure-evaluation error formatting for unlocked Sourcehut inputs and revises documentation about supported schemes and fallback cases.

Changes: Sourcehut flake-reference support

Layer / File(s) Summary
Parse, render, and document Sourcehut references
src/flake/flakeref.rs, tests/lang/eval-okay-parse-flake-ref-sourcehut.*, docs/reference/*.md
Parsing and serialization now support Sourcehut references, including refs, revisions, directories, custom hosts, and query attributes. Tests cover parsed and displayed references. Documentation lists sourcehut: as parsed and rendered rather than unsupported.
Format unlocked Sourcehut input errors
src/builtins/fetch.rs, src/eval/tests.rs
Unlocked Sourcehut inputs with a narHash are included in the attributes rendered in the pure-evaluation refusal message. The test expects the unlocked-input error naming sourcehut:o/r.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant NixFixture
  participant ParseFlakeRef
  participant FlakeRefModule
  participant FlakeRefToString
  NixFixture->>ParseFlakeRef: Sourcehut reference
  ParseFlakeRef->>FlakeRefModule: Parse URL
  FlakeRefModule-->>ParseFlakeRef: Parsed attributes
  ParseFlakeRef-->>NixFixture: Parsed reference
  NixFixture->>FlakeRefToString: Sourcehut attributes
  FlakeRefToString->>FlakeRefModule: Serialize attributes
  FlakeRefModule-->>NixFixture: Displayed reference
Loading

Suggested reviewers: zimbatm, rszyma, connorbaker

Merge Risk: Minimal · up to 2837e

This adds sourcehut: support to flake-reference parsing and rendering and makes the pure-mode error for unlocked inputs match Nix. Remote sourcehut: root flakes stay unsupported and still fall back to Nix in classic mode. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "flakeref: parse and render sourcehut references" matches the main change. The flakeref module now parses and renders sourcehut: references, and the builtins parseFlakeRef and flakeRefToStri…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "flakeref: parse and render sourcehut references" matches the main change. The flakeref module now parses and renders sourcehut: references, and the builtins parseFlakeRef and flakeRefToString accept them. The title is specific, short, and follows the repository's module-prefix style. The changes to pure-mode error text and docs support the same core change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 05f8ebe0-a856-48b1-ae31-7e4054512ab1
Commits

Reviewing files that changed from the base of the PR and between 0bf3082 and 2837e87.

Files selected for processing: 9

  • docs/reference/builtins.md
  • docs/reference/classic.md
  • docs/reference/divergences.md
  • docs/reference/flakes.md
  • src/builtins/fetch.rs
  • src/eval/tests.rs
  • src/flake/flakeref.rs
  • tests/lang/eval-okay-parse-flake-ref-sourcehut.exp
  • tests/lang/eval-okay-parse-flake-ref-sourcehut.nix

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@Mic92
Mic92 added this pull request to the merge queue Nov 28, 2026
Any commits made after this event will not be merged.
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.

1 participant