From 616b1154a49fe915718df315fae140664249aaff Mon Sep 17 00:00:00 2001 From: Kabbone Date: Wed, 20 Dec 2023 11:27:50 +0100 Subject: [PATCH] disko: add initial config --- README.md | 30 +++++++++++++++++- disko/README.md | 27 +++++++++++++++++ disko/btrfs.nix | 71 +++++++++++++++++++++++++++++++++++++++++++ disko/btrfs_luks.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 disko/README.md create mode 100644 disko/btrfs.nix create mode 100644 disko/btrfs_luks.nix diff --git a/README.md b/README.md index 84fafb0..50f9b14 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ -# nixos-config +# nixos-config # +## Install ## + +### Patitioning ### + +- Easiest is to run [disko](https://git.kabtop.de/Kabbone/nixos-config/raw/branch/main/disko/README.md) +- `Classic way:` +Partition disk with gdisk: +1. EFI Partition, size 512M, type "EF00", Label "NIXBOOT" + +2. Root Partition, size 100%, type "8300", Label "NIXROOT" + +### Installing ### + +1. mount all the partitions and subvolumes to /mnt + +2. generate initial nixos config +```# nixos-generate-config --root /mnt``` + +3. clone flake and check config +``` +# cd /mnt/etc/nixos/ +# git clone https://git.kabtop.de/Kabbone/nixos-config.git +``` + +4. install system +```# nixos-install --flake .#``` + +5. reboot diff --git a/disko/README.md b/disko/README.md new file mode 100644 index 0000000..61cbe3a --- /dev/null +++ b/disko/README.md @@ -0,0 +1,27 @@ +##Step by step## +1. Boot the [installer](https://nixos.org/download.html#nixos-iso) + +2. Get disk name +```$ lsblk``` + +3. Get disko config +``` +$ curl https://git.kabtop.de/Kabbone/nixos-config/raw/branch/main/disko/btrfs_luks.nix -o /tmp/disko-config.nix +``` + +4. Adjust device name + +5. Let disko partition the disk +``` +$ sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode disko /tmp/disko-config.nix +``` + +6. Check if it got mounted +```$ mount | grep /mnt``` + +7. Continue with NixOS installation +Filesystem definitions come from disko, hence "--no-filesystems" +`Alternative:` continue with normal hardware-config +``` +$ nixos-generate-config --no-filesystems --root /mnt +$ mv /tmp/disko-config.nix /mnt/etc/nixos diff --git a/disko/btrfs.nix b/disko/btrfs.nix new file mode 100644 index 0000000..4dbc90a --- /dev/null +++ b/disko/btrfs.nix @@ -0,0 +1,71 @@ +{ + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + name = "NIXBOOT"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + ]; + }; + }; + root = { + size = "100%"; + content = { + type = "btrfs"; + name = "NIXROOT"; + # disable settings.keyFile if you want to use interactive password entry + #passwordFile = "/tmp/secret.key"; # Interactive + settings = { + allowDiscards = true; + #keyFile = "/tmp/secret.key"; + }; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "@" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@srv" = { + mountpoint = "/srv"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@var" = { + mountpoint = "/var"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@swap" = { + mountpoint = "/swap"; + swap.swapfile.size = "8G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/disko/btrfs_luks.nix b/disko/btrfs_luks.nix new file mode 100644 index 0000000..13c04e3 --- /dev/null +++ b/disko/btrfs_luks.nix @@ -0,0 +1,72 @@ +{ + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + name = "NIXBOOT"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + askPassword = true; + # disable settings.keyFile if you want to use interactive password entry + #passwordFile = "/tmp/secret.key"; # Interactive + settings = { + allowDiscards = true; + }; + content = { + type = "btrfs"; + name = "NIXROOT"; + extraArgs = [ "-f" ]; + subvolumes = { + "@" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@srv" = { + mountpoint = "/srv"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@var" = { + mountpoint = "/var"; + mountOptions = [ "compress=zstd" "noatime" "ssd" "discard=async" ]; + }; + "@swap" = { + mountpoint = "/swap"; + swap.swapfile.size = "8G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +}