nixos_installation

I've long been tired of the dependency management of Linux and wanted totry a new system: NixOS. It's an operating systemcentered around system configuration – a DevOps tool and a way to manageconfiguration files as well as a proper Linux-based operating system.

I did have a bit of trouble installing it so I wanted to catalogue theprocess here.

To help with the installation, I referenced Domen Kozar'sinstructions,Jethro's configuration andKyle's configuration. I alsomade substantial use of the NixOSmanual and its instructions. I'll besummarizing steps taken by each of these articles; refer to the NixOSmanual or the instructions if you'd like more information about theabbreviated steps.

As the title says, I installed NixOS 20.03 on the Dell XPS 9370 i7UHD. I can't guarantee that these instructions will work for yoursystem. My current configuration, including some of the code mentionedin this article, can be foundhere.

Make sure that you have a flash drive handy with a capacity greater than2 gigabytes. My first go used installation media that didn't have theentire ISO written to it and I had issues booting.

Setup

Recovery Disk

First remember to create a recovery disk for Windows. I didn't do this,but it's probably a good idea! (I'm still looking for my Windowspartition…)

Reboot to the BIOS

Press F2 repeatedly when the Dell logo appears on boot (don't hold it,as this may be interpreted as a stuck key) and reboot into the BIOSsettings.

BIOS Settings

Disable secure boot and RAID mode. It's unclear why RAID mode is on bydefault, but this isn't somethign that should be used by the XPS.

Make an Installation Disk

Download an ISO from the website. Iwouldn't recommend the graphical installation CD, as it'll takesubstantially longer to boot and at the time of this writing offers noreal advantage over the minimal installation disk. You'll be using toolswith command-line interfaces anyways.

Install ISO

For Linux, I recommend using dd to write the media to your USB. ForWindows 10, I'd recommend using Rufus.

I used Rufus and had trouble with the installation media when writingthe ISO, but using DD mode worked well. I'd recommend using that tostart.

Provisioning the Installation

Booting the Installation Media

Plug the flash drive into any port on your laptop and reboot.

On boot, press F10 repeatedly to enter the boot selection mode. Use theup and down arrow keys to navigate to the name of your flash driveloaded with the installation media. Press enter when the proper media ishighlighted.

Initial System Configuration

The computer should now be booted to the NixOS installer. It'll show youseveral images to chose from.

Select NixOS Live CD if you're ready to install. The other optionsprovided may be used if you'd like to try out the operating systemwithout a full installation.

Troubleshooting

If the media didn't boot properly and you do not now see a terminalshowing that you've booted into NixOS, make sure that you've chosen thecorrect installation image for your system. If you provisioned yourinstallation media as an ISO, try using DD mode.

Connecting to The Internet

Now that you've successfully booted the system, it's time to connect tothe internet. Ethernet would be easy but we still have some networkingtools.

We'll want to do everything as root for the installation, so:

sudo -i

To connect to the internet, run

wpa_supplicant -i {WiFi card} <(wpa_passphrase "{SSID}" "{password}")

where {WiFi card} is the name found with ifconfig beginning with wlpor wlan (typically wlan0 or wlp2s0), {SSID} is the name of yourWiFi network and {password} is the password for the network. Make surethat the latter two are both strings.

To confirm your connection, use ping google.com orping {stable site of choice}. If you receive frequent responses at theterminal, you have a connection.

Partitioning the Drive

I'll yield to the Arch Wiki here; they'll maintain documentation moreaccurate and thorough than what I can cover here. Here's the gist of it:

  • Create three partitions:

    • a boot partition {\~100 mb},
    • a main partition {rest of disk, -1/2 ram size},
    • and a swap partition {1/2 ram capacity}.
  • Format each with the file system of your choice.

    • The boot partition should be FAT.
    • The main partition should be a file system of your choice. Use ext4if you want something simple and reliable; use btrfs or zfs if youwant something advanced.
    • The swap partition should be formatted as a swap partition.

Mounting and Installing

This system's a UEFI system, so we'll have to mount two partitions.Mount your main partition to /mnt:

mount nixos /mnt

Mount your boot partition to /mnt/boot:

mkdir -p /mnt/boot
mount boot /mnt/boot

This assumes that you've named your main and boot partitions 'nixos' and'boot' respectively.

Initial Configuration

Now that everything is mounted, you'll want to generate an initialconfiguration for your system.

This can be accomplished with

nixos-generate-config -d

Editing the Configuration

You should now have two files visible in the /etc/nixos directory:

  • configuration.nix
  • hardware-configuration.nix

Make sure that hardware-configuration.nix contains three partitions –one for each partition you created earlier – with the same file systemsand configurations. If not, update the files with the correct values.

Initial Configuration

You'll now need to edit properly configure configuration.nix. Most ofthe defaults are fine, but you'll want to install a sane editor to makeit immediately usable. I'd suggest vim or nvim. You'll probably alsowant git and wget for saving your configuration or cloning that ofanother.

Add these to environment.systemPackages:

environment.systemPackages = [
  nvim wget git
];

You might also want a better program for configuring networking. Ifyou're accustomed to Network Manager, add

~services.networkmanager.enable = true;

to the configuration.

You should probably add a user as well. There's a template for userconfiguration in the file, but try amending it:

users.users.{username} = {
  isNormalUser = true;
  home = "/home/{username}";
  extraGroups = [ "wheel" "networkmanager" ];
};

You'll want to add yourself to the "networkmanager" group if you'reusing Network Manager in lieu of wpasupplicant. 'Wheel' willallow this user to use sudo.

First Boot

You're ready to install and boot the system! Run:

nixos-install

Make sure to set the password for the root user to something youremember when prompted.

Final Touches

Reboot first: reboot. Now, log in as the root user when prompted forlogin and password.

Set an initial password for the user you created:

passwd {username}

and provide the password when prompted.

You're now ready to go!

Revisions
DateHash
2023-02-22
Navigation
Previousinterior-design
Nextreact
Uppages