about summary refs log tree commit diff
path: root/hosts/luna
diff options
context:
space:
mode:
authorBaitinq <30861839+Baitinq@users.noreply.github.com>2022-08-24 16:41:36 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2022-08-24 16:42:25 +0200
commit83676fceda000156656ddee0561001090334ec37 (patch)
treee791d6a53250adfc079df8b0c0b01f71989e6988 /hosts/luna
parentGrub: Install as removable (diff)
downloadnixos-config-83676fceda000156656ddee0561001090334ec37.tar.gz
nixos-config-83676fceda000156656ddee0561001090334ec37.tar.bz2
nixos-config-83676fceda000156656ddee0561001090334ec37.zip
Luna: Implement* disko for declarative partition configuration
Diffstat (limited to 'hosts/luna')
-rw-r--r--hosts/luna/disks.nix110
1 files changed, 109 insertions, 1 deletions
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))
+  ];
 }