Skip to content

クロスプラットフォーム対応 #58

@toku345

Description

@toku345

概要

macOS専用の設定をLinux/WSLでも動作するように拡張し、複数環境での利用を可能にする。

現状の課題

  • macOS専用の設定が多い(Homebrew、defaults writeなど)
  • Linuxでのセットアップ手順がない
  • OS固有の条件分岐が実装されていない

提案内容

1. OS別の設定分岐

.chezmoi.toml.tmpl:

encryption = "age"

{{- if eq .chezmoi.os "darwin" }}
# macOS specific settings
[darwin]
  homebrew_prefix = "/opt/homebrew"
{{- else if eq .chezmoi.os "linux" }}
# Linux specific settings  
[linux]
  package_manager = "apt"  # or "yum", "pacman", etc.
{{- end }}

[age]
identity = "~/key.txt"
recipient = "age13nd6rta5xqx4prnsggkmsdrcs3dp6ysszncmshyya67r357gua5s0k8gy7"

[edit]
command = "{{ if lookPath "code" }}code{{ else }}vim{{ end }}"
args = ["--wait"]

2. OS別セットアップスクリプト

# .chezmoiscripts/run_once_before_install-packages.sh.tmpl
{{- if eq .chezmoi.os "darwin" }}
# macOS
brew bundle --file="${HOME}/.local/share/chezmoi/Brewfile"
{{- else if eq .chezmoi.os "linux" }}
# Linux
{{ if eq .chezmoi.osRelease.id "ubuntu" }}
sudo apt-get update
sudo apt-get install -y git fish starship fzf ...
{{ else if eq .chezmoi.osRelease.id "fedora" }}
sudo dnf install -y git fish starship fzf ...
{{ end }}
{{- end }}

3. Fish設定の条件分岐

# conf.d/10-package-manager.fish.tmpl
{{- if eq .chezmoi.os "darwin" }}
# Homebrew (macOS)
test -e /opt/homebrew/bin/brew; and eval (/opt/homebrew/bin/brew shellenv)
{{- else if eq .chezmoi.os "linux" }}
# Linuxbrew / システムパッケージ
test -e /home/linuxbrew/.linuxbrew/bin/brew; and eval (/home/linuxbrew/.linuxbrew/bin/brew shellenv)
{{- end }}

4. macOS固有設定の分離

# .chezmoiscripts/darwin/run_once_setup-macos-defaults.sh
# macOS専用の設定(defaultsコマンドなど)
defaults write com.apple.dock autohide -bool true
...

5. 対応OS

  • macOS (Apple Silicon & Intel)
  • Ubuntu / Debian
  • Fedora / RHEL
  • Arch Linux
  • WSL2 (Ubuntu)

期待される効果

  • 複数のマシン(Mac、Linux)で同一のdotfilesを利用可能
  • 環境ごとの設定を1つのリポジトリで管理
  • 新しいLinuxマシンのセットアップが容易に

優先度

Low

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions