This post explain how to get NixOS up and running without getting overloaded with too many new terms.
Highlighted text is additional information that can be ignored if you only want to play with NixOS.
This post assumes you can create a virtual machine.
NixOS is a Linux distribution with a fancy package manager. You manage the whole system by editing a single configuration file. The package manager takes care of installing and configuring each package and service on your system, based on your single file.
This is like user dotfiles (1,2) but for your whole system.
Or
Kickstart but for everything and way more features.
wget https://channels.nixos.org/nixos-19.09/latest-nixos-graphical-x86_64-linux.iso{,.sha256}
sha256sum -c latest-nixos-graphical-x86_64-linux.iso.sha256
sudo parted /dev/sda -- mklabel msdos
sudo parted /dev/sda -- mkpart primary 1MiB -8GiB
sudo parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
Above commands are for BIOS not UEFI. Make sure your VM matches.
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mount /dev/disk/by-label/nixos /mnt
swapon /dev/sda2
/mnt/etc/nixos/configuration.nix
and /mnt/etc/nixos/hardware-configuration.nix
.nixos-generate-config --root /mnt
configuration.nix
should look like this:{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
# Use the GRUB 2 boot loader. (BIOS)
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
boot.loader.grub.device = "/dev/sda";
networking.hostName = "nixos";
networking.interfaces.ens3.useDHCP = true;
# Set your time zone.
time.timeZone = "Europe/Dublin";
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
wget vim htop
];
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
services.openssh.permitRootLogin = "yes";
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 22 ];
# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.freethink = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
};
system.stateVersion = "19.09";
}
reboot
and remove the ISO.nixos-install
...
reboot
Use the bleeding edge unstable versions.
nix-channel --add https://nixos.org/channels/nixos-unstable nixos
nixos-rebuild switch --upgrade
Note, you might be tempted to edit configuration.nix’s
system.stateVersion = "19.09"
. Don’t do that, it won’t change your channel. This option is used to prevent major changes in packages from breaking your system.
Once rebooted you will be able to ssh into the machine using the root account and password.
ssh root@ip.address
Now you have a fresh install of NixOS to play with.
This might become a blog series. Come back soon.
Website Last Updated on 4 Oct 2024 (CC BY-SA 4.0)
This site uses JQuery and nanogallery2 hosted by jsdelivr.net
for the Flickr photo feed and GoatCounter for user insights.