diff --git a/README.md b/README.md index 50805ad..a5065e4 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,46 @@ Work-in-progress NixOS Server Infrastructure based on [valerie's NixOS setup](ht ## WARNING This is a work-in-progress and currently DOES NOT WORK. Please check back later. + +## Setup + +### Bootstrapping a New Device + +This guide assumes you have a somewhat sane sops setup. + +1. First, boot the NixOS live environment (minimal ISO is recommended). +2. Then, get the harddrive ID using `lsblk` or `fdisk -l`: + + ```bash + sudo fdisk -l + ls -lah /dev/disk/by-id | grep -i + ``` + + Example output: + + ```bash + [nix-shell:~]$ sudo fdisk -l + Disk /dev/loop0: 1.14 GiB, 1221455872 bytes, 2385656 sectors + Units: sectors of 1 * 512 = 512 bytes + Sector size (logical/physical): 512 bytes / 512 bytes + I/O size (minimum/optimal): 512 bytes / 512 bytes + + + Disk /dev/sda: 256 GiB, 274877906944 bytes, 536870912 sectors + Disk model: QEMU HARDDISK + Units: sectors of 1 * 512 = 512 bytes + Sector size (logical/physical): 512 bytes / 512 bytes + I/O size (minimum/optimal): 512 bytes / 512 bytes + + [nix-shell:~]$ ls -lah /dev/disk/by-id | grep -i sda + lrwxrwxrwx 1 root root 9 May 5 13:20 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 -> ../../sda + + [nix-shell:~]$ # disk path: /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 + ``` + +3. Manually create a host configuration by modifying/duplicating `hosts/` to `hosts/`. Be sure to modify the hostname in `hosts//configuration.nix`. +4. Add the host to `flake.nix`. +5. Modify the disko configuration for our host to use the correct disk ID that we found earlier. +6. Make any other additional modifications if needed. +7. Copy/clone the configuration over to the host to install. +8. Run `sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount -f "$PWD#hostname"` to prepare the disk, replacing `hostname` with the host you want to switch to (ex. `andromeda`). diff --git a/SETUP.md b/SETUP.md index 64c8ed6..8b13789 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,38 +1 @@ -# Bootstrapping a New Device -This guide assumes you have a somewhat sane sops setup. - -1. First, boot the NixOS live environment (minimal ISO is recommended). -2. Then, get the harddrive ID using `lsblk` or `fdisk -l`: - - ```bash - sudo fdisk -l - ls -lah /dev/disk/by-id | grep -i - ``` - -Example output: - - ```bash - [nix-shell:~]$ sudo fdisk -l - Disk /dev/loop0: 1.14 GiB, 1221455872 bytes, 2385656 sectors - Units: sectors of 1 * 512 = 512 bytes - Sector size (logical/physical): 512 bytes / 512 bytes - I/O size (minimum/optimal): 512 bytes / 512 bytes - - - Disk /dev/sda: 256 GiB, 274877906944 bytes, 536870912 sectors - Disk model: QEMU HARDDISK - Units: sectors of 1 * 512 = 512 bytes - Sector size (logical/physical): 512 bytes / 512 bytes - I/O size (minimum/optimal): 512 bytes / 512 bytes - - [nix-shell:~]$ ls -lah /dev/disk/by-id | grep -i sda - lrwxrwxrwx 1 root root 9 May 5 13:20 scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 -> ../../sda - - [nix-shell:~]$ # disk path: /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0 - ``` - -3. Manually create a host configuration by modifying/duplicating `hosts/` to `hosts/`. Be sure to modify the hostname in `hosts//configuration.nix`. -4. Add the host to `flake.nix`. -5. Modify the disko configuration for our host to use the correct disk ID that we found earlier. -6. Make any other additional modifications if needed. diff --git a/flake.nix b/flake.nix index c08d8ad..b93750d 100755 --- a/flake.nix +++ b/flake.nix @@ -39,7 +39,7 @@ system = "x86_64-linux"; modules = [ inputs.disko.nixosModules.default - (import ./hosts/andromeda/disko.nix {device = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0";}) + (import ./system/disko.nix {device = "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0";}) inputs.impermanence.nixosModules.impermanence ./hosts/andromeda/configuration.nix ]; diff --git a/system/disko.nix b/system/disko.nix index 67dca85..225480d 100755 --- a/system/disko.nix +++ b/system/disko.nix @@ -19,23 +19,30 @@ }; rootfs = { size = "100%"; + name = "NixOS"; content = { - "/root" = { - mountpoint = "/"; - # mountOptions = ["compress=zstd" "noatime"]; - }; - "/persist" = { - mountpoint = "/persist"; - # mountOptions = ["compress=zstd" "subvol=persist" "noatime"]; - mountOptions = ["subvol=persist" "noatime"]; - }; - "/home" = { - mountpoint = "/home"; - mountOptions = ["compress=zstd" "subvol=home" "noatime"]; - }; - "/nix" = { - mountpoint = "/nix"; - mountOptions = ["compress=zstd" "subvol=nix" "noatime"]; + type = "btrfs"; + extraArgs = ["-f"]; + subvolumes = { + root = { + name = "root"; + mountpoint = "/"; + }; + persist = { + name = "persist"; + mountpoint = "/persist"; + mountOptions = ["subvol=persist" "noatime"]; + }; + home = { + name = "home"; + mountpoint = "/home"; + mountOptions = ["subvol=home" "noatime"]; + }; + nix = { + name = "nix"; + mountpoint = "/nix"; + mountOptions = ["compress=zstd" "subvol=nix" "noatime"]; + }; }; }; };