- System Components
- NixOS Installation Guide
- Nix Installation Guide
- Nix-Darwin Installation Guide
- Guides
- FAQ
NixOS - Wayland | NixOS - Wayland/Xorg | NixOS - Xorg | Darwin | |
---|---|---|---|---|
DM | / | GDM | LightDM | / |
WM/DE | Hyprland | Gnome | Bspwm | Raycast |
Compositor | Hyprland | Mutter | Picom (jonaburg) | / |
Bar | Eww + Waybar | / | Polybar | / |
Hotkeys | Hyprland | / | Sxhkd | Raycast |
Launcher | Wofi | Gnome | Rofi | Raycast |
GTK Theme | Orchis-Dark | Adwaita | Orchis-Dark | / |
Notifications | Swaync | Gnome | Dunst | / |
Terminal | Kitty | Kitty | Kitty | Kitty |
Used by host | Beelink, XPS | Work | VM & Probook | MacBook{Intel or AirM1} |
There are some other desktop environments/window manager (See NixOS - Other). Just link to correct default/home.nix
in ./hosts/<host>/default and home.nix
.
There is also a general Nix config with hostname pacman
that can be used on pretty much any disto.
Components relevant to all hosts:
Shell | Zsh |
Terminal | Kitty |
Editors | Neovim |
This flake currently has 3 host setups
- Beelink & XPS
- UEFI boot w/ systemd-boot
- Work & Probook
- UEFI boot w/ grub
- vm
- Legacy boot w/ grub
Flakes can be build with:
$ sudo nixos-rebuild switch --flake <path>#<hostname>
- example
$ sudo nixos-rebuild switch --flake .#desktop
This will depend on the host chosen.
In these commands
- Partition Labels:
- Boot = “boot”
- Home = “nixos”
- Partition Size:
- Boot = 512MiB
- Swap = 8GiB
- Home = Rest
- No Swap: Ignore line 3 & 7
# parted /dev/sda -- mklabel gpt # parted /dev/sda -- mkpart primary 512MiB -8GiB # parted /dev/sda -- mkpart primary linux-swap -8GiB 100% # parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB # parted /dev/sda -- set 3 esp # mkfs.ext4 -L nixos /dev/sda1 # mkswap -L /dev/sda2 # mkfs.fat -F 32 -n boot /dev/sda3
In these commands
- Partition Label:
- Home & Boot = “nixos”
- Swap = “swap”
- Partition Size:
- Swap = 8GiB
- Home = Rest
- No swap: Ignore line 3 and 5
# parted /dev/sda -- mklabel msdos # parted /dev/sda -- mkpart primary 1MiB -8GiB # parted /dev/sda -- mkpart primary linux-swap -8GiB 100% # mkfs.ext4 -L nixos /dev/sda1 # mkswap -L /dev/sda2
In these commands
- Mount partition with label … on …
- “nixos” ->
/mnt
- “boot” ->
/mnt/boot
- “nixos” ->
# mount /dev/disk/by-label/nixos /mnt # mkdir -p /mnt/boot # mount /dev/disk/by-label/boot /mnt/boot
# mount /dev/disk/by-label/nixos /mnt
In these commands
/mnt/ssd
- Label of storage:
- ssd2
- If storage has no label:
mount /dev/disk/by-uuid/ssd2 /mnt/ssd
# mkdir -p /mnt/ssd # mount /dev/disk/by-label/ssd2 /mnt/ssd
In these commands
- Swap is enable:
- Ignore if no swap or enough RAM
- Configuration files are generated @
/mnt/etc/nixos
- If you are me, you don’t need to do this. Hardware-configuration.nix already in flake.
- Clone repository
# swapon /dev/sda2 # nixos-generate-config --root /mnt # nix-env -iA nixos.git # git clone https://github.com/matthiasbenaets/nixos-config /mnt/etc/nixos/<name> Optional if you are not me # cp /mnt/etc/nixos/hardware-configuration.nix /mnt/etc/nixos/nixos-config/hosts/<host>/.
- Switch specific host hardware-configuration.nix with generated
/mnt/etc/nixos/hardware-configuration.nix
- Change existing network card name with the one in your system
- Look in generated hardware-configuration.nix
- Or enter
$ ip a
- Change username in flake.nix
- Set a
users.users.${user}.initialPassword = ...
- Not really recommended. It’s maybe better to follow last steps
- If you are planning on using the doom-emacs alternative home.nix, don’t forget to rebuild after the initial installation when you link to this nix file.
- This is because userActivationScript is used for this setup and this will time out during the rebuild.
- It will automatically install if
$HOME/.emacs.d
does not exist- If this dir already exist, move or delete it.
In these commands
- Move into cloned repository
- in this example
/mnt/etc/nixos/<name>
- in this example
- Available hosts:
- desktop
- laptop
- vm
# cd /mnt/etc/nixos/<name> # nixos-install --flake .#<host>
- Set a root password after installation is done
- Reboot without liveCD
- Login
- If initialPassword is not set use TTY:
Ctrl - Alt - F1
- login as root
# passwd <user>
Ctrl - Alt - F7
- login as user
- If initialPassword is not set use TTY:
- Optional:
$ sudo mv <location of cloned directory> <prefered location>
$ sudo chown -R <user>:users <new directory location>
$ sudo rm /etc/nixos/configuration.nix
- This is done because in the past it would auto update this config if you would have auto update in your configuration.- or just clone flake again do apply same changes.
- Dual boot:
- OSProber probably did not find your Windows partition after the first install
- There is a high likelihood it will find it after:
$ sudo nixos-rebuild switch --flake <config path>#<host>
- Rebuilds:
$ sudo nixos-rebuild switch --flake <config path>#<host>
- For example
$ sudo nixos-rebuild switch --flake ~/.setup#matthias
This flake currently has 1 host
- pacman
The Linux distribution must have the nix package manager installed.
$ sh <(curl -L https://nixos.org/nix/install) --daemon
To be able to have an easy reproducible setup when using the nix package manager on a non-NixOS system, home-manager is a wonderful tool to achieve this.
So this is how it is set up in this flake.
In these commands
- Get git
- Clone repository
- First build of the flake
- This is done so we can use the home-manager command is part of PATH.
$ nix-env -iA nixpkgs.git $ git clone https://github.com/matthiasbenaets/nixos-config ~/.setup $ cd ~/.setup $ nix build --extra-experimental-features 'nix-command flakes' .#homeConfigurations.<host>.activationPackage $ ./result/activate
Since home-manager is now a valid command we can rebuild the system using this command. In this example it is build from inside the flake directory:
$ home-manager switch --flake <config path>#<host>
This will rebuild the configuration and automatically activate it.
Mostly optional or already correct by default
- NixGL gets set up by default, so if you are planning on using GUI applications that use OpenGL or Vulkan:
$ nixGLIntel <package>
- or add it to your aliases file
- Every rebuild, and activation-script will run to add applications to the system menu.
- it’s pretty much the same as adding the path to XDG_DATA_DIRS
- if you do not want to or if the locations are different, change this.
This flake currently has 1 host
- macbook
The Apple computer must have the nix package manager installed.
In terminal run command: $ sh <(curl -L https://nixos.org/nix/install)
In these commands
- Create a nix config directory
- Allow experimental features to use flakes
$ mkdir ~/.config/nix $ echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
In these commands
- Get git
- Clone repository
- First build of the flake on Darwin
- This is done because the darwin command is not yet available
$ nix-env -iA nixpkgs.git $ git clone https://github.com/matthiasbenaets/nixos-config ~/.setup $ cd ~/.setup $ nix build .#darwinConfigurations.<host>.system $ ./result/sw/bin/darwin-rebuild switch --flake .#<host>
/result
is located depending on where you build the system.
Since darwin is now added to the PATH, you can build it from anywhere in the system. In this example it is rebuilt from inside the flake directory:
$ darwin-rebuild switch --flake .#<host>
This will rebuild the configuration and automatically activate it.
Mostly optional or already correct by default
- Change default shell for Terminal or iTerm.
Terminal/iTerm > Preferences > General > Shells open with: Command > /bin/zsh
- Disable Secure Keyboard Entry. Needed for Skhd.
Terminal/iTerm > Secure Keyboard Entry
- Install XCode to get complete development environment.
$ xcode-select --install
- NixOS general guide
- Nix on other Linux distributions
- Nix on MacOS with Nix-Darwin
- Contribution to nixpkgs
- Using nix shells
- What is NixOS?
- NixOS is a Linux distribution built on top of the Nix package manager.
- It uses declarative configurations and allow reliable system upgrades.
- What is a Flake?
- Flakes are an upcoming feature of the Nix package manager.
- Flakes allow you to specify your major code dependencies in a declarative way.
- It does this by creating a flake.lock file. Some major code dependencies are:
- nixpkgs
- home-manager
- What is Nix-Darwin?
- Nix-Darwin is a way to use Nix modules on macOS using the Darwin Unix-based core set of components.
- Just like NixOS, it allows to build declarative reproducible configurations.
- Should I switch to NixOS?
- Is water wet?
- Where can I learn about everything Nix?
- Nix and NixOS
- Home-manager
- Flakes
- Nix-Darwin
- Videos