Skip to content

Conversation

@ta93abe
Copy link
Owner

@ta93abe ta93abe commented Jan 26, 2026

  • Restructure directories: modules/{common,darwin,nixos}, machines/{darwin,nixos,linux}
  • Split darwin-configuration.nix into modular components
  • Add platform detection for homeDirectory, clipboard commands
  • Change nixpkgs URL from darwin-specific to nixos-24.11
  • Add lib helpers: mkDarwinSystem, mkNixosSystem, mkHomeConfig
  • Add NixOS and standalone home-manager configuration templates

Summary by CodeRabbit

Release Notes

  • New Features

    • Added multi-platform support for macOS, Linux (NixOS and non-NixOS), and Windows/WSL2.
    • Introduced platform-specific configuration management with automatic detection.
    • Added Windows setup automation via package management tooling.
  • Documentation

    • Expanded project documentation with comprehensive guides for all supported platforms.
    • Added platform-specific Quick Start and daily usage instructions.
    • Introduced Windows and WSL2 setup guidance.
  • Refactor

    • Restructured configuration system for cross-platform compatibility.
    • Reorganized modular configuration structure for improved maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The project transitions from a macOS-centric (Darwin-only) configuration to a unified, multi-platform Nix-based setup supporting macOS, NixOS, non-NixOS Linux, and Windows/WSL2. The monolithic darwin-configuration.nix and top-level home.nix are removed, replaced by modularized library helpers (lib/mk*.nix) and platform-specific configuration directories. The flake.nix now conditionally dispatches workflows based on the target system, and the README is extensively reorganized to document platform-specific setup and usage patterns.

Changes

Cohort / File(s) Summary
Documentation
README.md, windows/README.md
Extensive README restructuring from Darwin-only to multi-platform scope; adds platform support table, expands Quick Start/daily usage sections with macOS, Linux (NixOS and non-NixOS), WSL2 workflows; introduces new troubleshooting and initialization guidance. New Windows README documents winget setup, WSL2 integration, and package management.
Flake & Library Infrastructure
flake.nix, lib/default.nix, lib/mkDarwinSystem.nix, lib/mkNixosSystem.nix, lib/mkHomeConfig.nix
Flake extended from Darwin-only to cross-platform scaffolding with conditional system detection. New lib/ module exports supportedSystems, forAllSystems, mkUnstableOverlay, and three system builders (mkDarwinSystem, mkNixosSystem, mkHomeConfig) that modularize system-specific configuration assembly with overlays and Home Manager integration. Apps now conditionally handle Darwin vs. non-Darwin platforms.
Deprecated/Removed
darwin-configuration.nix, home.nix, lib/mkSystem.nix
Removed monolithic macOS configuration, top-level Home Manager entry point, and legacy Darwin system builder. Functionality redistributed to modular, platform-aware equivalents.
Home Manager Configuration
home/default.nix, home/packages.nix, home/programs/fzf.nix, home/xdg.nix
New modular Home Manager setup with platform detection and conditional imports. Packages module now uses lib.optionals for platform-specific composition. FZF and XDG modules updated with platform-aware clipboard command selection (Darwin/Wayland/fallback). All modules gain lib parameter for conditional logic.
Darwin/macOS Modules
modules/darwin/default.nix, modules/darwin/system.nix, modules/darwin/homebrew.nix
New modularized macOS configuration replacing the removed monolithic file. default.nix aggregates system packages and Nerd Fonts; system.nix defines comprehensive macOS preferences (Dock, Finder, keyboard, mouse, Touch ID for sudo); homebrew.nix enables declarative GUI app management via Homebrew with casks and taps.
NixOS Modules
modules/nixos/default.nix, machines/nixos/example.nix
New NixOS system configuration module with networking, timezone (Asia/Tokyo), user setup, system packages, and font management. Example template provided for per-machine NixOS configurations.
Linux/Home Manager Configuration
machines/linux/example.nix
New template for non-NixOS Linux machine-specific Home Manager settings with placeholders for packages and WSL2 session variables.
Common Modules
modules/common/nix.nix
New shared Nix configuration module defining experimental features, auto-optimization, and garbage collection settings used across all platforms.
Windows Tooling
windows/setup.ps1, windows/packages.json
New Windows setup automation: PowerShell script for winget package import with privilege/verification checks; winget manifest defining GUI application packages and repository sources.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs


🐰 Hops with glee through module directories new,
From Darwin's cage to Linux bright and true,
NixOS, WSL2, Windows too—
One fluffy flake now builds 'em all, ta-doo!


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Owner Author

ta93abe commented Jan 26, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gemini-code-assist
Copy link

Summary of Changes

Hello @ta93abe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly broadens the scope of the Nix flake configuration by introducing robust multi-platform support. The core changes involve a comprehensive restructuring of the configuration, breaking down platform-specific settings into modular components, and introducing a set of helper functions to simplify the definition of macOS, NixOS, and standalone Linux/WSL2 environments. This enhancement makes the configuration more adaptable and maintainable across diverse operating systems, moving towards a unified declarative approach for all personal computing environments.

Highlights

  • Multi-Platform Support: The configuration has been refactored to support macOS, NixOS, and standalone Home Manager setups for Linux and WSL2, moving from a Darwin-specific setup to a truly universal one.
  • Modularization of Configuration: The monolithic darwin-configuration.nix has been split into smaller, more manageable modules under modules/darwin and modules/common, improving organization and reusability.
  • Introduction of Library Helpers: A new lib directory contains helper functions (mkDarwinSystem, mkNixosSystem, mkHomeConfig) to streamline the creation and management of different system configurations within the flake.
  • Platform-Aware Logic: Dynamic detection for homeDirectory and clipboard commands (pbcopy, wl-copy, xclip) has been implemented in Home Manager configurations, ensuring correct behavior across different operating systems.
  • Updated Flake Structure and Templates: The flake.nix now uses a generic nixos-24.11 nixpkgs channel and includes commented-out templates for NixOS and standalone Home Manager configurations, along with platform-specific nix run commands.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is an excellent refactoring that significantly improves the structure and maintainability of the Nix configuration by adding multi-platform support for macOS, Linux, and WSL2. The introduction of helper functions in the lib directory and the modularization of configurations into modules and machines are great design choices.

I've added a couple of suggestions to improve the robustness of the helper scripts and ensure all dependencies are correctly managed for standalone Home Manager configurations on Linux. Overall, this is a very solid pull request.

