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 for the first time requires some temporary environment modifications:
proxy_url="http://user:password@proxy:port/"export http_proxy="$proxy_url"
export https_proxy="$proxy_url"
export HTTP_PROXY="$proxy_url"
export HTTPS_PROXY="$proxy_url"
export CURL_NIX_FLAGS="-x $proxy_url"Unfortunately there is only a limited set of environment variables which get copied over by sudo!
This might be wise from a security standpoint but is annoying in this case.
To circumvent this, add --preserve-env=http_proxy,https_proxy,HTTP_PROXY,HTTPS_PROXY as an argument to sudo:
sudo --preserve-env=http_proxy,https_proxy,HTTP_PROXY,HTTPS_PROXY,CURL_NIX_FLAGS 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