Skip to content

okf: extract into flakes/okf sub-flake - #26

Merged
kriswill merged 3 commits into
mainfrom
okf-subflake
Jul 4, 2026
Merged

okf: extract into flakes/okf sub-flake#26
kriswill merged 3 commits into
mainfrom
okf-subflake

Conversation

@kriswill

@kriswill kriswill commented Jul 4, 2026

Copy link
Copy Markdown
Owner

What

Moves the okf knowledge-bundle CLI from scripts/okf/ to flakes/okf/ (git mv, history preserved) and makes it a self-contained sub-flake per the house extraction pattern (AGENTS.md / flakes/ccglass precedent) — the first step toward spinning okf out as an independent project consumable by many repos.

  • Real package output: packages.<system>.okf ships the TypeScript sources plus vendored node_modules — a fixed-output bun install keyed on bun.lock (the pattern nixpkgs uses for opencode/helix-gpt; no bun packaging helper exists) — under a bun run --prefer-offline --no-install wrapper. No bun build --compile: okf viz bundles the Svelte viewer with Bun.build + bun-plugin-svelte at CLI runtime, so the bun runtime and deps must be present. The lock is pure JS (no os/cpu-conditional packages), so one FOD hash serves all three systems.
  • cwd-based repo resolution: lib.ts repoRoot() switched from import.meta.dir/../.. to git rev-parse --show-toplevel, so the store-run binary operates on whatever repo it's invoked in. This is the only generalization taken now — bundle dir stays hardcoded knowledge/, scaffold stays dotfiles-shaped.
  • Fast iteration preserved: the dev shell keeps its impure working-tree wrapper (modules/dev.nix, path repointed) — edits stay live with no rebuild. The nix package is for external consumption/parity.
  • CI unchanged in spirit: the Pages workflow stays bun-native (no nix), with trigger paths / working-directory / build command repointed to flakes/okf.
  • Root wiring: relative-path input with nixpkgs/flake-parts follows; re-exports in modules/packages.nix (perSystem + the aarch64-linux block). No overlay — nothing installs okf system-wide.
  • Docs/knowledge: full scripts/okf reference sweep (log.md history untouched); new knowledge/packages/okf.md concept and knowledge/decisions/okf-subflake.md decision record.

Reviewer notes

  • The FOD hash needs refreshing when bun.lock changes or a nixpkgs bump changes bun's install layout — loud hash-mismatch failure; procedure documented in flakes/okf/README.md (passthru.node_modules makes it one command).
  • okf viz --check / --perf are dev-tree-only (svelte-check writes into node_modules, read-only in the store; --perf needs local Chrome) — documented in the README.
  • Root nix flake check doesn't run the sub-flake's checks; use nix flake check ./flakes/okf.
  • After merge, a workflow_dispatch of the pages workflow confirms the publish end-to-end.

Verification

  • bun test: 238 pass (working tree) and offline in the nix sandbox (checks.<system>.test)
  • nix build ./flakes/okf#okf standalone; store binary ran validate and viz (full 2.5 MB viz.html through the store node_modules symlink)
  • nix flake check on both flakes; nix build .#okf (exact drv parity with standalone); nix eval of the aarch64-linux/x86_64-linux re-exports
  • nix build .#darwinConfigurations.k.system and nebula toplevel cross-eval both green
  • okf validate --strict: 0 errors, 0 warnings; fmt/statix/deadnix: no new findings

kriswill added 3 commits July 4, 2026 16:22
Move scripts/okf -> flakes/okf (git mv, history preserved) and make it a
real sub-flake per the house extraction pattern — the first step toward
spinning okf out as an independent project:

- packages.<system>.okf: sources + vendored node_modules (fixed-output
  bun install; pure-JS lock, one hash for all systems) under a
  `bun run --no-install` wrapper. No bun compile: `okf viz` runs
  Bun.build + bun-plugin-svelte at CLI runtime.
- checks.<system>.test: the 238 viewer tests, offline in the sandbox.
- lib.ts repoRoot() is now cwd-based (git rev-parse --show-toplevel) so
  the store binary operates on the caller's repo — the only
  generalization taken now; bundle dir stays knowledge/.
- Dev shell keeps the impure working-tree wrapper (fast iteration
  unchanged); root re-exports the package (perSystem + aarch64-linux);
  no overlay. Pages workflow stays bun-native, paths repointed.
- Reference sweep across AGENTS.md/README/skills/knowledge (log.md
  history untouched); new okf catalog concept + okf-subflake decision
  record; okf validate --strict clean.

Verified: bun test (238), standalone + root nix builds, store-binary
validate/viz, nix flake check (both flakes), Linux drv evals,
darwinConfigurations.k build, nebula toplevel cross-eval.
repoRoot() now reports "could not run git" when the binary itself can't
be spawned (r.error, e.g. ENOENT), instead of the misleading
"not inside a git repository" message that case previously shared with
a real non-repo cwd. Also switches the memoization to the file's
existing `x ??= compute()` idiom (matches gitDates below it) instead of
a bespoke if-check-then-assign.

Cosmetic follow-ups from the okf-subflake code review.
@kriswill
kriswill merged commit 67a95a5 into main Jul 4, 2026
@kriswill
kriswill deleted the okf-subflake branch July 4, 2026 23:50
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