|
91 | 91 | system ? "x86_64-linux", |
92 | 92 | }: let |
93 | 93 | user-metadata = split-user-and-host name; |
| 94 | + unique-name = |
| 95 | + if user-metadata.host == "" |
| 96 | + then "${user-metadata.user}@${system}" |
| 97 | + else name; |
94 | 98 |
|
95 | 99 | # NOTE: home-manager has trouble with `pkgs` recursion if it isn't passed in here. |
96 | 100 | pkgs = user-inputs.self.pkgs.${system}.${channelName} // {lib = home-lib;}; |
|
110 | 114 | ++ modules; |
111 | 115 |
|
112 | 116 | specialArgs = { |
113 | | - inherit name system; |
| 117 | + inherit system; |
| 118 | + name = unique-name; |
114 | 119 | inherit (user-metadata) user host; |
115 | 120 |
|
116 | 121 | format = "home"; |
@@ -161,16 +166,22 @@ in { |
161 | 166 | get-target-homes-metadata = target: let |
162 | 167 | homes = snowfall-lib.fs.get-directories target; |
163 | 168 | existing-homes = builtins.filter (home: builtins.pathExists "${home}/default.nix") homes; |
164 | | - create-home-metadata = path: { |
165 | | - path = "${path}/default.nix"; |
| 169 | + create-home-metadata = path: let |
166 | 170 | # We are building flake outputs based on file contents. Nix doesn't like this |
167 | 171 | # so we have to explicitly discard the string's path context to allow us to |
168 | 172 | # use the name as a variable. |
169 | | - name = builtins.unsafeDiscardStringContext (builtins.baseNameOf path); |
| 173 | + basename = builtins.unsafeDiscardStringContext (builtins.baseNameOf path); |
170 | 174 | # We are building flake outputs based on file contents. Nix doesn't like this |
171 | 175 | # so we have to explicitly discard the string's path context to allow us to |
172 | 176 | # use the name as a variable. |
173 | 177 | system = builtins.unsafeDiscardStringContext (builtins.baseNameOf target); |
| 178 | + name = |
| 179 | + if !(hasInfix "@" basename) |
| 180 | + then "${basename}@${system}" |
| 181 | + else basename; |
| 182 | + in { |
| 183 | + path = "${path}/default.nix"; |
| 184 | + inherit name system; |
174 | 185 | }; |
175 | 186 | home-configurations = builtins.map create-home-metadata existing-homes; |
176 | 187 | in |
|
302 | 313 | ... |
303 | 314 | }: let |
304 | 315 | host-matches = |
305 | | - (created-user.specialArgs.host == host) |
306 | | - || (created-user.specialArgs.host == "" && created-user.specialArgs.system == system); |
| 316 | + (name == "${user-name}@${host}") |
| 317 | + || (name == "${user-name}@${system}"); |
307 | 318 |
|
308 | 319 | # NOTE: To conform to the config structure of home-manager, we have to |
309 | 320 | # remap the options coming from `snowfallorg.user.<name>.home.config` since `mkAliasDefinitions` |
|
0 commit comments