refactor(nix): flake-parts系flakeでflakeを簡素化しビルドキャッシュと開発環境を整備 - #121
Merged
Conversation
flake-partsのエコシステム(treefmt-nix, git-hooks.nix)を活用してNix flakeを 簡素化し、ビルドキャッシュと開発環境セットアップを容易にする。 - flake.nixに明示的なroot perSystemを置き、pkgs/rustToolchain/swiftformatを 一度だけ構築して各ヘルパー(nix/packages.nix, nix/formatting.nix, nix/dev-shells.nix)へ名前付き引数で明示的に渡す構成にした。_module.argsの 暗黙的な共有をやめ、データの流れを追いやすくした。 - treefmt-nixでnixfmt/rustfmt/swiftformatを一元化し、formatterと treefmtチェックとして公開(従来のnixfmt formatterとcrane cargoFmtを置換)。 元のformattingチェック名も維持。 - git-hooks.nixのpre-commit(treefmt + clippy)をdev shell入室時に自動導入。 clippyフックはCraneのclippyチェックとスコープを一致(--workspace --exclude wisp-desktop --all-targets)。 - nixConfigでnix-communityバイナリキャッシュを宣言し、default shellに cachix CLIを同梱。CraneのbuildDepsOnly成果物を共有してキャッシュ再利用を最大化。 - CIのパスフィルタにnix/**を追加(nix/rust/rust-macos/swift.yaml)。 Windowsクロスコンパイル、sherpa-onnxのLinux取得、macOS Xcodeハンドリング、 swiftformatピン留め、全packages/checks/devShells出力は維持している。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Nix flake を flake-parts のエコシステム(
treefmt-nix/git-hooks.nix)を活用して簡素化し、ビルドキャッシュと開発環境セットアップを容易にしました。あわせてflake.nixに明示的な rootperSystemを置き、コードを追いやすい構成に整理しています。主な変更
構成をわかりやすく(明示的な root perSystem)
flake.nixの rootperSystemでpkgs/rustToolchain/swiftformatを一度だけ構築し、各ヘルパー(nix/packages.nix/nix/formatting.nix/nix/dev-shells.nix)へ名前付き引数で明示的に渡す構成にしました。_module.argsによる暗黙的な共有をやめ、各ファイルの関数シグネチャを見れば「何を必要とし何を返すか」が一目で分かるようにしています。データの流れが上から下に追えます。packages.nix→{ packages, checks }、formatting.nix→{ treefmt, pre-commit }、dev-shells.nix→ devShells セット)。不要になったnix/parts/toolchain.nixは削除。フォーマット統一(treefmt-nix)
nixfmt/rustfmt/swiftformatを treefmt で一元化し、formatter(nix fmt)とtreefmtチェック(nix flake check)として公開。従来のnixfmtformatter と Crane のcargoFmtチェックを置換しつつ、元のformattingチェック名も維持。rustfmtは workspace の toolchain にピン留めし CI と整合。開発環境をターンキー化(git-hooks.nix)
treefmt+clippy)をnix develop入室時に自動導入。フレッシュクローンでも一発でセットアップ完了。clippyフックは Crane の clippy チェックとスコープを一致(--workspace --exclude wisp-desktop --all-targets)。ビルドキャッシュを容易に
nixConfigで nix-community バイナリキャッシュを宣言(公式の trusted key 付き)。cachixCLI を同梱(プロジェクト用キャッシュのcachix use手順は README に記載)。buildDepsOnly成果物を package / clippy / tests 間で共有し、ローカルキャッシュ再利用を最大化。CI
nix/**を追加(nix.yaml/rust.yaml/rust-macos.yaml/swift.yaml)。Nix ロジックをnix/へ分割したことで漏れていた再トリガを補完。互換性(すべて維持)
Windows クロスコンパイル、sherpa-onnx の Linux アーカイブ取得、macOS の Xcode/
DEVELOPER_DIRハンドリング、swiftformat のピン留め、および全packages/checks/devShells出力を維持しています。検証(aarch64-darwin)
nixfmt --check flake.nix nix→ exit 0nix flake check --no-build→ 全出力グリーンpackages:default, wisp-mcp, wisp-windowschecks:clippy, formatting, tests, treefmt, wisp-mcppackages:default, wisp-mcp/checks:formatting, treefmt, wisp-mcpdevShells:default, ci/formatterありnix develop両シェル)も darwin 上で成功。Linux 専用チェック(clippy/tests/wisp-windows/sherpa 取得)は当ホストでは評価のみ。