Skip to content

Latest commit

 

History

History
181 lines (125 loc) · 2.71 KB

fresh_nixos_install.md

File metadata and controls

181 lines (125 loc) · 2.71 KB

My NixOS installation guide

Booting into live iso

Setting keyboard layout

On minimal iso:

loadkeys de-latin1

On X-Server iso:

setxkbmap de

Partitioning

Creating new gpt partition table

parted /dev/sda -- mklabel gpt

Setting up partition layout with cfdisk

cfdisk /dev/sda

Partition layout:

Device Size Type
/dev/sda1 512M EFI System
/dev/sda2 8G (size of your RAM) Linux Swap
/dev/sda3 457G (free space left) Linux Filesystem

Format the partitions

mkfs.fat -F 32 -n boot /dev/sda1
mkswap -L swap /dev/sda2
mkfs.ext4 -L nixos /dev/sda3

Mounting

mount /dev/disk/by-label/nixos /mnt
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
swapon /dev/sda2

Initial NixOS Configuration

nixos-generate-config --root /mnt

Generates /etc/nixos/configuration.nix and /etc/nixos/hardware-configuration.nix in /mnt

System installation

nixos-install

Install some package

For example: git

sudo nix-env -iA nixos.git

Showing all packages installed via nix-env

sudo nix-env -q

Uninstall a package

sudo nix-env --uninstall git

Update&Upgrade

nix-channel --update
nixos-rebuild switch --upgrade

Garbage collection

List all generations

nix-env --list-generations
nix-env --delete-generations 1
nix-env --delete-older-than 7d
nix-collect-garbage
sudo nix-collect-garbage -d 

Home Manager

Installation

sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager
sudo nix-channel --update

As a NixOs Module

In /etc/nixos/configuration.nix

imports = [<home-manager/nixos>];
home-manager.users.user = { pkgs, ... }: {
    home.packages = [ pkgs.sl ];
    home.stateVersion = "23.11";
};

Standalone

nix-shell '<home-manager>' -A install

Apply changes on homemanager (standalone)

home-manager switch

Remove a channel

sudo nix-channel --remove home-manager

Flakes

Installation:

Add following to /etc/nixos/configuration.nix

nix = {
  package = pkgs.nixFlakes;
  extraOptions = "experimental-features = nix-command flakes";
};

Generate flake.nix

cd ~
mkdir flake
cd flake
nix flake init

Build it

sudo nixos-rebuild switch --flake .#