Structured documentation

This commit is contained in:
marc
2024-02-10 20:26:01 +01:00
parent d0f78cc24f
commit fa12502c6e
4 changed files with 229 additions and 174 deletions

114
docs/install.org Normal file
View File

@@ -0,0 +1,114 @@
#+title: Installing
* Set up
** If new host, follow [[new_host][Setting up a new host]]
** Open a nix-shell with dependencies
#+BEGIN_SRC bash
nix shell nixpkgs#git
#+END_SRC
** Obtain the flake
+ Via git clone
#+BEGIN_SRC bash
git clone https://git.samfelag.xyz/marc/samfelag.git
#+END_SRC
+ Via scp (in this case, from local to remote)
#+BEGIN_SRC bash
scp samfelag marc@remotehost:samfelag
#+END_SRC
** Copy the host ssh key
Obtain the host ssh *private* key. You can decrypt it using gpg:
#+begin_src bash
gpg -d secrets/ssh-keys/id_<host>.gpg > /etc/ssh/id_<host>
#+end_src
Copy the ssh keys to `/etc/ssh`
* Partition the disk
We'll partition the disk in the follwing way:
+ 512MB at the beginning for the boot partition
+ 8GB at the end for swap
+ The rest (at the middle) for the filesystem (/)
** Locate the disk
#+BEGIN_SRC bash
lsblk
#+END_SRC
** UEFI Boot
1. Create a GPT partition table
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mklabel gpt
#+END_SRC
2. Create the root partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart primary 512MB -8GB
#+END_SRC
3. Create the swap partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart primary linux-swap -8GB 100%
#+END_SRC
4. Create the boot partition
#+BEGIN_SRC bash
sudo parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB
sudo parted /dev/nvme0n1 -- set 3 esp on
#+END_SRC
** MBR boot
1. Create a MBR partition table
#+BEGIN_SRC bash
sudo parted /dev/vda -- mklabel msdos
#+END_SRC
2. Create the root partition
#+BEGIN_SRC bash
sudo parted /dev/vda -- mkpart primary 1MiB -8GiB
#+END_SRC
3. Create the swap partition
#+BEGIN_SRC bash
sudo parted /dev/vda -- mkpart primary linux-swap -8GiB 100%
#+END_SRC
4. Create the boot partition
#+BEGIN_SRC bash
sudo parted /dev/vda -- mkpart ESP fat32 1MB 512MB
sudo parted /dev/vda -- set 3 esp on
#+END_SRC
* Format the partitions
1. Root partition
#+BEGIN_SRC bash
sudo mkfs.ext4 -L nixos /dev/nvme0n1p1
#+END_SRC
2. Swap partition
#+BEGIN_SRC bash
sudo mkswap -L swap /dev/nvme0n1p2
#+END_SRC
3. Boot partition (if UEFI boot)
#+BEGIN_SRC bash
sudo mkfs.fat -F 32 -n BOOT /dev/nvme0n1p3
#+END_SRC
* Mount the filesystems
1. Root partition
#+BEGIN_SRC bash
sudo mount /dev/disk/by-label/nixos /mnt
#+END_SRC
2. Boot partition (if UEFI boot)
#+BEGIN_SRC bash
sudo mkdir -p /mnt/boot
sudo mount /dev/disk/by-label/BOOT /mnt/boot
#+END_SRC
3. Swap partition (if needed)
#+BEGIN_SRC bash
sudo swapon /dev/disk/by-label/swap
#+END_SRC
* Create the host nix configuration
If the host is not present under system/hosts, create a new folder for the host.
Check [[Setting up a new host]] for further documentation.
Generate the hardware configuration file, you can use nixos-generate-config as a base:
#+BEGIN_SRC bash
nixos-generate-config --dir <<host directory>> --no-filesystems
#+END_SRC
* Install nixos!
#+BEGIN_SRC bash
sudo nixos-install --impure --root /mnt --flake '.#reykjavik'
#+END_SRC
* Copy the ssh deploy key (again)
#+begin_src bash
cp /etc/ssh/samfelag_agenix* /mnt/etc/ssh
#+end_src
* Set up the user
You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user:
#+BEGIN_SRC bash
passwd marc
#+END_SRC