From 3ca54f62b126d301a93bee3ab9b4b5aea600cd1b Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 22 Jul 2026 21:18:27 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20flake.nix=20=E3=82=92=20multi-syste?= =?UTF-8?q?m=20=E5=AF=BE=E5=BF=9C=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将来 macOS (Apple Silicon) でも dotfiles を使うため、system 固定だった pkgs 生成と mkHomeConfig を system パラメータ化。評価確認用に aarch64-darwin 向け homeConfigurations (testuser-darwin) を追加し、 CI でも eval で壊れていないことを検知できるようにする。 Co-Authored-By: Claude Sonnet 5 --- .github/workflows/nix.yaml | 3 +++ flake.nix | 48 +++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml index f89c64a..20a377d 100644 --- a/.github/workflows/nix.yaml +++ b/.github/workflows/nix.yaml @@ -23,3 +23,6 @@ jobs: - name: Run nix flake check run: nix flake check . + + - name: Evaluate darwin home-manager config + run: nix eval .#homeConfigurations.testuser-darwin.config.home.username diff --git a/flake.nix b/flake.nix index 938ab0d..2aebc9f 100644 --- a/flake.nix +++ b/flake.nix @@ -39,24 +39,25 @@ ... }: let - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - overlays = [ llm-agents.overlays.shared-nixpkgs ]; - config.allowUnfreePredicate = - pkg: - builtins.elem (nixpkgs.lib.getName pkg) [ - "claude-code" - "copilot.vim" - "copilot-cli" - "barbar.nvim" - "antigravity-cli" - ]; - }; + mkPkgs = + system: + import nixpkgs { + inherit system; + overlays = [ llm-agents.overlays.shared-nixpkgs ]; + config.allowUnfreePredicate = + pkg: + builtins.elem (nixpkgs.lib.getName pkg) [ + "claude-code" + "copilot.vim" + "copilot-cli" + "barbar.nvim" + "antigravity-cli" + ]; + }; mkHomeConfig = - username: homeDirectory: personal: + system: username: homeDirectory: personal: home-manager.lib.homeManagerConfiguration { - inherit pkgs; + pkgs = mkPkgs system; modules = [ nixvim.homeModules.nixvim ./home.nix @@ -73,7 +74,7 @@ in let loadPackagesDir = - dir: + dir: pkgs: let allFiles = builtins.readDir dir; nixFiles = builtins.filter (name: name != "default.nix" && builtins.match ".*\\.nix" name != null) ( @@ -86,17 +87,22 @@ value = import (dir + "/${name}") { inherit pkgs; }; }) nixFiles ); - npmPackages = loadPackagesDir ./modules/npm/packages; + npmPackages = loadPackagesDir ./modules/npm/packages (mkPkgs "x86_64-linux"); in { - packages.${system} = npmPackages; + packages.x86_64-linux = npmPackages; homeConfigurations = { - "rito528" = mkHomeConfig "rito528" "/home/rito528" { + "rito528" = mkHomeConfig "x86_64-linux" "rito528" "/home/rito528" { name = "rito528"; email = "39003544+rito528@users.noreply.github.com"; gpgKey = "F4022307254812F8"; }; - "testuser" = mkHomeConfig "testuser" "/home/testuser" { + "testuser" = mkHomeConfig "x86_64-linux" "testuser" "/home/testuser" { + name = "testuser"; + email = "testuser@example.com"; + gpgKey = ""; + }; + "testuser-darwin" = mkHomeConfig "aarch64-darwin" "testuser" "/Users/testuser" { name = "testuser"; email = "testuser@example.com"; gpgKey = ""; From 357a747e8e40e76c77f6a9bfc92834914267e392 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 22 Jul 2026 21:23:53 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20flake.nix=20=E3=81=AE=20homeCon?= =?UTF-8?q?figurations=20=E3=82=92=E3=83=87=E3=83=BC=E3=82=BF=E9=A7=86?= =?UTF-8?q?=E5=8B=95=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mkHomeConfig を毎回位置引数で呼ぶ形は、今後プロファイル分岐などで 引数が増えると見通しが悪くなるため、machines attrset に system/username/homeDirectory/personal をまとめ、mapAttrs で homeConfigurations を生成する形に変更した。 Co-Authored-By: Claude Sonnet 5 --- flake.nix | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index 2aebc9f..4ec5ca7 100644 --- a/flake.nix +++ b/flake.nix @@ -88,26 +88,47 @@ }) nixFiles ); npmPackages = loadPackagesDir ./modules/npm/packages (mkPkgs "x86_64-linux"); - in - { - packages.x86_64-linux = npmPackages; - homeConfigurations = { - "rito528" = mkHomeConfig "x86_64-linux" "rito528" "/home/rito528" { - name = "rito528"; - email = "39003544+rito528@users.noreply.github.com"; - gpgKey = "F4022307254812F8"; + + # 各マシン向け homeConfigurations の定義。新しいマシンを追加する場合はここにエントリを足す。 + machines = { + rito528 = { + system = "x86_64-linux"; + username = "rito528"; + homeDirectory = "/home/rito528"; + personal = { + name = "rito528"; + email = "39003544+rito528@users.noreply.github.com"; + gpgKey = "F4022307254812F8"; + }; }; - "testuser" = mkHomeConfig "x86_64-linux" "testuser" "/home/testuser" { - name = "testuser"; - email = "testuser@example.com"; - gpgKey = ""; + testuser = { + system = "x86_64-linux"; + username = "testuser"; + homeDirectory = "/home/testuser"; + personal = { + name = "testuser"; + email = "testuser@example.com"; + gpgKey = ""; + }; }; - "testuser-darwin" = mkHomeConfig "aarch64-darwin" "testuser" "/Users/testuser" { - name = "testuser"; - email = "testuser@example.com"; - gpgKey = ""; + # aarch64-darwin 向け評価確認用。実 Mac 上の Unix ユーザー名は testuser のまま。 + testuser-darwin = { + system = "aarch64-darwin"; + username = "testuser"; + homeDirectory = "/Users/testuser"; + personal = { + name = "testuser"; + email = "testuser@example.com"; + gpgKey = ""; + }; }; }; + in + { + packages.x86_64-linux = npmPackages; + homeConfigurations = builtins.mapAttrs ( + _: cfg: mkHomeConfig cfg.system cfg.username cfg.homeDirectory cfg.personal + ) machines; templates = { seichi-assist = { path = ./templates/seichi-assist; From 4b27ed3d9f69582da31e582e7d9453f8bf6e10a5 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 22 Jul 2026 21:28:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20personal=20=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=82=92=20identity=20=E3=81=AB=E3=83=AA=E3=83=8D=E3=83=BC?= =?UTF-8?q?=E3=83=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 「personal」は今後 work/personal のプロファイル分岐を入れると 意味が衝突するため、name/email/gpgKey を保持する Git ID 情報である ことがわかる identity に改名した。 Co-Authored-By: Claude Sonnet 5 --- flake.nix | 12 ++++++------ modules/git.nix | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 4ec5ca7..3500c2b 100644 --- a/flake.nix +++ b/flake.nix @@ -55,7 +55,7 @@ ]; }; mkHomeConfig = - system: username: homeDirectory: personal: + system: username: homeDirectory: identity: home-manager.lib.homeManagerConfiguration { pkgs = mkPkgs system; modules = [ @@ -66,7 +66,7 @@ inherit username homeDirectory - personal + identity takt ; }; @@ -95,7 +95,7 @@ system = "x86_64-linux"; username = "rito528"; homeDirectory = "/home/rito528"; - personal = { + identity = { name = "rito528"; email = "39003544+rito528@users.noreply.github.com"; gpgKey = "F4022307254812F8"; @@ -105,7 +105,7 @@ system = "x86_64-linux"; username = "testuser"; homeDirectory = "/home/testuser"; - personal = { + identity = { name = "testuser"; email = "testuser@example.com"; gpgKey = ""; @@ -116,7 +116,7 @@ system = "aarch64-darwin"; username = "testuser"; homeDirectory = "/Users/testuser"; - personal = { + identity = { name = "testuser"; email = "testuser@example.com"; gpgKey = ""; @@ -127,7 +127,7 @@ { packages.x86_64-linux = npmPackages; homeConfigurations = builtins.mapAttrs ( - _: cfg: mkHomeConfig cfg.system cfg.username cfg.homeDirectory cfg.personal + _: cfg: mkHomeConfig cfg.system cfg.username cfg.homeDirectory cfg.identity ) machines; templates = { seichi-assist = { diff --git a/modules/git.nix b/modules/git.nix index d70023c..e10808a 100644 --- a/modules/git.nix +++ b/modules/git.nix @@ -1,12 +1,12 @@ -{ lib, personal, ... }: +{ lib, identity, ... }: { programs.git = { enable = true; signing = { format = "openpgp"; } - // lib.optionalAttrs (personal.gpgKey != "") { - key = personal.gpgKey; + // lib.optionalAttrs (identity.gpgKey != "") { + key = identity.gpgKey; signByDefault = true; }; ignores = [ @@ -23,8 +23,8 @@ ]; settings = { user = { - name = personal.name; - email = personal.email; + name = identity.name; + email = identity.email; }; gpg.program = "gpg"; init.defaultBranch = "main";