From 83676fceda000156656ddee0561001090334ec37 Mon Sep 17 00:00:00 2001 From: Baitinq <30861839+Baitinq@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:41:36 +0200 Subject: Luna: Implement* disko for declarative partition configuration --- hosts/luna/disks.nix | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) (limited to 'hosts/luna/disks.nix') diff --git a/hosts/luna/disks.nix b/hosts/luna/disks.nix index 753711c..d9a5846 100644 --- a/hosts/luna/disks.nix +++ b/hosts/luna/disks.nix @@ -1,4 +1,106 @@ -{ config, lib, inputs, pkgs, modulesPath, ... }: +{ inputs, pkgs, ... }: +let + partitionsConfig = { + type = "devices"; + content = { + "disk/by-path/platform-80860F14:00" = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + part-type = "ESP"; + label = "efi"; + start = "0"; + end = "64M"; + fs-type = "fat32"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot/esp"; + }; + } + { + type = "partition"; + start = "64M"; + end = "264M"; + part-type = "primary"; + label = "boot"; + content = { + type = "luks"; + name = "encrypted_boot"; + extraArgs = [ "--type luks1" ]; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/boot"; + }; + }; + } + { + type = "partition"; + start = "264M"; + end = "100%"; + part-type = "primary"; + label = "nix"; + content = { + type = "luks"; + name = "encrypted_nix"; + extraArgs = [ "--type luks2" ]; + content = { + type = "filesystem"; + format = "btrfs"; + mountpoint = "/nix"; + }; + }; + } + ]; + }; + "disk/by-path/pci-0000:00:14.0-usb-0:2.3:1.0-scsi-0:0:0:0" = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + part-type = "primary"; + label = "home_and_persist"; + start = "0"; + end = "100%"; + content = { + type = "luks"; + name = "encrypted_home_and_persist"; + extraArgs = [ "--type luks2" ]; + content = { + type = "lvm"; + name = "pool"; + lvs = { + _persist = { + type = "lv"; + size = "4G"; + content = { + type = "filesystem"; + format = "btrfs"; + mountpoint = "/persist"; + }; + }; + home = { + type = "lv"; + size = "100%FREE"; + content = { + type = "filesystem"; + format = "btrfs"; + mountpoint = "/home"; + }; + }; + }; + }; + }; + } + ]; + }; + }; + }; +in { fileSystems."/" = { device = "none"; @@ -50,4 +152,10 @@ zramSwap.enable = true; + + environment.systemPackages = with pkgs;[ + parted + (pkgs.writeScriptBin "disko-create" (inputs.disko.lib.create partitionsConfig)) + (pkgs.writeScriptBin "disko-mount" (inputs.disko.lib.mount partitionsConfig)) + ]; } -- cgit 1.4.1