Comment on lines +17 to +52
{
imports = [
# Package list
./packages.nix

# Program configurations
./programs/git.nix
./programs/fish.nix
./programs/starship.nix
./programs/helix.nix
./programs/fzf.nix
./programs/zoxide.nix
./programs/mcfly.nix
./programs/claude.nix

# XDG configurations (Ghostty, Zellij)
./xdg.nix
];

# Home Manager needs a bit of information about you and the paths it should manage
home = {
username = personal.username;
inherit homeDirectory;

# This value determines the Home Manager release that your configuration is compatible with
stateVersion = "24.11";

# Environment variables
sessionVariables = {
EDITOR = "hx";
};
};

# Let Home Manager install and manage itself
programs.home-manager.enable = true;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Your configurations for fzf and zellij (via xdg.nix) correctly use a platform-specific copyCommand. On Linux, this relies on xclip or wl-clipboard. While these are included in the systemPackages for NixOS, they are missing for standalone Home Manager setups (e.g., on non-NixOS Linux or WSL2).

To make your Home Manager configuration self-contained and ensure it works correctly across all supported platforms, I recommend conditionally adding xclip and wl-clipboard to home.packages for Linux systems directly within this main Home Manager module.

{
  imports = [
    # Package list
    ./packages.nix

    # Program configurations
    ./programs/git.nix
    ./programs/fish.nix
    ./programs/starship.nix
    ./programs/helix.nix
    ./programs/fzf.nix
    ./programs/zoxide.nix
    ./programs/mcfly.nix
    ./programs/claude.nix

    # XDG configurations (Ghostty, Zellij)
    ./xdg.nix
  ];

  # Ensure clipboard tools are available on Linux for fzf, zellij, etc.
  home.packages = lib.mkIf isLinux [ pkgs.xclip pkgs.wl-clipboard ];

  # Home Manager needs a bit of information about you and the paths it should manage
  home = {
    username = personal.username;
    inherit homeDirectory;

    # This value determines the Home Manager release that your configuration is compatible with
    stateVersion = "24.11";

    # Environment variables
    sessionVariables = {
      EDITOR = "hx";
    };
  };

  # Let Home Manager install and manage itself
  programs.home-manager.enable = true;
}

Comment on lines 128 to 133
set -e
echo "Building configuration..."
# Try to build any available configuration
if nix build .#nixosConfigurations.${personal.hostname}.config.system.build.toplevel 2>/dev/null; then
echo "NixOS build successful!"
elif nix build .#homeConfigurations.${personal.username}@${personal.hostname}.activationPackage 2>/dev/null; then
echo "Home Manager build successful!"
else
echo "No matching configuration found for this hostname"
exit 1
fi
''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation of the build app for non-Darwin systems attempts to automatically find and build a configuration. This approach has a couple of drawbacks:

  1. It uses 2>/dev/null to suppress errors, which can hide legitimate build failures (like syntax errors in your Nix code), making debugging difficult.
  2. The "magic" of auto-detection can be confusing. A more explicit approach is often clearer and more robust.

I suggest replacing this logic with a clear error message that instructs the user on how to build their specific configuration, similar to how the switch app is handled for non-Darwin systems.

                set -e
                echo "Error: 'build' app is not supported for non-Darwin systems. Please build explicitly." >&2
                echo "  For NixOS: nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel" >&2
                echo "  For Home Manager: nix build .#homeConfigurations.<user@hostname>.activationPackage" >&2
                exit 1
              ''

@claude
Copy link

claude bot commented Jan 26, 2026

PR レビュー: マルチプラットフォーム対応

このPRはmacOS専用の設定をmacOS、Linux、WSL2の3プラットフォームに対応させる大規模なリファクタリングです。全体的に非常によく設計されており、コードの品質も高いです。

👍 良い点

1. 優れたモジュール設計

  • modules/{common,darwin,nixos} の階層構造が明確で保守性が高い
  • 共通設定を modules/common/nix.nix に集約し、DRYの原則に従っている
  • Darwin固有の設定を system.nix と homebrew.nix に分離し、関心の分離ができている

2. プラットフォーム検出が適切

  • home/default.nix:640-646 でのプラットフォーム検出は明確で読みやすい
  • クリップボードコマンドの分岐も適切

3. ヘルパー関数の抽象化

  • lib/mkDarwinSystem.nix, lib/mkNixosSystem.nix, lib/mkHomeConfig.nix の3つの構築関数が整理されている
  • forAllSystems ヘルパーで複数システムへの対応がエレガント

4. テンプレートファイルの提供

  • machines/linux/example.nix と machines/nixos/example.nix が将来の拡張を考慮している
  • コメントで使用方法を明示しており、ドキュメントとして機能している

@claude
Copy link

claude bot commented Jan 26, 2026

🔍 改善提案

1. Wayland環境変数のチェック方法(優先度: 中)

問題箇所: home/programs/fzf.nix:697, home/xdg.nix:727

懸念点:

  • builtins.getEnv はビルド時に評価されるため、実行時の環境変数を正しく取得できない可能性があります
  • Nixはpureな評価を重視するため、環境変数への依存は推奨されません

推奨される修正案(実行時スクリプトで判定):
利用可能なクリップボードツールを動的に選択する方が堅牢です

2. NixOS設定のロケールがハードコードされている(優先度: 低)

問題箇所: modules/nixos/default.nix:21-35

推奨される修正:

  • personal 設定にタイムゾーンとロケールを追加することで、複数ユーザーや地域での使用に対応

3. nixpkgs URLの変更影響(優先度: 高 - 確認事項)

変更箇所: flake.nix:342
nixpkgs-24.11-darwin から nixos-24.11 への変更

確認事項:

  • nixos-24.11 は nixpkgs-24.11-darwin と完全に互換性があることを確認してください
  • macOS特有のパッケージ(特に mongodb-community など)が nixos-24.11 ブランチで利用可能か確認が必要です
  • 実際に nix run .#build でビルドが成功することをテストしてください

@claude
Copy link

claude bot commented Jan 26, 2026

🔒 セキュリティ

特に懸念はありませんが、以下の点に注意:

  • WSL2環境でクリップボード共有を使用する場合、clip.exe を通じてWindows側にデータが渡るため、機密情報の扱いに注意
  • modules/nixos/default.nix:41 でdockerグループに自動追加していますが、これはrootレベルの権限につながるため、セキュリティポリシーに応じて調整してください

📊 テストカバレッジ

現時点ではmacOSのみの実装なので、以下のテストが必要です:

  1. ✅ macOS (Darwin): 既存の設定が動作することを確認
  2. ⏳ NixOS: machines/nixos/example.nix を使用したテスト環境の構築
  3. ⏳ WSL2/Linux: machines/linux/example.nix を使用したテスト環境の構築

推奨: CI/CD パイプラインに複数プラットフォームのビルドテストを追加することをお勧めします。

🎯 結論

このPRは非常によく設計されており、将来の拡張性を考慮した優れたリファクタリングです。上記の改善提案は主にエッジケースと堅牢性の向上に関するもので、コアの実装は十分に高品質です。

承認条件:

  • クリップボードコマンドのWayland検出方法の修正(改善提案1)
  • nixpkgsブランチ変更の動作確認(改善提案3)

これらが確認できれば、自信を持ってマージできます。

@ta93abe ta93abe force-pushed the 01-26-feat_add_multi-platform_support_for_macos_linux_and_wsl2 branch 2 times, most recently from e3478a9 to a215644 Compare January 26, 2026 12:15
@claude
Copy link

claude bot commented Jan 26, 2026

PR #7 レビュー: マルチプラットフォーム対応

概要

このPRはdotfilesをmacOS専用からマルチプラットフォーム(macOS、Linux、WSL2)対応に拡張する大規模なリファクタリングです。全体的に非常によく設計されており、モジュール化と拡張性を高める優れた変更です。

良い点 ✅

1. 優れたアーキテクチャ設計

  • モジュール構造が論理的で明確(modules/{common,darwin,nixos}
  • プラットフォーム固有のコードと共通コードの分離が適切
  • lib/ディレクトリでヘルパー関数を再利用可能に整理

2. 宣言的で拡張可能

  • mkDarwinSystemmkNixosSystemmkHomeConfigにより新しいマシンの追加が容易
  • forAllSystemsによる複数プラットフォームのサポート
  • テンプレートファイル(example.nix)で新規構成のガイダンスを提供

3. プラットフォーム検出の実装

  • homeDirectoryの自動検出(Darwin: /Users/, Linux: /home/
  • クリップボードコマンドのプラットフォーム別分岐(pbcopy/wl-copy/xclip)
  • pkgs.stdenv.isDarwin/isLinuxによる条件分岐

4. コードの保守性向上

  • 大きなdarwin-configuration.nixを小さなモジュールに分割
  • 各モジュールの責務が明確(system.nixhomebrew.nixなど)
  • home.nixhome/default.nixに移動し、構造を統一

改善提案 🔧

1. セキュリティ: クリップボードコマンドの実行リスク ⚠️

home/programs/fzf.nix:693-698home/xdg.nix:720-728でクリップボードコマンドを決定する際にbuiltins.getEnvを使用していますが、これは潜在的な問題があります:

copyCommand = if isDarwin then "pbcopy"
  else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
  else "xclip -selection clipboard";

問題点:

  • builtins.getEnvはビルド時に評価されますが、環境変数はランタイムで変わる可能性があります
  • Nixの純粋性原則に反し、再現性が損なわれる可能性があります

推奨修正:

# Option 1: スクリプトでランタイム検出
copyCommand = pkgs.writeShellScript "copy" ''
  if command -v wl-copy &> /dev/null && [ -n "$WAYLAND_DISPLAY" ]; then
    wl-copy
  elif command -v xclip &> /dev/null; then
    xclip -selection clipboard
  else
    echo "No clipboard tool found" >&2
    exit 1
  fi
'';

# Option 2: 利用可能なツールをすべてインストールし、wrapper scriptで判定

2. バグ: personal変数のスコープ問題 🐛

flake.nix:107flake.nix:125${personal.hostname}を参照していますが、Linuxシステムではpersonalがスコープ外の可能性があります。

# Line 107
sudo ${darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .#${personal.hostname}

# Line 125
nix build .#darwinConfigurations.${personal.hostname}.system

NixOSやHome Manager構成がコメントアウトされている場合、personalは定義されていない可能性があります。

推奨修正:

apps = lib.forAllSystems (system:
  let
    pkgs = import nixpkgs { inherit system; };
    isDarwin = pkgs.stdenv.isDarwin;
    # personalが存在しない場合のフォールバック
    hostname = if personal ? hostname then personal.hostname else "unknown";
  in
  {
    # ... hostname を使用
  }
);

3. 型安全性: NixOS build コマンドのパス 🔍

flake.nix:131-133でNixOSビルドを試みるロジックがありますが、personal.usernamepersonal.hostnameの参照が失敗する可能性があります:

if nix build .#nixosConfigurations.${personal.hostname}.config.system.build.toplevel 2>/dev/null; then
  echo "NixOS build successful!"
elif nix build .#homeConfigurations.${personal.username}@${personal.hostname}.activationPackage 2>/dev/null; then

推奨修正:

  • 環境変数からhostnameusernameを取得
  • または、これらのコマンドを実行する前に構成が存在するかチェック

4. Windows対応の懸念 📝

windows/ディレクトリが追加されましたが:

良い点:

  • wingetによる宣言的パッケージ管理
  • WSL2セットアップへの明確なパス

改善案:

  • windows/README.mdにWSL2でのNixインストール後の具体的な手順を追加
  • PowerShellスクリプトのエラーハンドリングを強化(例:部分的な失敗時の処理)
  • packages.jsonの各パッケージにコメントを追加(なぜ必要か)

5. パフォーマンス考慮

lib/default.nix:14forAllSystemsは4つのシステムすべてでappsを生成しますが、実際に使用するのは1つだけです。これは問題ありませんが、大規模なプロジェクトではビルド時間に影響する可能性があります。

6. ドキュメントの不足 📚

  • CLAUDE.mdにマルチプラットフォーム対応後の新しいワークフローが反映されていません
  • NixOS/Linux/WSL2ユーザー向けのセットアップ手順が必要です
  • lib/mk*.nix関数のdocstringがあると良いでしょう

推奨追加:

## プラットフォーム別セットアップ

### macOS (nix-darwin)
```bash
nix run .#switch

NixOS

sudo nixos-rebuild switch --flake .#hostname

Linux / WSL2 (standalone Home Manager)

home-manager switch --flake .#user@hostname

## テストカバレッジ 🧪

**必要なテスト:**
1. ✅ macOS (Darwin) ビルドテスト: `nix run .#build`
2. ❓ NixOS構成の構文チェック(構成がコメントアウトされているため未テスト)
3. ❓ Home Manager standalone構成の構文チェック(構成がコメントアウトされているため未テスト)
4. ❓ プラットフォーム検出ロジックのテスト

**推奨アクション:**
- CIでビルドテストを追加(異なるプラットフォーム向け)
- 少なくとも1つのLinux/NixOS構成をコメント解除してテスト

## セキュリティ考慮事項 🔒

1. **環境変数の注入リスク**: 前述の`builtins.getEnv`の問題
2. **PowerShellスクリプトの実行**: `windows/setup.ps1`は管理者権限で実行されるため、慎重にレビュー済み(問題なし)
3. **Unfreeパッケージ**: `allowUnfree = true`が複数箇所にありますが、これは意図的と思われます

## 全体評価

| カテゴリ | 評価 | コメント |
|---------|------|---------|
| コード品質 | ⭐⭐⭐⭐⭐ | 非常に明確で保守しやすい |
| アーキテクチャ | ⭐⭐⭐⭐⭐ | 優れたモジュール設計 |
| セキュリティ | ⭐⭐⭐⭐ | 小さな改善の余地あり |
| テストカバレッジ | ⭐⭐⭐ | 追加テストが望ましい |
| ドキュメント | ⭐⭐⭐ | 更新が必要 |

## 推奨アクション

### 必須 (マージ前)
1. クリップボードコマンドの`builtins.getEnv`問題を修正
2. `personal`変数のスコープ問題を修正

### 推奨 (マージ後)
1. `CLAUDE.md`をマルチプラットフォーム対応に更新
2. NixOS/Linux用のCIテストを追加
3. Windows/WSL2セットアップドキュメントを拡充

## 結論

このPRは非常に良く設計された大規模リファクタリングです。いくつかの小さな問題がありますが、全体的にはマージ可能な品質です。上記の必須修正を行った後、マージすることをお勧めします。

素晴らしい仕事です!🎉

@claude
Copy link

claude bot commented Jan 26, 2026

PR #7 レビュー: マルチプラットフォーム対応

概要

macOS専用のdotfilesを、Linux(NixOS/非NixOS)、WSL2まで対応させる大規模なリファクタリングです。全体的に非常に良い設計で、モジュール化とプラットフォーム抽象化が適切に実装されています。

✅ 良い点

1. アーキテクチャ設計

  • モジュール化: modules/{common,darwin,nixos} の分離が明確で保守性が高い
  • DRY原則: modules/common/nix.nix で共通設定を一元化
  • ヘルパー関数: lib/ 配下の mkDarwinSystem, mkNixosSystem, mkHomeConfig が再利用性を高めている
  • プラットフォーム検出: pkgs.stdenv.isDarwin/isLinux を使った条件分岐が適切

2. コード品質

  • 一貫性: 既存のNix-Firstポリシーを維持しつつマルチプラットフォーム化
  • 可読性: コメントが充実し、テンプレートファイル (machines/*/example.nix) で使い方が明確
  • 型安全性: Nixの型システムを活用した実装

3. プラットフォーム対応

  • クリップボード: pbcopy / wl-copy / xclip の自動切り替え(home/programs/fzf.nix:780-782, home/xdg.nix:807-811
  • パッケージ分離: Linux固有パッケージ(xclip, inotify-tools等)をLinuxのみにインストール(home/packages.nix:726-762
  • ホームディレクトリ: /Users vs /home の自動判定(home/default.nix:13-15

⚠️ 改善提案

1. セキュリティ懸念

🔴 高: Wayland検出の脆弱性

場所: home/programs/fzf.nix:782, home/xdg.nix:809-811

問題点:

  • builtins.getEnv はビルド時評価のため、ビルド環境の環境変数を参照してしまう
  • 実行時にWayland/X11が切り替わっても対応できない
  • ビルドキャッシュの汚染リスク

推奨修正: ランタイムスクリプトで判定するか、両方のツールをインストールして自動フォールバック

2. パフォーマンス最適化

🟡 中: 不要な lib パラメータ

場所: lib/default.nix:30,35,40

mk*System.nix ファイルは nixpkgs.lib を直接参照可能なので、lib パラメータは不要です。

3. コード品質

🟡 中: Windows設定ファイルの配置

場所: windows/ ディレクトリ全体

Nixプロジェクトに非Nix(PowerShell)のセットアップが混在しています。別リポジトリ化するか、.github/workflows/ に配置してCI/CD統合を明確化することを推奨します。

🟢 低: flake.nixのコメントアウトコード

場所: flake.nix:435-463

50行以上のコメントアウトコードは可読性を下げるため、docs/examples/ に移動することを推奨します。

4. 潜在的バグ

🟡 中: NixOS locale設定のハードコード

場所: modules/nixos/default.nix:1506-1520

time.timeZone = "Asia/Tokyo"; がハードコードされています。personal.timezone フィールドを追加し、personal.timezone or "Asia/Tokyo" とすることを推奨します。

📊 統計

  • 追加: 1051行
  • 削除: 505行
  • 正味: +546行
  • 変更ファイル: 23ファイル
  • 新規ディレクトリ: lib/, modules/, windows/

🧪 テスト推奨項目

ビルドテスト

  • Darwin: nix run .#build
  • NixOS: nix build .#nixosConfigurations.example.config.system.build.toplevel
  • Home Manager: nix build .#homeConfigurations."user@host".activationPackage

動作確認

  1. クリップボード: Wayland/X11環境でfzfの Ctrl-Y が動作するか
  2. Linuxパッケージ: xclip等がLinuxのみにインストールされるか
  3. ホームディレクトリ: /Users vs /home が正しく設定されるか

📝 ドキュメント更新推奨

現在のCLAUDE.mdはmacOS中心の記述なので、マルチプラットフォーム対応の情報を追加すべきです。

🎯 総合評価

  • コード品質: ⭐⭐⭐⭐☆ (4/5) - モジュール設計が優秀
  • セキュリティ: ⭐⭐⭐☆☆ (3/5) - builtins.getEnv の誤用が重大
  • 保守性: ⭐⭐⭐⭐⭐ (5/5) - 非常に良いモジュール分割
  • ドキュメント: ⭐⭐⭐☆☆ (3/5) - プロジェクトドキュメント更新が必要

✅ マージ推奨度: 条件付き承認

必須修正:

  1. Wayland検出の builtins.getEnv 問題を修正

推奨修正:

  1. 不要な lib パラメータを削除
  2. NixOS locale設定を柔軟化
  3. CLAUDE.mdにマルチプラットフォーム情報を追加

上記の必須修正を実施後、マージを推奨します。素晴らしいリファクタリングです!

@ta93abe ta93abe force-pushed the 01-26-feat_add_multi-platform_support_for_macos_linux_and_wsl2 branch from a215644 to c0726dc Compare January 26, 2026 12:19
@claude
Copy link

claude bot commented Jan 26, 2026

コードレビュー: マルチプラットフォーム対応

全体として非常によく設計されたリファクタリングです。macOS専用の構成からマルチプラットフォーム対応への移行が適切に行われています。以下、詳細なフィードバックをお伝えします。

✅ 良い点

1. アーキテクチャ設計

  • モジュラー設計が優れており、modules/{common,darwin,nixos} の分離が明確
  • lib/ ディレクトリのヘルパー関数 (mkDarwinSystem, mkNixosSystem, mkHomeConfig) が再利用性を高めている
  • 設定の重複を排除し、DRY原則に従っている

2. プラットフォーム検出

isDarwin = pkgs.stdenv.isDarwin;
isLinux = pkgs.stdenv.isLinux;
  • プラットフォーム固有の設定(homeDirectory, clipboard コマンド)が適切に分岐
  • lib.optionals を使った条件付きパッケージ追加が美しい

3. ドキュメント

  • README が大幅に改善され、各プラットフォームのセットアップ手順が明確
  • トラブルシューティングセクションが実用的

4. nixpkgs URL の変更

# Before: nixpkgs-24.11-darwin
# After:  nixos-24.11
  • Darwin と NixOS の両方をサポートする適切な選択

🔧 改善提案

1. flake.nixapps セクションにバグの可能性

問題箇所 (flake.nix:107, flake.nix:125, flake.nix:133):

program = toString (pkgs.writeShellScript "switch" (
  if isDarwin then ''
    sudo ${darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .#${personal.hostname}
  '' else ''
    # ...
  ''
));

問題点:

  • appslib.forAllSystems で全プラットフォーム用に生成されるが、Linux システムでは personal.hostname が未定義の可能性がある
  • darwin.packages.${system} は Linux システムでは存在しないため、評価時にエラーになる可能性

修正案:

apps = lib.forAllSystems (system:
  let
    pkgs = import nixpkgs { inherit system; };
    isDarwin = pkgs.stdenv.isDarwin;
    # personal が定義されているか確認
    hasPersonal = builtins.pathExists ./personal.nix;
  in
  {
    switch = {
      type = "app";
      program = toString (pkgs.writeShellScript "switch" (
        if isDarwin && hasPersonal then ''
          set -e
          echo "Building and switching to new Darwin configuration..."
          sudo ${darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .#${personal.hostname}
          echo "Done!"
        '' else if isDarwin then ''
          echo "Error: personal.nix not found. Copy personal.nix.example to personal.nix"
          exit 1
        '' else ''
          set -e
          echo "Error: Use 'sudo nixos-rebuild switch --flake .#hostname' for NixOS"
          echo "Or use 'home-manager switch --flake .#user@hostname' for standalone Home Manager"
          exit 1
        ''
      ));
    };
    # ...
  }
);

または、personal への参照を遅延評価させる方法も検討してください。

2. home/xdg.nix のクリップボード検出

問題箇所 (home/xdg.nix:8-10, home/programs/fzf.nix:8-10):

copyCommand = if isDarwin then "pbcopy"
  else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
  else "xclip -selection clipboard";

問題点:

  • builtins.getEnv はビルド時に評価されるため、実行時の環境変数を正しく取得できない
  • Wayland 環境でも常に xclip にフォールバックする可能性

修正案:

# オプション1: シェルスクリプトで実行時に判定
copyCommand = if isDarwin then "pbcopy"
  else "sh -c 'if [ -n \"$WAYLAND_DISPLAY\" ]; then wl-copy; else xclip -selection clipboard; fi'";

# オプション2: 両方のコマンドをインストールし、aliasで制御
# home/programs/fish.nix などでaliasを定義

3. machines/*/example.nix のテンプレート

問題箇所 (machines/linux/example.nix:27-31, machines/nixos/example.nix:28-34):

assertions = [
  {
    assertion = true;
    message = "machines/linux/example.nix is a template file.";
  }
];

問題点:

  • assertion = true は常に成功するため、この assertion は意味がない
  • ユーザーがテンプレートをそのまま使った場合に警告されない

修正案:

# ファイルの存在チェックで実際に使用されているか判定
assertions = [
  {
    assertion = builtins.pathExists (./. + "/${personal.hostname}.nix");
    message = "Please create machines/linux/${personal.hostname}.nix from example.nix template";
  }
];

または、コメントアウトされた状態で提供し、ユーザーが有効化する形にする。

4. セキュリティ考慮事項

Windows の setup.ps1 (windows/setup.ps1:20-23):

$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
    Write-Host "Warning: Some packages may require Administrator privileges." -ForegroundColor Yellow
}

提案:

  • 管理者権限が必要な場合は、明示的に要求する方が安全
  • または、管理者権限が必要なパッケージのリストを明示する

5. パフォーマンス最適化

lib/default.nix:17-22:

mkUnstableOverlay = system: (final: prev: {
  unstable = import nixpkgs-unstable {
    inherit system;
    config.allowUnfree = true;
  };
});

考慮点:

  • unstable を使用しない場合でも、常に nixpkgs-unstable 全体がインポートされる
  • 遅延評価を検討してください(ただし、Nix の評価モデル上、大きな違いはないかもしれません)

🔍 テストカバレッジ

不足している検証:

  1. NixOS および Linux standalone 設定の実機テスト

    • テンプレートが実際に動作するか未検証
    • CI/CD パイプラインでのビルドテストを推奨
  2. Windows のパッケージリスト

    • windows/packages.json が実際にすべてインストールできるか要確認
    • 一部のパッケージ ID が変更されている可能性

推奨テスト:

# macOS
nix run .#build
nix flake check

# NixOS (VM でテスト)
nixos-rebuild build-vm --flake .#example

# home-manager standalone (Docker でテスト)
docker run -it nixos/nix

📊 コード品質指標

項目 評価 備考
モジュール化 ⭐⭐⭐⭐⭐ 優れた設計
可読性 ⭐⭐⭐⭐⭐ コメントが適切
保守性 ⭐⭐⭐⭐ テンプレートの扱いに改善余地
移植性 ⭐⭐⭐⭐ 実機テストが必要
セキュリティ ⭐⭐⭐⭐ 大きな問題なし

🎯 優先度付き TODO

高優先度

  • flake.nixapps セクションで Linux 環境での personal.hostname 参照を修正
  • クリップボードコマンドの実行時判定を実装

中優先度

  • NixOS 設定の実機テスト
  • テンプレートファイルの assertion を実用的に修正

低優先度

  • Windows setup.ps1 の管理者権限チェックを厳格化
  • CI/CD での multi-platform ビルドテスト追加

🎉 総評

素晴らしいリファクタリングです!特に以下の点が評価できます:

  1. 段階的な移行: macOS の既存設定を壊さずに、Linux/WSL2 対応を追加
  2. ドキュメント充実: セットアップガイドが各プラットフォームで明確
  3. Nix-First 哲学の維持: Homebrew を GUI アプリのみに制限する方針が一貫

上記の改善提案を反映すれば、さらに堅牢な構成になると思います。特に flake.nixapps セクションのバグは早めに修正することをお勧めします。

Great work! 🚀

…n build

Address review feedback from gemini-code-assist:
- Remove 2>/dev/null that hides legitimate build errors
- Show explicit instructions for NixOS and Home Manager builds
@ta93abe ta93abe force-pushed the 01-26-feat_add_multi-platform_support_for_macos_linux_and_wsl2 branch from c0726dc to 7d67550 Compare January 26, 2026 12:36
@claude
Copy link

claude bot commented Jan 26, 2026

PR レビュー: マルチプラットフォーム対応

全体的に非常によく設計されたリファクタリングです。モノリシックな設定ファイルをモジュール化し、複数プラットフォームに対応する構造に変更されています。


✅ 良い点

1. 優れたアーキテクチャ設計

  • モノリシックな darwin-configuration.nixhome.nixmodules/lib/ に分割
  • プラットフォーム別に設定を分離(modules/{darwin,nixos,common}
  • DRYの原則に従ったヘルパー関数(mkDarwinSystem, mkNixosSystem, mkHomeConfig

2. 適切なプラットフォーム検出

  • home/default.nix:26-32: プラットフォームに応じた homeDirectory の切り替え
  • home/packages.nix:76-112: Linux専用パッケージとmacOS専用パッケージの分離
  • home/programs/fzf.nix:6-9: クリップボードコマンドの自動検出(Wayland/X11対応)

3. 包括的なドキュメント

  • README.mdに各プラットフォームのセットアップ手順を詳細に記載
  • テンプレートファイル(machines/{nixos,linux}/example.nix)の提供
  • Windowsユーザー向けのwingetセットアップスクリプト

🔍 改善提案

1. nixpkgs URL変更の影響 (flake.nix:5)

-    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin";
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";

潜在的な問題:

  • nixpkgs-24.11-darwin から nixos-24.11 への変更により、一部のmacOS最適化パッケージが影響を受ける可能性があります
  • nixos-24.11 はNixOS向けにテストされていますが、Darwinでの動作検証が不足している可能性があります

推奨事項:

# 明示的にDarwin用とNixOS用を分ける方が安全
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin";
nixpkgs-nixos.url = "github:NixOS/nixpkgs/nixos-24.11";

2. 環境変数によるクリップボード検出の脆弱性 (home/programs/fzf.nix:8, home/xdg.nix:9)

else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"

問題点:

  • ビルド時に builtins.getEnv を使用すると、ビルド環境の値が使われてしまい、実行時の環境を反映しません
  • 再現性が損なわれ、Nixの純粋性原則に反します

推奨修正:

# ランタイムで切り替えるラッパースクリプトを使用
copyCommand = pkgs.writeShellScript "clipboard-copy" ''
  if [ -n "$WAYLAND_DISPLAY" ]; then
    wl-copy "$@"
  else
    xclip -selection clipboard "$@"
  fi
'';

3. NixOS設定のハードコーディング (modules/nixos/default.nix:21, 25-35)

time.timeZone = "Asia/Tokyo";
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
  LC_ADDRESS = "ja_JP.UTF-8";
  # ...
};

問題点:

  • タイムゾーンとロケールが日本に固定されています
  • 他の地域のユーザーが使用する場合、設定を変更する必要があります

推奨修正:

# personal.nixに追加
{
  timezone = "Asia/Tokyo";
  locale = "en_US.UTF-8";
}

# modules/nixos/default.nixで使用
time.timeZone = personal.timezone or "UTC";
i18n.defaultLocale = personal.locale or "en_US.UTF-8";

4. flake.nix の apps 定義の型安全性 (flake.nix:905-942)

apps = lib.forAllSystems (system:
  let
    pkgs = import nixpkgs { inherit system; };
    isDarwin = pkgs.stdenv.isDarwin;

潜在的な問題:

  • personal 変数が apps スコープ内で使用されていますが(line 920, 948)、Linuxシステムでは定義されていません
  • Linuxユーザーが nix run .#build を実行するとエラーになります

推奨修正:

# personal が定義されているかチェック
program = toString (pkgs.writeShellScript "build" (
  if isDarwin && personal ? hostname then ''
    # Darwin build logic
  '' else ''
    echo "Error: 'build' app is not supported..." >&2

5. Windows setup.ps1 のエラーハンドリング (windows/setup.ps1:14-16)

if (-not $isAdmin) {
    Write-Host "Warning: Some packages may require Administrator privileges." -ForegroundColor Yellow
}

問題点:

  • 警告のみで続行すると、一部のパッケージインストールが失敗する可能性があります

推奨修正:

if (-not $isAdmin) {
    Write-Host "Error: This script must be run as Administrator." -ForegroundColor Red
    Write-Host "Please right-click and select 'Run as Administrator'." -ForegroundColor Yellow
    exit 1
}

6. パッケージの重複 (modules/darwin/default.nix:23-54, modules/nixos/default.nix:49-65)

git, curl, wget, gnupg, openssl などがシステムレベルとHome Managerの両方でインストールされる可能性があります。

推奨事項:

  • システムレベルは最小限にし、ユーザーレベルのツールはHome Managerに統一
  • または明確にコメントで区別する

🔒 セキュリティに関する考慮事項

1. NixOS ユーザーのsudoアクセス (modules/nixos/default.nix:41)

extraGroups = [ "networkmanager" "wheel" "docker" ];
  • wheel グループへの追加は適切です
  • docker グループは rootless docker の場合は不要な可能性があります

2. personal.nix の取り扱い

  • .gitignore で適切に除外されていることを確認してください
  • 個人情報(メールアドレス、名前)が含まれるため

📊 テストカバレッジ

テストが推奨される項目:

  1. ✅ Darwin (Apple Silicon) - 既存マシンで検証済み
  2. ⚠️ Darwin (Intel) - 実機テストが必要
  3. ⚠️ NixOS - テンプレートのみ、実機テストが必要
  4. ⚠️ 非NixOS Linux - テンプレートのみ、実機テストが必要
  5. ⚠️ WSL2 - テンプレートのみ、実機テストが必要

推奨アクション:

  • GitHub Actions でビルドテストを追加
  • 各プラットフォームでの nix flake check の実行

🎯 パフォーマンスに関する考慮事項

forAllSystems の使用 (lib/default.nix:14)

forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems f;
  • すべてのシステムアーキテクチャに対してappsを生成していますが、現在使用していないシステムでも評価されます
  • 大きな問題ではありませんが、必要なシステムのみ定義する方が効率的です

📝 その他の細かい点

  1. machines/darwin/000355-M.nix は空ファイル

    • マシン固有の設定がない場合でも、コメントで説明を追加すると良いでしょう
  2. example.nix のアサーション (machines/nixos/example.nix:28-33)

    assertions = [
      {
        assertion = true;
        message = "machines/nixos/example.nix is a template file.";
      }
    ];
    • 常に true なので意味がありません
    • テンプレートであることを示すなら、READMEコメントで十分です
  3. Windows packages.json の日付 (windows/packages.json:2)

    • CreationDate が手動管理されています
    • 自動生成する方が良いでしょう

総評

Score: 9/10

非常に質の高いリファクタリングで、以下の点が特に優れています:

  • ✅ クリーンなアーキテクチャと関心の分離
  • ✅ 優れたドキュメント
  • ✅ 将来の拡張性を考慮した設計
  • ✅ Nix-First 哲学の一貫性

主な改善点:

  • 🔧 環境変数の扱い(ビルド時 vs ランタイム)
  • 🔧 nixpkgs URL の選択
  • 🔧 ハードコーディングされた設定の柔軟化

マージ判断:
上記の改善提案のうち、最低限 #2(クリップボード検出)#4(personal変数のスコープ) を修正することを推奨します。その他は後続のPRで対応可能です。

Great work! 🎉

@ta93abe ta93abe marked this pull request as ready for review January 26, 2026 12:41
Copilot AI review requested due to automatic review settings January 26, 2026 12:41
@ta93abe ta93abe merged commit 6c2c3c4 into main Jan 26, 2026
5 of 6 checks passed
@ta93abe ta93abe deleted the 01-26-feat_add_multi-platform_support_for_macos_linux_and_wsl2 branch January 26, 2026 12:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a modular, multi-platform dotfiles setup to support macOS (nix-darwin), NixOS, standalone Home Manager on Linux/WSL2, and Windows (winget).

Changes:

  • Restructures configuration into modules/{common,darwin,nixos}, machines/{darwin,nixos,linux}, and adds system builder helpers in lib/.
  • Modularizes the Home Manager entry point and adds platform-specific behaviors (home directory, clipboard integration).
  • Adds Windows bootstrap scripts (winget) and updates top-level documentation for multi-platform setup.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
windows/setup.ps1 Adds a winget-based Windows setup script to import a declarative package list.
windows/packages.json Declares Windows packages to install via winget import.
windows/README.md Documents Windows + WSL2 setup flow.
modules/nixos/default.nix Adds a baseline NixOS module with common settings, packages, users, and fonts.
modules/darwin/system.nix Extracts macOS system defaults and security settings into a dedicated module.
modules/darwin/homebrew.nix Extracts Homebrew (casks/taps) configuration into a dedicated module.
modules/darwin/default.nix New macOS entry module composing common nix + system + homebrew modules.
modules/common/nix.nix Introduces shared Nix settings (flakes, GC, store optimization).
machines/nixos/example.nix Provides a template NixOS machine configuration scaffold.
machines/linux/example.nix Provides a template standalone Home Manager machine configuration scaffold.
machines/darwin/000355-M.nix Adds a placeholder macOS machine-specific module.
lib/mkSystem.nix Removes legacy (unused) mkSystem helper.
lib/mkNixosSystem.nix Adds a helper to build NixOS systems with Home Manager integration.
lib/mkHomeConfig.nix Adds a helper to build standalone Home Manager configurations.
lib/mkDarwinSystem.nix Adds a helper to build nix-darwin systems with Home Manager integration.
lib/default.nix Adds shared lib utilities (supported systems, overlays, system builders).
home/xdg.nix Adds platform-aware clipboard command injection into terminal configs.
home/programs/fzf.nix Adds platform-aware clipboard binding for fzf.
home/packages.nix Splits packages into common + darwin + linux sets and conditionally includes them.
home/default.nix Adds new Home Manager entry point with platform-aware homeDirectory.
home.nix Removes old Home Manager entry point (replaced by home/default.nix).
flake.nix Switches to nixos-24.11 nixpkgs, adopts new lib helpers, and expands structure for multi-platform outputs.
darwin-configuration.nix Removes monolithic macOS config (replaced by modules/darwin/*).
README.md Updates documentation for multi-platform usage, setup flows, and new project structure.
Comments suppressed due to low confidence (1)

flake.nix:21

  • The darwin and home-manager flake inputs reference third-party GitHub repositories (LnL7/nix-darwin and nix-community/home-manager) only by branch/tag name without an accompanying immutable pin (e.g., via flake.lock or a commit SHA), which creates a supply-chain risk. If either upstream repo is compromised or a malicious update is pushed to those branches, running nix run .#switch or related commands would fetch and execute untrusted code with your local user (and often root) privileges. To harden this, ensure these inputs are pinned via a committed flake.lock or switch the URLs to immutable identifiers (specific commit hashes or content-addressed references) so that updates are explicit and reviewable.
    # nix-darwin for macOS
    darwin = {
      url = "github:LnL7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    # Home Manager
    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +6 to +9
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
else "xclip -selection clipboard";
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using builtins.getEnv("WAYLAND_DISPLAY") to choose between wl-copy and xclip is evaluated at Nix evaluation time (flakes default to pure evaluation), so this will typically always be "" and select xclip even on Wayland. Prefer runtime detection (e.g., a small wrapper script that checks $WAYLAND_DISPLAY) or a Home Manager/NixOS option-based switch rather than builtins.getEnv here.

Suggested change
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
else "xclip -selection clipboard";
# Runtime-detected clipboard command for non-Darwin platforms
copyScript = pkgs.writeShellScriptBin "fzf-copy" ''
if [ -n "$WAYLAND_DISPLAY" ] && command -v wl-copy >/dev/null 2>&1; then
exec wl-copy "$@"
elif command -v xclip >/dev/null 2>&1; then
exec xclip -selection clipboard "$@"
else
echo "No clipboard utility found (need wl-copy or xclip)" >&2
exit 1
fi
'';
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else "${copyScript}/bin/fzf-copy";

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +7
{ system, personal, overlays ? [] }:

home-manager.lib.homeManagerConfiguration {
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkHomeConfig doesn’t allow callers to pass extra Home Manager modules (no modules ? [] parameter), which makes it hard to extend per-machine/per-host without editing this helper. Consider adding an optional modules argument and appending it to the modules list.

Copilot uses AI. Check for mistakes.
users.users.${personal.username} = {
isNormalUser = true;
description = personal.name;
extraGroups = [ "networkmanager" "wheel" "docker" ];
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

users.users..extraGroups includes "docker", but this module never enables Docker (virtualisation.docker.enable) or defines the docker group. On NixOS this commonly causes evaluation/activation failures due to a missing group. Either enable Docker here or remove "docker" from extraGroups and let machine-specific configs add it when needed.

Suggested change
extraGroups = [ "networkmanager" "wheel" "docker" ];
extraGroups = [ "networkmanager" "wheel" ];

Copilot uses AI. Check for mistakes.
"homebrew/cask-versions"
];

# Note: CLI tools are managed via Nix packages in home.nix
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment still references "home.nix", but the Home Manager entry point is now the ./home directory (home/default.nix). Please update this comment to avoid confusion.

Suggested change
# Note: CLI tools are managed via Nix packages in home.nix
# Note: CLI tools are managed via Nix packages in the Home Manager configuration (./home, e.g. home/default.nix)

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +36
# Ubuntu(デフォルト)が起動したら、Nixをインストール
curl -L https://nixos.org/nix/install | sh
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WSL2 section installs Nix via curl -L https://nixos.org/nix/install | sh, while the main README recommends Determinate Systems. Consider aligning on one installer (or explicitly documenting why they differ) to avoid inconsistent setup guidance.

Suggested change
# Ubuntu(デフォルト)が起動したら、Nixをインストール
curl -L https://nixos.org/nix/install | sh
# Ubuntu(デフォルト)が起動したら、Nixをインストール(Determinate Systems インストーラーを使用)
curl -L https://install.determinate.systems/nix | sh

Copilot uses AI. Check for mistakes.
Comment on lines +315 to +317
# 詳細なエラー表示
nix run .#build 2>&1 | less

Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix run .#build is documented here as a generic way to inspect build errors, but flake.nix intentionally errors on non-Darwin systems for the build app. Please qualify this as macOS-only or update the instructions to use the explicit nix build .#nixosConfigurations... / nix build .#homeConfigurations... commands for Linux.

Suggested change
# 詳細なエラー表示
nix run .#build 2>&1 | less
# macOS (nix-darwin) の場合: 詳細なエラー表示
nix run .#build 2>&1 | less
# NixOS の場合: システム構成をビルド
nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel --show-trace
# 非NixOS Linux / WSL2 の場合: home-manager 構成をビルド
nix build .#homeConfigurations."<user>@<host>".activationPackage --show-trace

Copilot uses AI. Check for mistakes.
# Usage:
# nix run .#switch - Build and apply configuration
# nix run .#switch - Build and apply configuration (Darwin)
# nix run .#build - Build only (test)
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage comment advertises nix run .#build as a generic build/test command, but the build app intentionally exits with an error on non-Darwin systems below. Consider updating this comment to clarify it’s Darwin-only (or extend the app to support NixOS/home-manager builds).

Suggested change
# nix run .#build - Build only (test)
# nix run .#build - Build only (Darwin test; use explicit nix build on NixOS/Home Manager)

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +10
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
else "xclip -selection clipboard";
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in fzf.nix: builtins.getEnv("WAYLAND_DISPLAY") is evaluated during Nix evaluation, so Wayland sessions will usually not be detected and copy_command will default to xclip. Consider making copy_command a runtime check (wrapper script) instead of using builtins.getEnv.

Suggested change
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy"
else "xclip -selection clipboard";
# Runtime wrapper for clipboard command on non-Darwin systems
copyCommandBin = pkgs.writeShellScriptBin "clipboard-copy" ''
if [ -n "$WAYLAND_DISPLAY" ]; then
exec wl-copy "$@"
else
exec xclip -selection clipboard "$@"
fi
'';
# Platform-specific clipboard command
copyCommand = if isDarwin then "pbcopy"
else "${copyCommandBin}/bin/clipboard-copy";

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +24
modules = [
../home

# Machine-specific Home Manager configuration (optional)
# Uncomment if you have machine-specific home configs
# (../machines/linux + "/${personal.hostname}.nix")
];
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Machine-specific Home Manager config for Linux (machines/linux/.nix) is commented out here, so creating those files (as suggested by machines/linux/example.nix / README) will have no effect. Either import it (optionally guarded by builtins.pathExists) or document that users must wire it in themselves.

Suggested change
modules = [
../home
# Machine-specific Home Manager configuration (optional)
# Uncomment if you have machine-specific home configs
# (../machines/linux + "/${personal.hostname}.nix")
];
modules =
let
machineModulePath = ../machines/linux + "/${personal.hostname}.nix";
in
[ ../home ]
++ lib.optional (builtins.pathExists machineModulePath) machineModulePath;

Copilot uses AI. Check for mistakes.
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.

2 participants