From d85957eeedaa45bebec5a621a687a748e62caca4 Mon Sep 17 00:00:00 2001 From: Hare Date: Sat, 17 Oct 2026 00:01:06 +0900 Subject: [PATCH] feat: make nh host selection automatic --- README.md | 4 ++-- hosts/default.nix | 7 ++++++- hosts/mkHost.nix | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9d26ac4..33acf45 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ nix run .#home-manager -- switch --flake .#@ `nh` 導入後: ``` -nh os switch -H +nh os switch -nh home switch -c @ +nh home switch ``` diff --git a/hosts/default.nix b/hosts/default.nix index 09a9938..c17dc86 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -5,6 +5,11 @@ rec { x1carbon = import ./x1carbon inputs; fungus = import ./fungus inputs; }; - nixos = builtins.mapAttrs (_: host: host.nixos) hosts; + nixos = builtins.listToAttrs ( + map (host: { + name = host.hostname; + value = host.nixos; + }) (builtins.attrValues hosts) + ); home-manager = builtins.foldl' (a: b: a // b) { } (map (h: h.home-manager) (builtins.attrValues hosts)); } diff --git a/hosts/mkHost.nix b/hosts/mkHost.nix index f325f43..207a359 100644 --- a/hosts/mkHost.nix +++ b/hosts/mkHost.nix @@ -12,6 +12,8 @@ let }; in { + inherit hostname; + nixos = inputs.nixpkgs.lib.nixosSystem { modules = systemModules