This is my dendritic Nix(OS) & Home-Manager configuration. Nix besonderes!
It utilizes framework called Den:
Modular, context-aware and aspect-oriented dendritic Nix configurations
After getting familiar with the dendritic approach compared to a more "traditional" flake setup (e.g., EmergentMind's config), I settled on a layout heavily inspired by vic's own config.
It is definitely not something for the faint of heart and if you're unfamiliar with Nix in general, the syntax, or even just flakes, I'd recommend a simpler approach at first.
To bootstrap a (predefined!) device, simply use
sudo nixos-rebuild switch --flake github:DustVoice/nix-config#hostnamewhere hostname corresponds to a hostname defined in modules/my/hosts.nix.
As I normally use my own username instead of the default nixos user used by the NixOS-WSL image,
special care is needed when bootstrapping (and therefore changing the default user) on WSL.
According to the NixOS-WSL documentation, you'd need to
-
Rebuild the
bootinstead of directlyswitching to itsudo nixos-rebuild boot --flake github:DustVoice/nix-config#hostname -
Exit the WSL shell and terminate the distro
wsl.exe -t NixOS
-
Start a shell as the
rootuser and immediately exit, applying the new generationwsl.exe -d NixOS --user root exit
-
Stop the distro again
wsl.exe -t NixOS
-
Finally open a WSL shell with (hopefully) everything applied.
NOTE: This doesn't transfer any files from the
nixosuser's home directory to the newly created user!
When bootstrapping behind a proxy, some intermediate steps become necessary. Although the correct proxy configuration should be present for the specific hostname, bootstrapping the system needs to know about the proxy.
Make sure that your %USERPROFILE%\.wslconfig includes autoProxy=true under the [wsl] section,
or even better, that you're on a recent enough version where this setting is the default.
You can also find this setting in the new WSL Settings app included with recent WSL versions,
under the Network tab.
With the aforementioned automatic proxy setting propagation, the only remaining issue is that sudo
doesn't simply inherit those values.
To circumvent this for bootstrapping (correct env_keep configuration is included in modules/my/hosts.nix),
simply add the --preserve-env=http_proxy,https_proxy,HTTP_PROXY,HTTPS_PROXY parameter,
or even easier the -E flag (preserves all environment variables), to the sudo command.
sudo -E nixos-rebuild switch --flake github:DustVoice/nix-config#hostnameTo utilize the standalone home-manager configurations defined in modules/my/hosts.nix on non-NixOS systems:
-
Then install home-manager
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager nix-channel --update
-
Then build and run the home-manager configuration
home-manager --extra-experimental-features "nix-command flakes" --flake github:DustVoice/nix-config#username switchwhere
usernamecorresponds to a username for which a standalone home-manager config has been defined inmodules/my/hosts.nix