8000 Move to one repository with josh exports, the way pyterm did · Issue #4 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

Move to one repository with josh exports, the way pyterm did #4

Closed

Description

@Lillecarl

pyterm moved to one repository on 2026-10-14. Its sources are now directories, and josh exports each one to its own repository on every push. This is the route it took and the traps it hit, so that nixidae can take the same route. Every file named below is in Lillecarl/pyterm at main. Copy from there, do not start from scratch. The pyterm issues are Lillecarl/pyterm#669 (the import), Lillecarl/pyterm#672 (standalone sources) and Lillecarl/pyterm#673 (docs sites).

0. Settle the shape with Carl first

pyterm's answers, as a starting point:

  • Which repositories go in. A fork whose patches must stay upstreamable (pyterm's prompt-toolkit) stays out. Its checkout sits in the tree, gitignored, and flake.lock pins it. nix/compat.nix passes flake-compatish overrides = { self = ../.; prompt-toolkit = ../prompt-toolkit; }. The self override is required for pure evaluation.
  • The export target repositories are export-only. Commits happen in the monorepo, and issues go in one tracker.
  • Tests run only in the monorepo. Each exported repository runs one workflow, its Pages deploy (see step 6).
  • The credential is a fine-grained PAT, stored as the monorepo secret JOSH_EXPORT_TOKEN.

1. Import without losing history (do it in a separate clone)

  • Merge each source in with josh :prefix=<dir>. The export filter :/<dir> then gives back the same commit hashes that each repository already has. That is why every later push fast-forwards.
  • Stage it on a branch, for example monorepo, and push each export to a josh branch in each target first. Compare that branch with the target's main, and only then move main.
  • Archive before you move anything. Copy each remote branch to archive/pre-josh/<branch>. Push commits that exist only locally (jj log -r 'remote_bookmarks()..' and orphans) as archive/pre-josh/unpushed-*. Keep the archives, the josh branches and the old checkout until Carl removes them.
  • To rename master to main, use gh api -X POST repos/O/R/branches/master/rename -f new_name=main. Trap: the rename leaves the repository's github-pages environment branch policy on master, so the next Pages deploy fails. Repoint it with gh api repos/O/R/environments/github-pages/deployment-branch-policies.
  • Do the whole export locally, with your own push access, before you automate it. "What would GHA do" is cheaper to answer from your own terminal.

2. One lock, nothing flake-only

  • The root flake.lock is the only pin. npins goes. default.nix takes { inputs ? compat.inputs, system, pkgs ? <pinned>, sourceOverrides ? { } }.
  • flake.nix only maps default.nix over the systems. Nothing is defined there.

3. Each source builds alone

pyterm's nix/shared/ holds the templates, with @name@ for the name. Each source has:

  • package.nix: the package that the root calls.
  • default.nix: import inputs.pyterm { inherit (inputs.pyterm) inputs; system; sourceOverrides.<name> = ./.; }, which passes pkgs through when given. It exposes <name>, default, shell, checks and pages.
  • flake.nix with a single input, the monorepo.
  • nix/compat.nix, which reaches flake-compatish two hops through the lock. Also shell.nix.
  • flake.lock, written by pkgs/lock-subtrees. The lock is the root's lock graph plus a monorepo node locked at HEAD. Take the narHash from a local fetchTree of the git repository; it equals GitHub's. A commit cannot name itself, so the locks land as a second commit after the content. --check REV refuses a lock that names a commit with anything but locks changed since.

4. The export

  • pkgs/josh-export (Python, writePython3Bin) finds sources by tracked */flake.nix. It never forces a push, and it refuses a target that moved on its own. --verify requires each exported tree's standalone drvPath to equal the monorepo's. josh comes from the pinned nixpkgs, so after a nixpkgs bump run josh-export HEAD --verify before the push: another josh version can produce other hashes.
  • .github/workflows/josh-export.yml runs on a push to main: lock-subtrees --check "$GITHUB_SHA", then josh-export "$GITHUB_SHA" --verify --push.
  • Trap: actions/checkout needs persist-credentials: false and fetch-depth: 0. Without the first, the push goes as github-actions[bot] and is refused.
  • Trap: the PAT needs Contents read/write and Workflows read/write on every target. Without Workflows, GitHub refuses a push that creates a workflow file ("refusing to allow a Personal Access Token to create or update workflow"). A push that only deleted one went through, which hid the gap.

5. Landing procedure (put it in CLAUDE.md)

jj commit, then nix run --file . lock-subtrees, then jj bookmark set main -r @-, then jj git push --bookmark main. Then read the export run.

6. Docs sites

  • nix/docs/ builds each source's site with Sphinx, MyST, furo and an autosummary API reference. The content is the source's README, its docs/ and the API. Each pyproject has a docs extra, so autodoc imports the real package.
  • Each source's pages attribute is deployed by its exported .github/workflows/pages.yml. The root's pages.<root> gathers every source's site under /<name>/. Anything slow (pyterm's 30-minute picture galleries) builds only in the repository that owns it, and the root links to it.
  • Trap: configure-pages with enablement: true cannot create a Pages site with the run's own token ("Resource not accessible by integration"). Enable it once per repository with gh api -X POST repos/O/R/pages -f build_type=workflow, then rerun.

