Hello all,
I am very new to the world of Nix and am using standalone home-manager with nix flakes. I would like to use the same configuration for both my PopOS machine and my Windows machine (WSL2). It turns out that I have different usernames on each machine. How should I modify my home.nix
and flake.nix
files to work on both machines? My configuration is version controlled and I would like it to “just work” across machines despite their differences in username. Is there any way to programatically fetch the username ($USER in bash) and home directory ($HOME in bash) inside of the Nix files?
Thank you.
home.nix
...
home.username = "myusername"
home.homeDirectory = "/home/myusername"
...
flake.nix
{
inputs = {...};
output = {...}: let
...
in {
homeConfigurations."myusername" = home-manager.lib.homeManagerConfiguration {
...
};
}
}