diff --git a/README.md b/README.md index 384b42b..ddcf660 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ # dotfiles -**nix-darwin** と **home-manager** で管理する個人用dotfiles +**Nix** で管理するマルチプラットフォーム対応dotfiles -## セットアップ +macOS、Linux(NixOS / 非NixOS)、WSL2 に対応した宣言的・再現可能な開発環境を構築します。 + +## 対応プラットフォーム + +| プラットフォーム | 管理ツール | 状態 | +|-----------------|-----------|------| +| macOS (Apple Silicon) | nix-darwin + home-manager | ✅ | +| macOS (Intel) | nix-darwin + home-manager | ✅ | +| Linux (NixOS) | NixOS + home-manager | 🚧 テンプレート | +| Linux (非NixOS) | standalone home-manager | 🚧 テンプレート | +| WSL2 | standalone home-manager | 🚧 テンプレート | +| Windows | winget | ✅ | + +--- + +## クイックスタート + +### macOS ```bash -# 1. Nixをインストール +# 1. Nixをインストール(Determinate Systems推奨) curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install # 2. クローン @@ -14,57 +31,265 @@ cd ~/.dotfiles # 3. 個人設定を作成 cp personal.nix.example personal.nix -# personal.nix を編集(hostname, username, git設定) +vim personal.nix # hostname, username, git設定を編集 # 4. 適用 nix run .#switch -# 5. Fishをデフォルトシェルに +# 5. Fishをデフォルトシェルに設定 echo $(which fish) | sudo tee -a /etc/shells chsh -s $(which fish) ``` +### Linux(非NixOS / WSL2) + +```bash +# 1. Nixをインストール +curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install + +# 2. クローン +git clone https://github.com/ta93abe/dotfiles.git ~/.dotfiles +cd ~/.dotfiles + +# 3. 個人設定を作成 +cp personal.nix.example personal.nix +vim personal.nix # hostname, username を編集 + +# 4. flake.nixのhomeConfigurationsを有効化して設定 +# (コメントアウトを解除し、自分の設定を追加) + +# 5. 適用 +home-manager switch --flake .#username@hostname + +# 6. Fishをデフォルトシェルに設定 +echo $(which fish) | sudo tee -a /etc/shells +chsh -s $(which fish) +``` + +### Linux(NixOS) + +```bash +# 1. dotfilesをクローン +git clone https://github.com/ta93abe/dotfiles.git ~/.dotfiles +cd ~/.dotfiles + +# 2. 個人設定を作成 +cp personal.nix.example personal.nix +vim personal.nix + +# 3. マシン設定を作成 +cp machines/nixos/example.nix machines/nixos/$(hostname).nix +# hardware-configuration.nixをインポート + +# 4. flake.nixのnixosConfigurationsを有効化 + +# 5. 適用 +sudo nixos-rebuild switch --flake .#hostname +``` + +### Windows + WSL2 + +```powershell +# === Windows側 === + +# 1. WSL2をインストール +wsl --install + +# 2. dotfilesをクローン +git clone https://github.com/ta93abe/dotfiles.git +cd dotfiles\windows + +# 3. wingetでパッケージをインストール +.\setup.ps1 + +# === WSL2側(Ubuntu)=== +# 上記「Linux(非NixOS / WSL2)」の手順に従う +``` + +--- + ## 日常の使い方 +### macOS + ```bash -nix run .#switch # 設定を適用 -nix run .#build # ビルドのみ(テスト) -nix run .#update # パッケージを更新 +nix run .#switch # 設定を適用 +nix run .#build # ビルドのみ(テスト) +nix run .#update # flake inputsを更新 ``` -## 哲学:Nix-Firstアプローチ +### Linux(NixOS) -- **CLIツール**: 100% Nixで管理(`home/packages.nix`) -- **システム設定**: Nixで管理(`darwin-configuration.nix`) -- **GUIアプリ**: Homebrew Caskで管理(nixpkgsで利用できない場合のみ) +```bash +sudo nixos-rebuild switch --flake .#hostname +sudo nixos-rebuild build --flake .#hostname # テスト +nix flake update # 更新 +``` -## 構造 +### Linux(非NixOS / WSL2) + +```bash +home-manager switch --flake .#username@hostname +home-manager build --flake .#username@hostname # テスト +nix flake update # 更新 +``` + +### ロールバック + +```bash +# macOS +darwin-rebuild rollback + +# NixOS +sudo nixos-rebuild switch --rollback + +# home-manager +home-manager generations # 世代一覧 +home-manager switch --flake .#username@hostname # 再適用 +``` + +--- + +## プロジェクト構造 ``` dotfiles/ -├── flake.nix # エントリポイント -├── darwin-configuration.nix # macOSシステム設定 -├── home.nix # Home Managerエントリポイント -├── personal.nix # 個人設定(gitignored) +├── flake.nix # エントリポイント(マルチシステム対応) +├── personal.nix # 個人設定(gitignored) +├── personal.nix.example # 個人設定テンプレート +│ +├── modules/ +│ ├── common/ +│ │ └── nix.nix # Nix基本設定(共通) +│ ├── darwin/ +│ │ ├── default.nix # macOSエントリ +│ │ ├── system.nix # Dock, Finder, Touch ID, キーボード +│ │ └── homebrew.nix # Homebrew casks(GUIアプリ) +│ └── nixos/ +│ └── default.nix # NixOS共通設定 +│ ├── home/ -│ ├── packages.nix # パッケージリスト -│ ├── xdg.nix # Ghostty, Zellij設定 -│ └── programs/ # 各プログラム設定 -└── machines/ # マシン固有設定 +│ ├── default.nix # Home Managerエントリ +│ ├── packages.nix # パッケージリスト(プラットフォーム分岐) +│ ├── xdg.nix # Ghostty, Zellij設定 +│ └── programs/ # 各プログラム設定 +│ ├── fish.nix +│ ├── git.nix +│ ├── starship.nix +│ ├── helix.nix +│ ├── fzf.nix +│ ├── zoxide.nix +│ ├── mcfly.nix +│ └── claude.nix +│ +├── machines/ +│ ├── darwin/ # macOSマシン固有設定 +│ │ └── 000355-M.nix +│ ├── nixos/ # NixOSマシン固有設定 +│ │ └── example.nix +│ └── linux/ # 非NixOS Linux設定 +│ └── example.nix +│ +├── lib/ # ヘルパー関数 +│ ├── default.nix +│ ├── mkDarwinSystem.nix +│ ├── mkNixosSystem.nix +│ └── mkHomeConfig.nix +│ +└── windows/ # Windows用(winget) + ├── packages.json + ├── setup.ps1 + └── README.md ``` -## パッケージの追加 +--- + +## パッケージ管理 + +### Nix-First ポリシー + +| カテゴリ | macOS | Linux | Windows | +|---------|-------|-------|---------| +| CLIツール | Nix (home-manager) | Nix (home-manager) | WSL2経由でNix | +| GUIアプリ | Homebrew Cask | nixpkgs / Flatpak | winget | +| システム設定 | nix-darwin | NixOS / 手動 | - | + +### パッケージの追加 ```bash # 1. 検索 nix search nixpkgs -# 2. home/packages.nix に追加 +# 2. 追加 +# 共通: home/packages.nix の commonPackages +# macOS専用: home/packages.nix の darwinPackages +# Linux専用: home/packages.nix の linuxPackages # 3. 適用 -nix run .#switch +nix run .#switch # macOS +home-manager switch --flake .#user@host # Linux +``` + +### GUIアプリの追加(macOS) + +```bash +# 1. modules/darwin/homebrew.nix の casks に追加 +# 2. nix run .#switch ``` +### GUIアプリの追加(Windows) + +```powershell +# 1. パッケージIDを検索 +winget search + +# 2. windows/packages.json に追加 +# 3. winget import -i windows/packages.json +``` + +--- + +## 含まれるツール + +### 共通(124個以上) + +| カテゴリ | ツール | +|---------|--------| +| シェル | Fish, Starship, Zellij | +| エディタ | Helix | +| 検索 | ripgrep, fd, fzf, broot | +| Git | gh, gitui, tig, lefthook | +| 監視 | bottom, procs, bandwhich | +| データ処理 | jq, yq, xsv | +| ネットワーク | xh, dog, nmap, mtr | +| DB | pgcli, mycli, litecli, usql | +| K8s | k9s, helm, kubectx, stern | +| クラウド | awscli, azure-cli, gcloud | +| 言語 | Node.js, Python, Rust, Go, Zig, etc. | + +### Linux専用 + +`xclip`, `wl-clipboard`, `inotify-tools`, `strace`, `htop`, `iotop`, `ncdu`, `duf`, etc. + +### macOS専用 + +`cocoapods`, Homebrew Casksで管理するGUIアプリ + +--- + +## テーマ + +**Tokyo Night** で統一: +- Ghostty(ターミナル) +- fzf(ファジーファインダー) +- Zellij(ターミナルマルチプレクサ) + +**Monokai**: +- Starship(プロンプト) +- Helix(エディタ) + +--- + ## トラブルシューティング ### "experimental-features" エラー @@ -77,25 +302,58 @@ echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf ### 古い世代をクリーンアップ ```bash +# Nixストア全体 nix-collect-garbage -d + +# home-managerの古い世代 +home-manager expire-generations "-30 days" ``` -### ロールバック +### ビルドエラーの調査 ```bash -darwin-rebuild rollback +# 詳細なエラー表示 +nix run .#build 2>&1 | less + +# 特定パッケージのビルド +nix build nixpkgs# --show-trace ``` -## テーマ +### WSL2でのNixインストール問題 -**Tokyo Night** で統一: -- Ghostty -- fzf -- Zellij +```bash +# systemdが有効か確認 +systemctl --version -**Monokai**: -- Starship -- Helix +# 有効でない場合、/etc/wsl.conf を作成 +[boot] +systemd=true + +# WSLを再起動 +wsl --shutdown +``` + +--- + +## 新しいマシンの追加 + +### macOS + +1. `machines/darwin/.nix` を作成 +2. `flake.nix` の `darwinConfigurations` に追加 + +### NixOS + +1. `machines/nixos/.nix` を作成 +2. `hardware-configuration.nix` をインポート +3. `flake.nix` の `nixosConfigurations` に追加 + +### 非NixOS Linux / WSL2 + +1. `machines/linux/.nix` を作成(オプション) +2. `flake.nix` の `homeConfigurations` に追加 + +--- ## ライセンス diff --git a/darwin-configuration.nix b/darwin-configuration.nix deleted file mode 100644 index 5f165a2..0000000 --- a/darwin-configuration.nix +++ /dev/null @@ -1,322 +0,0 @@ -{ config, pkgs, ... }: - -{ - # ============================================================================= - # Nix-First Philosophy - # ============================================================================= - # This configuration prioritizes Nix packages over Homebrew. - # - ALL CLI tools are managed via Nix (see home.nix) - # - System packages are managed via Nix (see environment.systemPackages below) - # - Homebrew is ONLY used for GUI applications (see homebrew.casks below) - # ============================================================================= - - # Nix configuration - nix = { - settings = { - experimental-features = "nix-command flakes"; - # Optimize storage - auto-optimise-store = true; - }; - - gc = { - automatic = true; - options = "--delete-older-than 30d"; - }; - }; - - # List packages installed in system profile - environment.systemPackages = with pkgs; [ - # Core utilities - git - curl - wget - gnupg - openssl - - # Build tools - cmake - protobuf - - # Databases & Services - postgresql_14 - mariadb - redis - mongodb-community - nginx - - # Cloud & DevOps - docker - docker-compose - kubernetes - terraform - vault - consul - nomad - packer - - # Container & VM tools - colima - ]; - - # System configuration - system = { - # Set Git commit hash for darwin-rebuild - configurationRevision = null; - - defaults = { - # Dock settings - dock = { - autohide = true; - orientation = "bottom"; - show-recents = false; - tilesize = 48; - }; - - # Finder settings - finder = { - AppleShowAllExtensions = true; - FXPreferredViewStyle = "Nlsv"; # List view - ShowPathbar = true; - ShowStatusBar = true; - }; - - # NSGlobalDomain settings - NSGlobalDomain = { - AppleShowAllExtensions = true; - InitialKeyRepeat = 15; - KeyRepeat = 2; - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; - - # Custom keyboard shortcuts - # Format: "Menu Item" = "Shortcut" - # Shortcuts use: @ = Command, ^ = Control, ~ = Option, $ = Shift - NSUserKeyEquivalents = { - # Global shortcuts - "Show Help menu" = "^~@/"; - }; - }; - - # Screenshot settings - screencapture = { - location = "~/Documents"; - type = "png"; - disable-shadow = false; - }; - - # Trackpad settings - trackpad = { - Clicking = true; # Enable tap to click - TrackpadThreeFingerDrag = true; # Three finger drag - }; - - # Mouse settings - ".GlobalPreferences" = { - "com.apple.mouse.scaling" = 1.5; - }; - - # Menu bar settings - menuExtraClock = { - Show24Hour = true; - ShowDate = 1; # Always show date - ShowDayOfWeek = true; - }; - - # Login window settings - loginwindow = { - GuestEnabled = false; # Disable guest user - DisableConsoleAccess = true; - }; - - # Screen saver settings - screensaver = { - askForPassword = true; - askForPasswordDelay = 5; # seconds - }; - - # Spaces settings - spaces = { - spans-displays = false; # Separate spaces per display - }; - - # Custom macOS preferences - CustomUserPreferences = { - # Modifier keys remapping: Caps Lock → Command - "com.apple.keyboard.modifiermapping.1452-591-0" = [ - { - HIDKeyboardModifierMappingDst = 30064771299; # Command - HIDKeyboardModifierMappingSrc = 30064771129; # Caps Lock - } - ]; - - # Input source switching: Option + Esc - "com.apple.symbolichotkeys" = { - AppleSymbolicHotKeys = { - # Select next source in Input menu - "61" = { - enabled = true; - value = { - parameters = [ 53 53 524288 ]; # Esc key (53) + Option (524288) - type = "standard"; - }; - }; - }; - }; - }; - }; - - # Keyboard settings - keyboard = { - enableKeyMapping = true; - }; - - # Auto-upgrade - stateVersion = 5; - }; - - # Enable Touch ID for sudo - security.pam.enableSudoTouchIdAuth = true; - - # Fonts - fonts.packages = with pkgs; [ - (nerdfonts.override { - fonts = [ - "FiraCode" - "JetBrainsMono" - "Hack" - "Meslo" - "RobotoMono" - ]; - }) - ]; - - # Services - services = { - nix-daemon.enable = true; - }; - - # Homebrew configuration - # This allows nix-darwin to manage Homebrew declaratively - homebrew = { - enable = true; - - # Automatically update Homebrew and upgrade packages - onActivation = { - autoUpdate = true; - upgrade = true; - cleanup = "uninstall"; # Safely uninstall packages not listed in configuration - }; - - # Install GUI applications via Homebrew Cask - casks = [ - # Browsers - "google-chrome" - "firefox" - "vivaldi" - "opera-gx" - "min" - - # Development tools - "iterm2" - "warp" - "wezterm" - "github" - "gitkraken" - "tower" - "postman" - "paw" - "popsql" - "azure-data-studio" - "wireshark" - - # Design & Creative - "figma" - "abstract" - "canva" - "miro" - "origami-studio" - "protopie" - "blender" - "unity-hub" - - # Communication - "zoom" - "microsoft-teams" - "asana" - "linear-linear" - - # Productivity - "raycast" - "obsidian" - "typora" - "dynalist" - "numi" - "alt-tab" - "karabiner-elements" - "centered" - "forecast" - - # Media & Entertainment - "spotify" - "kap" - "descript" - "steam" - "epic-games" - "gog-galaxy" - "twitch" - - # Cloud & Database tools - "confluent-cli" - "redis-stack" - "redis-stack-server" - "redis-stack-redisinsight" - - # Programming environments - "flutter" - "anaconda" - "rstudio" - "qt-creator" - "qt3dstudio" - "neovide" - "nteract" - - # Music & Audio - "sonic-pi" - "supercollider" - "cycling74-max" - "splice" - "spark-ar-studio" - - # Other utilities - "adobe-acrobat-reader" - "google-japanese-ime" - "mactex" - "vagrant" - "powershell" - "owasp-zap" - "authy" - "session" - "brewlet" - "around" - "tableau" - "tableau-prep" - "storyboarder" - "openframeworks" - "git-credential-manager-core" - ]; - - # Additional taps (repositories) - # Only for GUI applications and tools not available in nixpkgs - taps = [ - "homebrew/cask-fonts" - "homebrew/cask-versions" - ]; - - # Note: CLI tools are managed via Nix packages in home.nix - # Homebrew is used ONLY for GUI applications (casks) that are not available in nixpkgs - }; - -} diff --git a/flake.nix b/flake.nix index b115262..252986f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,18 +1,20 @@ { - description = "Darwin system configuration"; + description = "Multi-platform Nix configuration (macOS, Linux, WSL2)"; inputs = { - # Stable nixpkgs (darwin-specific channel) - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin"; + # Stable nixpkgs (supports both Darwin and NixOS) + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; # Unstable nixpkgs for latest packages nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + # 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"; @@ -25,103 +27,127 @@ # Copy personal.nix.example to personal.nix and fill in your values personal = import ./personal.nix; - # System architecture - system = "aarch64-darwin"; # Use "x86_64-darwin" for Intel Macs - - # Packages for scripts - pkgs = import nixpkgs { inherit system; }; + # Import library functions + lib = import ./lib { + inherit nixpkgs nixpkgs-unstable darwin home-manager; + }; - # Overlays to access unstable packages - overlays = [ - (final: prev: { - unstable = import nixpkgs-unstable { - system = final.system; - config.allowUnfree = true; - }; - }) + # Unstable overlay for all systems + mkOverlays = system: [ + (lib.mkUnstableOverlay system) ]; in { - # ========================================================================== - # Darwin Configurations - # ========================================================================== + # ======================================================================== + # Darwin Configurations (macOS) + # ======================================================================== darwinConfigurations = { - "${personal.hostname}" = darwin.lib.darwinSystem { - inherit system; - - specialArgs = { - inherit personal; - }; - - modules = [ - # Apply overlays and allow unfree packages - { - nixpkgs.overlays = overlays; - nixpkgs.config.allowUnfree = true; - } - - # Machine-specific configuration - (./machines + "/${personal.hostname}.nix") - - # Darwin configuration - ./darwin-configuration.nix - - # Home Manager integration - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.${personal.username} = import ./home.nix; - home-manager.extraSpecialArgs = { inherit personal; }; - } - ]; + "${personal.hostname}" = lib.mkDarwinSystem { + system = "aarch64-darwin"; # Use "x86_64-darwin" for Intel Macs + inherit personal; + overlays = mkOverlays "aarch64-darwin"; }; }; - # ========================================================================== - # Apps - Simplified commands - # ========================================================================== + # ======================================================================== + # NixOS Configurations (Linux with NixOS) + # ======================================================================== + # Uncomment and configure when adding NixOS machines + # nixosConfigurations = { + # "nixos-hostname" = lib.mkNixosSystem { + # system = "x86_64-linux"; + # personal = { + # hostname = "nixos-hostname"; + # username = "your-username"; + # email = "your@email.com"; + # name = "Your Name"; + # }; + # overlays = mkOverlays "x86_64-linux"; + # }; + # }; + + # ======================================================================== + # Home Configurations (Standalone Home Manager for non-NixOS Linux / WSL2) + # ======================================================================== + # Uncomment and configure when adding standalone Home Manager setups + # homeConfigurations = { + # "username@hostname" = lib.mkHomeConfig { + # system = "x86_64-linux"; + # personal = { + # hostname = "linux-hostname"; + # username = "your-username"; + # email = "your@email.com"; + # name = "Your Name"; + # }; + # overlays = mkOverlays "x86_64-linux"; + # }; + # }; + + # ======================================================================== + # Apps - Simplified commands for all platforms + # ======================================================================== # Usage: - # nix run .#switch - Build and apply configuration + # nix run .#switch - Build and apply configuration (Darwin) # nix run .#build - Build only (test) # nix run .#update - Update flake inputs - # ========================================================================== - apps.${system} = { - # Build and switch to new configuration - switch = { - type = "app"; - program = toString (pkgs.writeShellScript "darwin-switch" '' - set -e - echo "🔄 Building and switching to new configuration..." - sudo ${darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild switch --flake .#${personal.hostname} - echo "✅ Done!" - ''); - }; + # ======================================================================== + apps = lib.forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + isDarwin = pkgs.stdenv.isDarwin; + in + { + # Build and switch to new configuration + switch = { + type = "app"; + program = toString (pkgs.writeShellScript "switch" ( + if isDarwin 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 '' + 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 + '' + )); + }; - # Build only (for testing) - build = { - type = "app"; - program = toString (pkgs.writeShellScript "darwin-build" '' - set -e - echo "🔨 Building configuration..." - nix build .#darwinConfigurations.${personal.hostname}.system - echo "✅ Build successful! Run 'nix run .#switch' to apply." - ''); - }; + # Build only (for testing) + build = { + type = "app"; + program = toString (pkgs.writeShellScript "build" ( + if isDarwin then '' + set -e + echo "Building Darwin configuration..." + nix build .#darwinConfigurations.${personal.hostname}.system + echo "Build successful! Run 'nix run .#switch' to apply." + '' else '' + set -e + echo "Error: 'build' app is not supported for non-Darwin systems. Please build explicitly." >&2 + echo " For NixOS: nix build .#nixosConfigurations..config.system.build.toplevel" >&2 + echo " For Home Manager: nix build .#homeConfigurations..activationPackage" >&2 + exit 1 + '' + )); + }; - # Update flake inputs - update = { - type = "app"; - program = toString (pkgs.writeShellScript "flake-update" '' - set -e - echo "📦 Updating flake inputs..." - nix flake update - echo "✅ Done! Run 'nix run .#switch' to apply changes." - ''); - }; + # Update flake inputs + update = { + type = "app"; + program = toString (pkgs.writeShellScript "flake-update" '' + set -e + echo "Updating flake inputs..." + nix flake update + echo "Done! Run the appropriate switch command to apply changes." + ''); + }; - # Default app is switch - default = self.apps.${system}.switch; - }; + # Default app is switch + default = self.apps.${system}.switch; + } + ); }; } diff --git a/home.nix b/home.nix deleted file mode 100644 index 3707196..0000000 --- a/home.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ config, pkgs, personal, ... }: - -{ - # ============================================================================= - # Home Manager Configuration - Modularized - # ============================================================================= - # This is the main entry point for Home Manager configuration. - # Individual program configurations are split into home/programs/ directory. - # ============================================================================= - - imports = [ - # Package list - ./home/packages.nix - - # Program configurations - ./home/programs/git.nix - ./home/programs/fish.nix - ./home/programs/starship.nix - ./home/programs/helix.nix - ./home/programs/fzf.nix - ./home/programs/zoxide.nix - ./home/programs/mcfly.nix - ./home/programs/claude.nix - - # XDG configurations (Ghostty, Zellij) - ./home/xdg.nix - ]; - - # Home Manager needs a bit of information about you and the paths it should manage - home = { - username = personal.username; - homeDirectory = "/Users/${personal.username}"; - - # 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; -} diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..c1e7885 --- /dev/null +++ b/home/default.nix @@ -0,0 +1,52 @@ +# Home Manager Configuration - Modularized with Platform Support +# ============================================================================= +# This is the main entry point for Home Manager configuration. +# Individual program configurations are split into home/programs/ directory. +# ============================================================================= +{ config, pkgs, lib, personal, ... }: + +let + isDarwin = pkgs.stdenv.isDarwin; + isLinux = pkgs.stdenv.isLinux; + + # Platform-specific home directory + homeDirectory = if isDarwin + then "/Users/${personal.username}" + else "/home/${personal.username}"; +in +{ + 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; +} diff --git a/home/packages.nix b/home/packages.nix index 7ba33ea..a80059c 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -1,7 +1,11 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: -{ - home.packages = with pkgs; [ +let + isDarwin = pkgs.stdenv.isDarwin; + isLinux = pkgs.stdenv.isLinux; + + # Common packages for all platforms + commonPackages = with pkgs; [ # Search & Navigation ripgrep ripgrep-all @@ -148,9 +152,6 @@ # DevOps & CI/CD circleci-cli - # Mobile development - cocoapods - # Utilities tldr neofetch @@ -160,4 +161,54 @@ # Other ko ]; + + # macOS-specific packages + darwinPackages = with pkgs; [ + # Mobile development (iOS) + cocoapods + ]; + + # Linux-specific packages + linuxPackages = with pkgs; [ + # Clipboard utilities (required for fzf, zellij) + xclip + wl-clipboard + + # System utilities + inotify-tools + lsof + strace + ltrace + + # Hardware info + pciutils + usbutils + dmidecode + + # Network + iproute2 + iptables + ethtool + tcpdump + + # Desktop integration (for GUI environments) + xdg-utils + desktop-file-utils + + # Fonts utilities + fontconfig + + # Process management + htop + iotop + + # Filesystem + ncdu + duf + ]; +in +{ + home.packages = commonPackages + ++ lib.optionals isDarwin darwinPackages + ++ lib.optionals isLinux linuxPackages; } diff --git a/home/programs/fzf.nix b/home/programs/fzf.nix index d5d63ac..052ce70 100644 --- a/home/programs/fzf.nix +++ b/home/programs/fzf.nix @@ -1,5 +1,13 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: +let + isDarwin = pkgs.stdenv.isDarwin; + + # Platform-specific clipboard command + copyCommand = if isDarwin then "pbcopy" + else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy" + else "xclip -selection clipboard"; +in { programs.fzf = { enable = true; @@ -39,7 +47,7 @@ "--bind 'ctrl-u:preview-half-page-up'" "--bind 'ctrl-d:preview-half-page-down'" "--bind 'ctrl-a:select-all'" - "--bind 'ctrl-y:execute-silent(echo {+} | pbcopy)'" + "--bind 'ctrl-y:execute-silent(echo {+} | ${copyCommand})'" ]; }; } diff --git a/home/xdg.nix b/home/xdg.nix index 309b29e..60802ff 100644 --- a/home/xdg.nix +++ b/home/xdg.nix @@ -1,5 +1,14 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: +let + isDarwin = pkgs.stdenv.isDarwin; + isLinux = pkgs.stdenv.isLinux; + + # Platform-specific clipboard command + copyCommand = if isDarwin then "pbcopy" + else if builtins.getEnv "WAYLAND_DISPLAY" != "" then "wl-copy" + else "xclip -selection clipboard"; +in { # Ghostty terminal configuration xdg.configFile."ghostty/config".text = '' @@ -92,7 +101,7 @@ // Copy mode copy_on_select true - copy_command "pbcopy" + copy_command "${copyCommand}" // Session configuration default_layout "compact" diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..8b4b931 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,42 @@ +# Library of helper functions for building system configurations +{ nixpkgs, nixpkgs-unstable, darwin, home-manager, ... }: + +let + # Supported systems + supportedSystems = [ + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + "aarch64-linux" + ]; + + # Helper to generate attributes for all systems + forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems f; + + # Create unstable overlay + mkUnstableOverlay = system: (final: prev: { + unstable = import nixpkgs-unstable { + inherit system; + config.allowUnfree = true; + }; + }); +in +{ + inherit supportedSystems forAllSystems mkUnstableOverlay; + + # Import individual builders + mkDarwinSystem = import ./mkDarwinSystem.nix { + inherit darwin home-manager; + lib = nixpkgs.lib; + }; + + mkNixosSystem = import ./mkNixosSystem.nix { + inherit nixpkgs home-manager; + lib = nixpkgs.lib; + }; + + mkHomeConfig = import ./mkHomeConfig.nix { + inherit home-manager nixpkgs; + lib = nixpkgs.lib; + }; +} diff --git a/lib/mkDarwinSystem.nix b/lib/mkDarwinSystem.nix new file mode 100644 index 0000000..8267b57 --- /dev/null +++ b/lib/mkDarwinSystem.nix @@ -0,0 +1,35 @@ +# Helper function to create Darwin (macOS) system configurations +{ darwin, home-manager, lib }: + +{ system, personal, overlays ? [] }: + +darwin.lib.darwinSystem { + inherit system; + + specialArgs = { + inherit personal; + }; + + modules = [ + # Apply overlays and allow unfree packages + { + nixpkgs.overlays = overlays; + nixpkgs.config.allowUnfree = true; + } + + # Machine-specific configuration + (../machines/darwin + "/${personal.hostname}.nix") + + # Darwin configuration (modularized) + ../modules/darwin + + # Home Manager integration + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${personal.username} = import ../home; + home-manager.extraSpecialArgs = { inherit personal; }; + } + ]; +} diff --git a/lib/mkHomeConfig.nix b/lib/mkHomeConfig.nix new file mode 100644 index 0000000..4503593 --- /dev/null +++ b/lib/mkHomeConfig.nix @@ -0,0 +1,25 @@ +# Helper function to create standalone Home Manager configurations +# Used for non-NixOS Linux systems and WSL2 +{ home-manager, nixpkgs, lib }: + +{ system, personal, overlays ? [] }: + +home-manager.lib.homeManagerConfiguration { + pkgs = import nixpkgs { + inherit system; + overlays = overlays; + config.allowUnfree = true; + }; + + extraSpecialArgs = { + inherit personal; + }; + + modules = [ + ../home + + # Machine-specific Home Manager configuration (optional) + # Uncomment if you have machine-specific home configs + # (../machines/linux + "/${personal.hostname}.nix") + ]; +} diff --git a/lib/mkNixosSystem.nix b/lib/mkNixosSystem.nix new file mode 100644 index 0000000..c04c9e7 --- /dev/null +++ b/lib/mkNixosSystem.nix @@ -0,0 +1,35 @@ +# Helper function to create NixOS system configurations +{ nixpkgs, home-manager, lib }: + +{ system, personal, overlays ? [] }: + +nixpkgs.lib.nixosSystem { + inherit system; + + specialArgs = { + inherit personal; + }; + + modules = [ + # Apply overlays and allow unfree packages + { + nixpkgs.overlays = overlays; + nixpkgs.config.allowUnfree = true; + } + + # Machine-specific configuration (hardware, etc.) + (../machines/nixos + "/${personal.hostname}.nix") + + # NixOS configuration (modularized) + ../modules/nixos + + # Home Manager integration + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${personal.username} = import ../home; + home-manager.extraSpecialArgs = { inherit personal; }; + } + ]; +} diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix deleted file mode 100644 index 28ff93c..0000000 --- a/lib/mkSystem.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ darwin, home-manager, nixpkgs, nixpkgs-unstable, ... }: - -{ system, hostname, username, modules ? [], overlays ? [] }: - -# NOTE: This function is not currently used in flake.nix, but is prepared -# for future use when managing multiple machines with different configurations. -# To use this function, update flake.nix to call mkSystem instead of -# directly defining darwinSystem. - -darwin.lib.darwinSystem { - inherit system; - - specialArgs = { - inherit hostname username; - }; - - modules = [ - # Apply overlays - { nixpkgs.overlays = overlays; } - - # Include machine-specific configuration if it exists - (../machines + "/${hostname}.nix") - - # Include darwin configuration - ../darwin-configuration.nix - - # Home Manager integration - home-manager.darwinModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.users.${username} = import ../home.nix; - home-manager.extraSpecialArgs = { - # Merge personal.nix with hostname/username to create complete personal object - personal = (import ../personal.nix) // { - inherit hostname username; - }; - }; - } - ] ++ modules; -} diff --git a/machines/000355-M.nix b/machines/darwin/000355-M.nix similarity index 100% rename from machines/000355-M.nix rename to machines/darwin/000355-M.nix diff --git a/machines/linux/example.nix b/machines/linux/example.nix new file mode 100644 index 0000000..4bab966 --- /dev/null +++ b/machines/linux/example.nix @@ -0,0 +1,33 @@ +# Example Linux standalone (non-NixOS / WSL2) machine configuration +# ============================================================================= +# This file is for machine-specific Home Manager settings on non-NixOS Linux. +# Copy this file and rename it to your hostname.nix (e.g., wsl-ubuntu.nix) +# Then add the machine to flake.nix under homeConfigurations +# +# Usage (after adding to flake.nix): +# home-manager switch --flake .#username@hostname +# ============================================================================= +{ config, pkgs, lib, personal, ... }: + +{ + # Machine-specific Home Manager settings + + # Additional packages for this machine + # home.packages = with pkgs; [ + # # Add machine-specific packages here + # ]; + + # WSL2-specific settings (uncomment if using WSL2) + # home.sessionVariables = { + # # Access Windows files + # WINDOWS_HOME = "/mnt/c/Users/${personal.username}"; + # }; + + # This assertion ensures the module is valid while keeping it minimal + assertions = [ + { + assertion = true; + message = "machines/linux/example.nix is a template file."; + } + ]; +} diff --git a/machines/nixos/example.nix b/machines/nixos/example.nix new file mode 100644 index 0000000..f163dcc --- /dev/null +++ b/machines/nixos/example.nix @@ -0,0 +1,35 @@ +# Example NixOS machine configuration +# ============================================================================= +# Copy this file and rename it to your hostname.nix (e.g., my-desktop.nix) +# Then add the machine to flake.nix under nixosConfigurations +# ============================================================================= +{ config, pkgs, lib, ... }: + +{ + # Import hardware configuration generated by nixos-generate-config + # imports = [ + # ./hardware-configuration.nix + # ]; + + # Bootloader configuration + # boot.loader.systemd-boot.enable = true; + # boot.loader.efi.canTouchEfiVariables = true; + + # Machine-specific packages + # environment.systemPackages = with pkgs; [ + # # Add machine-specific packages here + # ]; + + # Machine-specific services + # services = { + # # Enable services specific to this machine + # }; + + # This assertion ensures the module is valid while keeping it minimal + assertions = [ + { + assertion = true; + message = "machines/nixos/example.nix is a template file."; + } + ]; +} diff --git a/modules/common/nix.nix b/modules/common/nix.nix new file mode 100644 index 0000000..5015aa8 --- /dev/null +++ b/modules/common/nix.nix @@ -0,0 +1,17 @@ +# Common Nix settings shared across all platforms +{ config, pkgs, lib, ... }: + +{ + nix = { + settings = { + experimental-features = "nix-command flakes"; + # Optimize storage + auto-optimise-store = true; + }; + + gc = { + automatic = true; + options = "--delete-older-than 30d"; + }; + }; +} diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix new file mode 100644 index 0000000..5b188b2 --- /dev/null +++ b/modules/darwin/default.nix @@ -0,0 +1,73 @@ +# Darwin (macOS) configuration entry point +# ============================================================================= +# Nix-First Philosophy +# ============================================================================= +# This configuration prioritizes Nix packages over Homebrew. +# - ALL CLI tools are managed via Nix (see home/packages.nix) +# - System packages are managed via Nix (see environment.systemPackages below) +# - Homebrew is ONLY used for GUI applications (see homebrew.nix) +# ============================================================================= +{ config, pkgs, lib, ... }: + +{ + imports = [ + # Common Nix settings + ../common/nix.nix + + # macOS-specific modules + ./system.nix + ./homebrew.nix + ]; + + # List packages installed in system profile + environment.systemPackages = with pkgs; [ + # Core utilities + git + curl + wget + gnupg + openssl + + # Build tools + cmake + protobuf + + # Databases & Services + postgresql_14 + mariadb + redis + mongodb-community + nginx + + # Cloud & DevOps + docker + docker-compose + kubernetes + terraform + vault + consul + nomad + packer + + # Container & VM tools + colima + ]; + + # Fonts + fonts.packages = with pkgs; [ + (nerdfonts.override { + fonts = [ + "FiraCode" + "JetBrainsMono" + "Hack" + "Meslo" + "RobotoMono" + ]; + }) + ]; + + # Services + services = { + nix-daemon.enable = true; + }; +} diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 0000000..2e2b028 --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,124 @@ +# Homebrew configuration for macOS +# This allows nix-darwin to manage Homebrew declaratively +{ config, pkgs, lib, ... }: + +{ + homebrew = { + enable = true; + + # Automatically update Homebrew and upgrade packages + onActivation = { + autoUpdate = true; + upgrade = true; + cleanup = "uninstall"; # Safely uninstall packages not listed in configuration + }; + + # Install GUI applications via Homebrew Cask + casks = [ + # Browsers + "google-chrome" + "firefox" + "vivaldi" + "opera-gx" + "min" + + # Development tools + "iterm2" + "warp" + "wezterm" + "github" + "gitkraken" + "tower" + "postman" + "paw" + "popsql" + "azure-data-studio" + "wireshark" + + # Design & Creative + "figma" + "abstract" + "canva" + "miro" + "origami-studio" + "protopie" + "blender" + "unity-hub" + + # Communication + "zoom" + "microsoft-teams" + "asana" + "linear-linear" + + # Productivity + "raycast" + "obsidian" + "typora" + "dynalist" + "numi" + "alt-tab" + "karabiner-elements" + "centered" + "forecast" + + # Media & Entertainment + "spotify" + "kap" + "descript" + "steam" + "epic-games" + "gog-galaxy" + "twitch" + + # Cloud & Database tools + "confluent-cli" + "redis-stack" + "redis-stack-server" + "redis-stack-redisinsight" + + # Programming environments + "flutter" + "anaconda" + "rstudio" + "qt-creator" + "qt3dstudio" + "neovide" + "nteract" + + # Music & Audio + "sonic-pi" + "supercollider" + "cycling74-max" + "splice" + "spark-ar-studio" + + # Other utilities + "adobe-acrobat-reader" + "google-japanese-ime" + "mactex" + "vagrant" + "powershell" + "owasp-zap" + "authy" + "session" + "brewlet" + "around" + "tableau" + "tableau-prep" + "storyboarder" + "openframeworks" + "git-credential-manager-core" + ]; + + # Additional taps (repositories) + # Only for GUI applications and tools not available in nixpkgs + taps = [ + "homebrew/cask-fonts" + "homebrew/cask-versions" + ]; + + # Note: CLI tools are managed via Nix packages in home.nix + # Homebrew is used ONLY for GUI applications (casks) that are not available in nixpkgs + }; +} diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix new file mode 100644 index 0000000..6909241 --- /dev/null +++ b/modules/darwin/system.nix @@ -0,0 +1,125 @@ +# macOS system settings (Dock, Finder, Touch ID, keyboard, etc.) +{ config, pkgs, lib, ... }: + +{ + system = { + # Set Git commit hash for darwin-rebuild + configurationRevision = null; + + defaults = { + # Dock settings + dock = { + autohide = true; + orientation = "bottom"; + show-recents = false; + tilesize = 48; + }; + + # Finder settings + finder = { + AppleShowAllExtensions = true; + FXPreferredViewStyle = "Nlsv"; # List view + ShowPathbar = true; + ShowStatusBar = true; + }; + + # NSGlobalDomain settings + NSGlobalDomain = { + AppleShowAllExtensions = true; + InitialKeyRepeat = 15; + KeyRepeat = 2; + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + + # Custom keyboard shortcuts + # Format: "Menu Item" = "Shortcut" + # Shortcuts use: @ = Command, ^ = Control, ~ = Option, $ = Shift + NSUserKeyEquivalents = { + # Global shortcuts + "Show Help menu" = "^~@/"; + }; + }; + + # Screenshot settings + screencapture = { + location = "~/Documents"; + type = "png"; + disable-shadow = false; + }; + + # Trackpad settings + trackpad = { + Clicking = true; # Enable tap to click + TrackpadThreeFingerDrag = true; # Three finger drag + }; + + # Mouse settings + ".GlobalPreferences" = { + "com.apple.mouse.scaling" = 1.5; + }; + + # Menu bar settings + menuExtraClock = { + Show24Hour = true; + ShowDate = 1; # Always show date + ShowDayOfWeek = true; + }; + + # Login window settings + loginwindow = { + GuestEnabled = false; # Disable guest user + DisableConsoleAccess = true; + }; + + # Screen saver settings + screensaver = { + askForPassword = true; + askForPasswordDelay = 5; # seconds + }; + + # Spaces settings + spaces = { + spans-displays = false; # Separate spaces per display + }; + + # Custom macOS preferences + CustomUserPreferences = { + # Modifier keys remapping: Caps Lock -> Command + "com.apple.keyboard.modifiermapping.1452-591-0" = [ + { + HIDKeyboardModifierMappingDst = 30064771299; # Command + HIDKeyboardModifierMappingSrc = 30064771129; # Caps Lock + } + ]; + + # Input source switching: Option + Esc + "com.apple.symbolichotkeys" = { + AppleSymbolicHotKeys = { + # Select next source in Input menu + "61" = { + enabled = true; + value = { + parameters = [ 53 53 524288 ]; # Esc key (53) + Option (524288) + type = "standard"; + }; + }; + }; + }; + }; + }; + + # Keyboard settings + keyboard = { + enableKeyMapping = true; + }; + + # Auto-upgrade + stateVersion = 5; + }; + + # Enable Touch ID for sudo + security.pam.enableSudoTouchIdAuth = true; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix new file mode 100644 index 0000000..5b361a3 --- /dev/null +++ b/modules/nixos/default.nix @@ -0,0 +1,87 @@ +# NixOS configuration entry point +# ============================================================================= +# This module contains common NixOS settings. +# Machine-specific hardware configuration should go in machines/nixos/*.nix +# ============================================================================= +{ config, pkgs, lib, personal, ... }: + +{ + imports = [ + # Common Nix settings + ../common/nix.nix + ]; + + # Basic system configuration + networking.hostName = personal.hostname; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone + time.timeZone = "Asia/Tokyo"; + + # Select internationalisation properties + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "ja_JP.UTF-8"; + LC_IDENTIFICATION = "ja_JP.UTF-8"; + LC_MEASUREMENT = "ja_JP.UTF-8"; + LC_MONETARY = "ja_JP.UTF-8"; + LC_NAME = "ja_JP.UTF-8"; + LC_NUMERIC = "ja_JP.UTF-8"; + LC_PAPER = "ja_JP.UTF-8"; + LC_TELEPHONE = "ja_JP.UTF-8"; + LC_TIME = "ja_JP.UTF-8"; + }; + + # User configuration + users.users.${personal.username} = { + isNormalUser = true; + description = personal.name; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + shell = pkgs.fish; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # System packages + environment.systemPackages = with pkgs; [ + # Core utilities + git + curl + wget + gnupg + openssl + + # Build tools + cmake + gcc + gnumake + + # Clipboard utilities for Linux + xclip + wl-clipboard + ]; + + # Enable Fish shell system-wide + programs.fish.enable = true; + + # Fonts + fonts.packages = with pkgs; [ + (nerdfonts.override { + fonts = [ + "FiraCode" + "JetBrainsMono" + "Hack" + "Meslo" + "RobotoMono" + ]; + }) + ]; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. + system.stateVersion = "24.11"; +} diff --git a/windows/README.md b/windows/README.md new file mode 100644 index 0000000..5521c20 --- /dev/null +++ b/windows/README.md @@ -0,0 +1,59 @@ +# Windows Setup + +Windows環境のセットアップ用ファイル。wingetを使ってパッケージを宣言的に管理。 + +## 使い方 + +### 初回セットアップ + +PowerShellを管理者として実行: + +```powershell +cd windows +.\setup.ps1 +``` + +### パッケージの追加 + +1. `packages.json` にパッケージを追加 +2. `winget import -i packages.json` を実行 + +### 現在のパッケージをエクスポート + +```powershell +winget export -o packages.json +``` + +## WSL2 セットアップ + +Windows側のセットアップ後、WSL2でLinux環境を構築: + +```powershell +# WSL2のインストール +wsl --install + +# Ubuntu(デフォルト)が起動したら、Nixをインストール +curl -L https://nixos.org/nix/install | sh + +# dotfilesをクローン +git clone https://github.com/ta93abe/dotfiles.git ~/.dotfiles +cd ~/.dotfiles + +# home-managerで設定を適用 +home-manager switch --flake .#username@hostname +``` + +## パッケージID検索 + +```powershell +winget search +``` + +## 構成 + +``` +windows/ +├── packages.json # wingetパッケージリスト +├── setup.ps1 # セットアップスクリプト +└── README.md # このファイル +``` diff --git a/windows/packages.json b/windows/packages.json new file mode 100644 index 0000000..a63f162 --- /dev/null +++ b/windows/packages.json @@ -0,0 +1,67 @@ +{ + "$schema": "https://aka.ms/winget-packages.schema.2.0.json", + "CreationDate": "2025-01-26", + "Sources": [ + { + "Packages": [ + { "PackageIdentifier": "Google.Chrome" }, + { "PackageIdentifier": "Mozilla.Firefox" }, + { "PackageIdentifier": "Vivaldi.Vivaldi" }, + { "PackageIdentifier": "Opera.OperaGX" }, + + { "PackageIdentifier": "Microsoft.VisualStudioCode" }, + { "PackageIdentifier": "Microsoft.WindowsTerminal" }, + { "PackageIdentifier": "GitHub.GitHubDesktop" }, + { "PackageIdentifier": "Axosoft.GitKraken" }, + { "PackageIdentifier": "Postman.Postman" }, + { "PackageIdentifier": "WiresharkFoundation.Wireshark" }, + + { "PackageIdentifier": "Figma.Figma" }, + { "PackageIdentifier": "Canva.Canva" }, + { "PackageIdentifier": "Miro.Miro" }, + { "PackageIdentifier": "BlenderFoundation.Blender" }, + { "PackageIdentifier": "UnityTechnologies.UnityHub" }, + + { "PackageIdentifier": "Zoom.Zoom" }, + { "PackageIdentifier": "Microsoft.Teams" }, + { "PackageIdentifier": "SlackTechnologies.Slack" }, + { "PackageIdentifier": "Discord.Discord" }, + + { "PackageIdentifier": "Obsidian.Obsidian" }, + { "PackageIdentifier": "Typora.Typora" }, + { "PackageIdentifier": "Notion.Notion" }, + + { "PackageIdentifier": "Spotify.Spotify" }, + { "PackageIdentifier": "Valve.Steam" }, + { "PackageIdentifier": "EpicGames.EpicGamesLauncher" }, + { "PackageIdentifier": "GOG.Galaxy" }, + { "PackageIdentifier": "Twitch.Twitch" }, + + { "PackageIdentifier": "Docker.DockerDesktop" }, + { "PackageIdentifier": "Hashicorp.Terraform" }, + { "PackageIdentifier": "Hashicorp.Vagrant" }, + { "PackageIdentifier": "Microsoft.PowerShell" }, + + { "PackageIdentifier": "Git.Git" }, + { "PackageIdentifier": "GitHub.cli" }, + { "PackageIdentifier": "sharkdp.fd" }, + { "PackageIdentifier": "BurntSushi.ripgrep.MSVC" }, + { "PackageIdentifier": "sharkdp.bat" }, + { "PackageIdentifier": "junegunn.fzf" }, + { "PackageIdentifier": "ajeetdsouza.zoxide" }, + + { "PackageIdentifier": "Adobe.Acrobat.Reader.64-bit" }, + { "PackageIdentifier": "Google.JapaneseIME" }, + { "PackageIdentifier": "7zip.7zip" }, + { "PackageIdentifier": "VideoLAN.VLC" } + ], + "SourceDetails": { + "Argument": "https://cdn.winget.microsoft.com/cache", + "Identifier": "Microsoft.Winget.Source_8wekyb3d8bbwe", + "Name": "winget", + "Type": "Microsoft.PreIndexed.Package" + } + } + ], + "WinGetVersion": "1.7.0" +} diff --git a/windows/setup.ps1 b/windows/setup.ps1 new file mode 100644 index 0000000..86c2241 --- /dev/null +++ b/windows/setup.ps1 @@ -0,0 +1,45 @@ +# Windows Setup Script using winget +# Run as Administrator in PowerShell +# Usage: .\setup.ps1 + +$ErrorActionPreference = "Stop" + +Write-Host "Windows Setup Script" -ForegroundColor Cyan +Write-Host "====================" -ForegroundColor Cyan + +# Check if running as Administrator +$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 +} + +# Check if winget is available +if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { + Write-Host "Error: winget is not installed." -ForegroundColor Red + Write-Host "Please install App Installer from the Microsoft Store." -ForegroundColor Yellow + exit 1 +} + +# Get script directory +$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path +$packagesFile = Join-Path $scriptDir "packages.json" + +if (-not (Test-Path $packagesFile)) { + Write-Host "Error: packages.json not found." -ForegroundColor Red + exit 1 +} + +Write-Host "" +Write-Host "Installing packages from packages.json..." -ForegroundColor Green +Write-Host "" + +# Import packages +winget import -i $packagesFile --accept-package-agreements --accept-source-agreements + +Write-Host "" +Write-Host "Setup complete!" -ForegroundColor Green +Write-Host "" +Write-Host "Next steps:" -ForegroundColor Cyan +Write-Host " 1. Install WSL2: wsl --install" -ForegroundColor White +Write-Host " 2. Set up Nix in WSL2" -ForegroundColor White +Write-Host " 3. Clone dotfiles and run home-manager" -ForegroundColor White