fix(logseq-cli): resolve opam #main pins per-nightly via manifest#54
Conversation
logseq/logseq 3684727952e6 (2026-06-25 "chore: update opam") repointed the
cli/logseq-cli.opam pin-depends for melange-edn, melange-transit, and humanize at the
mutable #main branch. opam-nix fetchGitURL rejects a git pin whose fragment is not a
40-char sha1 in pure evaluation mode, so the nightly publish-release "Validate flake"
step (nix flake check) throws "[opam-nix] a git dependency without an explicit sha1 is
not supported in pure evaluation mode" while the desktop build legs (native opam, which
accepts branch refs) pass.
opam-deps.nix resolves the closure over the unpatched upstream src FOD, so the patches/
mechanism cannot reach it. scripts/update-nightly.sh (Phase 3b) reads the opam at
LOGSEQ_REV, git ls-remotes each non-sha1 git pin to its current commit, and records the
rewrites in the new manifest.cliOpamPinOverrides ({from,to} URL pairs); opam-deps.nix
applies them with substituteInPlace --replace-fail before buildOpamProject reads the
file (empty list reads src/cli in place). Resolving at manifest time keeps the pin
tracking upstream every nightly instead of freezing a literal: the melange-edn main HEAD
moved twice within 30 minutes on 2026-06-26 (bdc79c1d -> f155433f). lib/loadManifest.nix
requires the field and asserts each to URL ends in an explicit 40-char sha1.
Validation: nixfmt, shfmt, shellcheck, deadnix, statix; nix eval of
.#packages.x86_64-linux.logseq-cli.drvPath and .#packages.x86_64-linux.logseq.drvPath
(identical drvs at the current empty-override rev); producer resolution and the
substituteInPlace rewrite verified end-to-end against the real upstream opam at the
failing-era rev (3684727952e6) and current master.
|
Claude finished @Bad3r's task in 3m 10s —— View job ReviewNo issues found. Walked through every hunk against the upstream opam shape and surrounding callers:
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to resolve mutable git branch pins in logseq-cli.opam to explicit 40-character SHA1 commits during nightly updates, ensuring compatibility with opam-nix in pure evaluation mode. The changes include adding a cliOpamPinOverrides field to the manifest, validating it in Nix, updating the nightly script to resolve these branch refs using git ls-remote, and applying the overrides in opam-deps.nix. Feedback focuses on two key issues: first, pkgs.runCommandLocal will fail when using substituteInPlace because the function is not available in its minimal environment, so pkgs.stdenv.mkDerivation should be used instead; second, the git ls-remote resolution in the update script is fragile and should be updated to match exact refs to avoid incorrect SHA resolution.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f748a43ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Phase 3b of update-nightly.sh resolved each opam pin-depends branch ref with
`git ls-remote "$remote" "$frag" | awk 'NR==1'`, which is wrong two ways:
- git ls-remote tail-matches the fragment, so a bare `main` also returns
refs/heads/feature/main; sorted output places feature/main first and NR==1
records the colliding branch's sha1 instead of refs/heads/main.
- an annotated-tag fragment records the tag-object sha1 (git cat-file -t
reports `tag`), not the commit it points at. loadManifest.nix only checks
for 40 hex chars, so the bad `to` value passes validation and opam-nix
still throws when it needs a commit sha1.
resolve_ref_sha passes qualified patterns (refs/heads/<f>, refs/tags/<f>^{},
refs/tags/<f>) and matches column 2 exactly in awk, preferring a branch head,
then the peeled annotated tag, then a lightweight tag or already-qualified
ref. Verified against a synthetic repo (collision branch, lightweight tag,
annotated tag, missing ref) and the real humanize/logseq remotes; shfmt
-s -i 2, shellcheck, and bash -n are clean.
Review triage (commit
|
Problem
The nightly
publish-release"Validate flake" step fails with[opam-nix] a git dependency without an explicit sha1 is not supported in pure evaluation mode(failing run).
Upstream
logseq/logseq@3684727952e6(2026-06-25 "chore: update opam") repointedcli/logseq-cli.opampin-depends formelange-edn,melange-transit, andhumanizeatthe mutable
#mainbranch. opam-nix'sfetchGitURLrejects a git fragment that is not a40-char sha1 in pure evaluation mode, so
nix flake checkthrows. The desktop build legsuse native opam (which accepts branch refs) and pass, so every
buildleg is green whileonly the Nix validation breaks. It does not self-heal: upstream's later
eda573cre-pinnedonly
melange-transit, leaving the other two on#main.Fix
opam-deps.nixresolves the closure over the unpatched upstreamsrcFOD, so thepatches/mechanism cannot reach it. Resolution moves to the producer and rides throughthe manifest, like the other CLI hashes:
scripts/update-nightly.sh(Phase 3b) reads the opam atLOGSEQ_REV,git ls-remoteseach non-sha1 git pin to its current commit, and writes
cliOpamPinOverrides(
{from,to}URL pairs) into the manifest.lib/loadManifest.nixrequires the field and asserts eachtoends in an explicit40-char sha1.
opam-deps.nixapplies the rewrites withsubstituteInPlace --replace-failbeforebuildOpamProjectreads the file; an empty list readssrc/cliin place (no-op).Resolving at manifest time keeps the pin tracking upstream every nightly instead of
freezing a literal. The
melange-ednmainHEAD moved twice within ~30 minutes on2026-06-26 (
bdc79c1d->f155433f), so a hardcoded pin would already diverge from whatthe desktop legs build.
Validation
nix evalof.#packages.x86_64-linux.logseq-cli.drvPathand.#packages.x86_64-linux.logseq.drvPath: identical drvs at the current empty-overriderev (no regression).
substituteInPlacerewrite verified end-to-end against thereal upstream opam at the failing-era rev (
3684727952e6) and current master: fullysha1-pinned, zero
#mainremaining,--replace-failmatched everyfrom.