Skip to content

Dendritic NixOS & Home-Manager configuration - Nix besonderes!

Notifications You must be signed in to change notification settings

DustVoice/nix-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DustVoice's Nix(OS) & Home-Manager config

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.

Bootstrap on NixOS

To bootstrap a (predefined!) device, simply use

sudo nixos-rebuild switch --flake github:DustVoice/nix-config#hostname

where hostname corresponds to a hostname defined in modules/my/hosts.nix.

WSL

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

  1. Rebuild the boot instead of directly switching to it

    sudo nixos-rebuild boot --flake github:DustVoice/nix-config#hostname
  2. Exit the WSL shell and terminate the distro

    wsl.exe -t NixOS
  3. Start a shell as the root user and immediately exit, applying the new generation

    wsl.exe -d NixOS --user root exit
  4. Stop the distro again

    wsl.exe -t NixOS
  5. Finally open a WSL shell with (hopefully) everything applied.

    NOTE: This doesn't transfer any files from the nixos user's home directory to the newly created user!

Proxy

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#hostname

Bootstrap on Generic Linux

To utilize the standalone home-manager configurations defined in modules/my/hosts.nix on non-NixOS systems:

  1. First install Nix (the Package Manager)

  2. Then install home-manager

    nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
    nix-channel --update
  3. Then build and run the home-manager configuration

    home-manager --extra-experimental-features "nix-command flakes" --flake github:DustVoice/nix-config#username switch

    where username corresponds to a username for which a standalone home-manager config has been defined in modules/my/hosts.nix

About

Dendritic NixOS & Home-Manager configuration - Nix besonderes!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages