Skip to content

First NixOS Graphical Install

Prerequisites

Installation

  1. Boot the ISO in a new VM (using BIOS instead of UEFI).
  2. The NixOs Installer should have started automatically - step through it.
  3. As we'll initial focus on a minimal headless server installation chose No Desktop (for now).
  4. At the end, shut-down the VM, remove the installation ISO image, and restart the VM.

You now have your very first NixOS-based (VM) machine!

PS: The screen & font may be tiny; we'll fix that later.

Nix files

The result of the graphical configuration from the previous step is stored in /etc/nixos/configuration.nix (and its hardware-configuration.nix).

You can edit that file to further customize your NixOS installation.

SSH

Let's enable SSH access! Edit /etc/nixos/configuration.nix and uncomment the following line:

services.openssh.enable = true;

Run sudo nixos-rebuild switch to apply the changes.

Test that SSH is working by connecting locally from the VM to itself:

ssh localhost

To connect from the host to the VM, find out the VM's IP address (e.g., using ip a on the VM; for GNOME Boxes, it may be 192.168.122.x), and connect to that IP address from your host machine:

ssh -At <vm-ip-address>

Packages

Let's install some packages, like git and perhaps the fish shell - and any others you may want. Edit /etc/nixos/configuration.nix and add the following lines inside the top-level { config, pkgs, ... }: block:

environment.systemPackages = with pkgs; [
  fish
  git
];

Note that NixOS has environment.systemPackages as well as a packages in the users.users.<your-username> section. We're using environment.systemPackages here to install packages system-wide for now, and will revisit user-specific packages later.

After editing, run sudo nixos-rebuild switch again; you now have git and fish installed.

Git

It's a good idea to keep your NixOS configuration files in a Git repository. Create your own nixfiles Git repository now - similar to this! Then do something like:

mkdir modules/hosts/vm1
scp "192.168.122.72:/etc/nixos/*" modules/hosts/vm1/

TODO Beware that if you use a layout like this repo, then you cannot directly put the configuration.nix and hardware-configuration.nix files into it...