Skip to content

Commit f25f6db

Browse files
authored
feat: set home.homeDirectory based on final username (#62)
1 parent ef3b066 commit f25f6db

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

lib/default.nix

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,24 @@ let
224224
modules = [
225225
perSystemModule
226226
modulePath
227-
{
228-
home.username = lib.mkDefault username;
229-
# Home Manager would use builtins.getEnv prior to 20.09, but
230-
# this feature was removed to make it pure. However, since
231-
# we know the operating system and username ahead of time,
232-
# it's safe enough to automatically set a default for the home
233-
# directory and let users customize it if they want. This is
234-
# done automatically in the NixOS or nix-darwin modules too.
235-
home.homeDirectory = lib.mkDefault (
236-
if pkgs.stdenv.isDarwin then "/Users/${username}" else "/home/${username}"
237-
);
238-
}
227+
(
228+
{ config, ... }:
229+
{
230+
home.username = lib.mkDefault username;
231+
# Home Manager would use builtins.getEnv prior to 20.09, but
232+
# this feature was removed to make it pure. However, since
233+
# we know the operating system and username ahead of time,
234+
# it's safe enough to automatically set a default for the home
235+
# directory and let users customize it if they want. This is
236+
# done automatically in the NixOS or nix-darwin modules too.
237+
home.homeDirectory =
238+
let
239+
username = config.home.username;
240+
homeDir = if pkgs.stdenv.isDarwin then "/Users/${username}" else "/home/${username}";
241+
in
242+
lib.mkDefault homeDir;
243+
}
244+
)
239245
];
240246
};
241247

0 commit comments

Comments
 (0)