|
3 | 3 |
|
4 | 4 | inputs = { |
5 | 5 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
6 | | - nix-darwin.url = "github:LnL7/nix-darwin"; |
7 | | - nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; |
| 6 | + nix-darwin = { |
| 7 | + url = "github:LnL7/nix-darwin"; |
| 8 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 9 | + }; |
8 | 10 | nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew"; |
9 | 11 |
|
10 | 12 | # Linux-specific inputs |
11 | | - home-manager.url = "github:nix-community/home-manager"; |
12 | | - home-manager.inputs.nixpkgs.follows = "nixpkgs"; |
| 13 | + home-manager = { |
| 14 | + url = "github:nix-community/home-manager"; |
| 15 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 16 | + }; |
13 | 17 | }; |
14 | 18 |
|
15 | 19 | outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager }: |
16 | 20 | let |
| 21 | + # Overlays |
| 22 | + overlays = [ |
| 23 | + (import ./overlays/tfenv.nix) |
| 24 | + (import ./overlays/nvm.nix) |
| 25 | + (import ./overlays/browser-forward.nix) |
| 26 | + ]; |
| 27 | + |
| 28 | + # Create a version of nixpkgs with our overlays for Linux |
| 29 | + nixpkgsWithOverlays = system: import nixpkgs { inherit system overlays; }; |
| 30 | + |
17 | 31 | # Default macOS configuration |
18 | 32 | darwinSystem = { hostname ? "macbook", # Generic default hostname |
19 | 33 | username ? "user", # Generic default username |
|
33 | 47 | # Add Home Manager to Darwin |
34 | 48 | home-manager.darwinModules.home-manager |
35 | 49 | { |
36 | | - home-manager.useGlobalPkgs = true; |
37 | | - home-manager.useUserPackages = true; |
38 | | - home-manager.extraSpecialArgs = { inherit username; }; |
39 | | - # Add backup file extension to avoid conflicts |
40 | | - home-manager.backupFileExtension = "backup"; |
41 | | - |
42 | | - # Inline Home Manager configuration |
43 | | - home-manager.users.${username} = { config, lib, pkgs, ... }: |
44 | | - let sharedZsh = import ./common/zsh/shared.nix; |
45 | | - in { |
46 | | - home.username = username; |
47 | | - home.homeDirectory = "/Users/${username}"; |
48 | | - home.stateVersion = "23.11"; |
49 | | - |
50 | | - programs.zsh = { |
51 | | - enable = true; |
52 | | - |
53 | | - oh-my-zsh = { |
54 | | - enable = true; |
55 | | - plugins = [ "git" ]; |
56 | | - theme = ""; |
| 50 | + home-manager = { |
| 51 | + useGlobalPkgs = true; |
| 52 | + useUserPackages = true; |
| 53 | + extraSpecialArgs = { inherit username; }; |
| 54 | + backupFileExtension = "backup"; |
| 55 | + |
| 56 | + # Inline Home Manager configuration |
| 57 | + users.${username} = { config, lib, pkgs, ... }: |
| 58 | + let sharedZsh = import ./common/zsh/shared.nix; |
| 59 | + in { |
| 60 | + home = { |
| 61 | + username = username; |
| 62 | + homeDirectory = "/Users/${username}"; |
| 63 | + stateVersion = "23.11"; |
57 | 64 | }; |
58 | 65 |
|
59 | | - shellAliases = sharedZsh.aliases // { |
60 | | - nixswitch = |
61 | | - "darwin-rebuild switch --flake ~/.config/nix#${hostname}"; |
| 66 | + programs.zsh = { |
| 67 | + enable = true; |
| 68 | + |
| 69 | + oh-my-zsh = { |
| 70 | + enable = true; |
| 71 | + plugins = [ "git" ]; |
| 72 | + theme = ""; |
| 73 | + }; |
| 74 | + |
| 75 | + shellAliases = sharedZsh.aliases // { |
| 76 | + nixswitch = |
| 77 | + "darwin-rebuild switch --flake ~/.config/nix#${hostname}"; |
| 78 | + }; |
| 79 | + |
| 80 | + initContent = '' |
| 81 | + # Source common settings |
| 82 | + ${sharedZsh.options} |
| 83 | + ${sharedZsh.keybindings} |
| 84 | + ${sharedZsh.tools} |
| 85 | +
|
| 86 | + # Ensure Oh My Posh is properly initialized |
| 87 | + if command -v oh-my-posh &> /dev/null; then |
| 88 | + eval "$(oh-my-posh --init --shell zsh --config ~/.config/oh-my-posh/default.omp.json)" |
| 89 | + fi |
| 90 | + ''; |
62 | 91 | }; |
63 | 92 |
|
64 | | - initContent = '' |
65 | | - # Source common settings |
66 | | - ${sharedZsh.options} |
67 | | - ${sharedZsh.keybindings} |
68 | | - ${sharedZsh.tools} |
69 | | -
|
70 | | - # Ensure Oh My Posh is properly initialized |
71 | | - if command -v oh-my-posh &> /dev/null; then |
72 | | - eval "$(oh-my-posh --init --shell zsh --config ~/.config/oh-my-posh/default.omp.json)" |
73 | | - fi |
74 | | - ''; |
| 93 | + home.file.".config/oh-my-posh/default.omp.json".source = |
| 94 | + ./common/zsh/default.omp.json; |
75 | 95 | }; |
76 | | - |
77 | | - home.file.".config/oh-my-posh/default.omp.json".source = |
78 | | - ./common/zsh/default.omp.json; |
79 | | - }; |
| 96 | + }; |
80 | 97 | } |
81 | 98 | ] ++ extraModules; |
82 | | - specialArgs = { |
83 | | - inherit inputs self hostname; |
84 | | - username = username; |
85 | | - }; |
86 | | - }; |
87 | 99 |
|
88 | | - # Overlays |
89 | | - overlays = [ |
90 | | - (import ./overlays/tfenv.nix) |
91 | | - (import ./overlays/nvm.nix) |
92 | | - (import ./overlays/browser-forward.nix) |
93 | | - ]; |
94 | | - |
95 | | - # Create a version of nixpkgs with our overlays for Linux |
96 | | - nixpkgsWithOverlays = system: |
97 | | - import nixpkgs { |
98 | | - inherit system; |
99 | | - inherit overlays; |
| 100 | + specialArgs = { inherit inputs self hostname username; }; |
100 | 101 | }; |
101 | 102 | in { |
102 | | - # Generic macOS configuration - can be customized with hostname and user |
| 103 | + # macOS configurations |
103 | 104 | darwinConfigurations = { |
104 | 105 | "macbook" = darwinSystem { |
105 | 106 | hostname = "macbook"; |
|
113 | 114 | }; |
114 | 115 |
|
115 | 116 | # Standalone home-manager configuration for Vagrant VM |
116 | | - # Install with: |
117 | | - # $ nix run home-manager/master -- switch --flake ~/.config/nix#vagrant |
118 | | - homeConfigurations = { |
119 | | - "vagrant" = home-manager.lib.homeManagerConfiguration { |
120 | | - pkgs = nixpkgsWithOverlays "aarch64-linux"; |
121 | | - modules = [ |
122 | | - ./vagrant/home.nix |
123 | | - { |
124 | | - home = { |
125 | | - username = "vagrant"; |
126 | | - homeDirectory = "/home/vagrant"; |
127 | | - stateVersion = "23.11"; |
128 | | - }; |
129 | | - nixpkgs.config.allowUnfree = true; |
130 | | - |
131 | | - # Explicitly specify nix.package for home-manager |
132 | | - nix = { |
133 | | - package = nixpkgs.legacyPackages.aarch64-linux.nix; |
134 | | - settings = { |
135 | | - experimental-features = [ "nix-command" "flakes" ]; |
136 | | - }; |
137 | | - }; |
138 | | - |
139 | | - programs.fish = { enable = false; }; |
140 | | - |
141 | | - nixpkgs.overlays = [ |
142 | | - (final: prev: { |
143 | | - # Override fish package properly inside the module |
144 | | - fish = prev.fish.overrideAttrs (oldAttrs: { |
145 | | - doCheck = false; |
146 | | - doInstallCheck = false; |
147 | | - }); |
148 | | - }) |
149 | | - ]; |
150 | | - } |
151 | | - ]; |
152 | | - extraSpecialArgs = { username = "vagrant"; }; |
153 | | - }; |
| 117 | + homeConfigurations.vagrant = home-manager.lib.homeManagerConfiguration { |
| 118 | + pkgs = nixpkgsWithOverlays "aarch64-linux"; |
| 119 | + modules = [ |
| 120 | + ./vagrant/home.nix |
| 121 | + { |
| 122 | + home = { |
| 123 | + username = "vagrant"; |
| 124 | + homeDirectory = "/home/vagrant"; |
| 125 | + stateVersion = "23.11"; |
| 126 | + }; |
| 127 | + |
| 128 | + nixpkgs.config.allowUnfree = true; |
| 129 | + |
| 130 | + # Explicitly specify nix.package for home-manager |
| 131 | + nix = { |
| 132 | + package = nixpkgs.legacyPackages.aarch64-linux.nix; |
| 133 | + settings.experimental-features = [ "nix-command" "flakes" ]; |
| 134 | + }; |
| 135 | + |
| 136 | + programs.fish.enable = false; |
| 137 | + |
| 138 | + nixpkgs.overlays = [ |
| 139 | + (final: prev: { |
| 140 | + # Override fish package properly inside the module |
| 141 | + fish = prev.fish.overrideAttrs (oldAttrs: { |
| 142 | + doCheck = false; |
| 143 | + doInstallCheck = false; |
| 144 | + }); |
| 145 | + }) |
| 146 | + ]; |
| 147 | + } |
| 148 | + ]; |
| 149 | + extraSpecialArgs = { username = "vagrant"; }; |
154 | 150 | }; |
155 | 151 | }; |
156 | 152 | } |
0 commit comments