From 6368fe594ac5fb77a2fbb9509a3b7c6b4addd5f1 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Fri, 29 Aug 2025 23:16:24 +0200 Subject: [PATCH] Use host-specific home configuration --- flake.nix | 49 ++++++++----------------------- home/common.nix | 33 +++++++++++++++++++++ hosts/darwin/MacBook-Air/home.nix | 11 +++++++ hosts/darwin/iMac/home.nix | 11 +++++++ modules/zsh.nix | 4 +-- 5 files changed, 69 insertions(+), 39 deletions(-) create mode 100644 home/common.nix create mode 100644 hosts/darwin/MacBook-Air/home.nix create mode 100644 hosts/darwin/iMac/home.nix diff --git a/flake.nix b/flake.nix index 3696fee..41d89a2 100644 --- a/flake.nix +++ b/flake.nix @@ -46,39 +46,6 @@ programs.zsh.enable = true; }; - homeConfiguration = { pkgs, ... }: { - imports = [ - nixvim.homeManagerModules.nixvim - ./modules/nvim.nix - ./modules/tmux.nix - ./modules/zsh.nix - ./modules/ssh.nix - ./modules/git.nix - ./modules/lazygit.nix - ./modules/papis.nix - ./modules/termscp.nix - ./modules/rsync.nix - ./modules/btop.nix - ./modules/firefox.nix - ./modules/ghostty.nix - ./modules/syncthing.nix - ./config/fonts.nix - ./config/packages/common.nix - ./config/packages/darwin.nix - ./config/packages/dev.nix - ./config/packages/productivity.nix - ]; - - nixpkgs.config.allowUnfree = true; - - home.username = "yanlin"; - home.homeDirectory = "/Users/yanlin"; - home.stateVersion = "24.05"; - - programs.home-manager.enable = true; - - - }; in { darwinConfigurations."iMac" = nix-darwin.lib.darwinSystem { @@ -97,10 +64,18 @@ ]; }; - homeConfigurations.yanlin = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.aarch64-darwin; - modules = [ homeConfiguration ]; - extraSpecialArgs = { inherit claude-code nixvim firefox-addons; }; + homeConfigurations = { + "yanlin@iMac" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.aarch64-darwin; + modules = [ ./hosts/darwin/iMac/home.nix ]; + extraSpecialArgs = { inherit claude-code nixvim firefox-addons; }; + }; + + "yanlin@MacBook-Air" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages.aarch64-darwin; + modules = [ ./hosts/darwin/MacBook-Air/home.nix ]; + extraSpecialArgs = { inherit claude-code nixvim firefox-addons; }; + }; }; }; } diff --git a/home/common.nix b/home/common.nix new file mode 100644 index 0000000..1be906d --- /dev/null +++ b/home/common.nix @@ -0,0 +1,33 @@ +{ config, pkgs, nixvim, claude-code, firefox-addons, ... }: + +{ + imports = [ + nixvim.homeManagerModules.nixvim + ../modules/nvim.nix + ../modules/tmux.nix + ../modules/zsh.nix + ../modules/ssh.nix + ../modules/git.nix + ../modules/lazygit.nix + ../modules/papis.nix + ../modules/termscp.nix + ../modules/rsync.nix + ../modules/btop.nix + ../modules/firefox.nix + ../modules/ghostty.nix + ../modules/syncthing.nix + ../config/fonts.nix + ../config/packages/common.nix + ../config/packages/darwin.nix + ../config/packages/dev.nix + ../config/packages/productivity.nix + ]; + + nixpkgs.config.allowUnfree = true; + + home.username = "yanlin"; + home.homeDirectory = "/Users/yanlin"; + home.stateVersion = "24.05"; + + programs.home-manager.enable = true; +} \ No newline at end of file diff --git a/hosts/darwin/MacBook-Air/home.nix b/hosts/darwin/MacBook-Air/home.nix new file mode 100644 index 0000000..21d61e2 --- /dev/null +++ b/hosts/darwin/MacBook-Air/home.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../../../home/common.nix + ]; + + # MacBook Air-specific home configuration + # Example: Laptop-specific tools, power management, etc. + +} diff --git a/hosts/darwin/iMac/home.nix b/hosts/darwin/iMac/home.nix new file mode 100644 index 0000000..7bb4c24 --- /dev/null +++ b/hosts/darwin/iMac/home.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../../../home/common.nix + ]; + + # iMac-specific home configuration + # Example: Different screen setup, desktop-specific tools, etc. + +} diff --git a/modules/zsh.nix b/modules/zsh.nix index d785483..ea43e8c 100644 --- a/modules/zsh.nix +++ b/modules/zsh.nix @@ -24,8 +24,8 @@ in # Nix helpers hm = "home-manager"; - hms = "home-manager switch --flake ~/.config/nix#yanlin"; - hms-offline = "home-manager switch --flake ~/.config/nix#yanlin --option substitute false"; + hms = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname)"; + hms-offline = "home-manager switch --flake ~/.config/nix#$(whoami)@$(hostname) --option substitute false"; } // lib.optionalAttrs pkgs.stdenv.isDarwin { # macOS-specific app aliases