7. Keep the sources alike

pkgs/sync-sources writes what every source shares from the root:

  • the [tool.ruff] stanza, from ruff.toml;
  • .gitignore, default.nix, shell.nix, nix/compat.nix and pages.yml, from nix/shared/;
  • the README's head and tail, found by HTML-comment marker lines.

checks.<root>-sources-in-step, part of the gate, fails while a copy drifts. Seven hand-kept copies had drifted before this existed.

Checked in pyterm

  • nix run github:Lillecarl/pymux works.
  • nix flake check --all-systems passes.
  • A fresh clone builds with --file.
  • The standalone drv equals the monorepo's (--verify).

Activity

  1. Lillecarl commented on Oct 14, 2026

    @Lillecarl
    ContributorAuthor

    Shape settled with Carl on 2026-10-14:

    • In (9): nanopynix, pynixd, easykubenix, nixkube, vivarium, huggorm, pydd, havsorm, ghanix.
    • External: flake-compatish and dinix (general tools nixidae only consumes), kr8s and containerd (forks for upstream). umbrella retires.
    • Home: nixidae/nixidae. Its lock history stays as the root line; each project merges in with :prefix=<name>.
    • Branch: every target exports to main. nanopynix, pynixd, easykubenix, nixkube, vivarium and ghanix rename develop to main first.

    Assisted-By: Claude Opus 5.5

  2. Lillecarl commented on Oct 14, 2026

    @Lillecarl
    ContributorAuthor

    Staged locally in a separate clone (branch monorepo, nothing pushed). Each step is a commit; 40 of them on top of b8b1292.

    • Import: nine :prefix merges. josh-filter :/<name> gives back each repository's exact remote head, signed commits included.
    • Pins: flake.lock (all flake = false, flat), read by nix/compat.nix. Sources are what git tracks of each directory, copied to a store path named source, so local, CI and exported builds agree. Old umbrella vs new: 149 of 168 top-level derivations identical; the 19 that differ are in sources I edited.
    • Six sibling imports passed no sources and silently fetched an older nixidae (nixkube wait_for matches what already arrived, so a repeated expectation checks nothing Lillecarl/pyterm#81's bug class). Fixed.
    • CI: each source exposes ciTestWorkflows; nix/ci.nix renders .github/workflows/<source>-<name>.yml. Exported repos keep only a Pages workflow (vivarium none).
    • lock-subtrees and josh-export adapted from pyterm, with per-source repo targets in nix/members.nix. josh-export HEAD --verify: all nine ok, standalone drv == root drv. Both checks fail when they should (tested).

    Open for Carl: the cutover pushes, the JOSH_EXPORT_TOKEN PAT, where nixkube releases live (tags are now nixkube/v*), and nanopynix/last-green now on nixidae.

    Assisted-By: Claude Opus 5.5

  3. Lillecarl commented on Oct 14, 2026

    @Lillecarl
    ContributorAuthor

    Cut over 2026-10-14.

    • nixidae main = 6a2b054. Every child main fast-forwarded to its josh export (no force). vivarium and ghanix: develop renamed to main. nanopynix, pynixd, easykubenix, nixkube: default branch main; their develop stays where it was. github-pages branch policies point at main.
    • archive/pre-josh/* in every child: 29 old branches, 9 formerly local-only commits.
    • nixkube releases go to Lillecarl/nixkube: a tag nixkube/vX here releases vX there, on the exported commit.
    • Missing: JOSH_EXPORT_TOKEN. A fine-grained PAT covers one owner, and the targets are Lillecarl/* plus nixidae/havsorm. Until it exists, the export job fails at its push step.

    Assisted-By: Claude Opus 5.5

  4. added
    source: monorepo
    on Oct 19, 2026
  5. added theissue type on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: monorepo

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0