about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--flake.lock37
-rw-r--r--flake.nix2
-rw-r--r--hosts/luna/disks.nix110
3 files changed, 147 insertions, 2 deletions
diff --git a/flake.lock b/flake.lock
index ad27cc3..e911f05 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,23 @@
 {
   "nodes": {
+    "disko": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      },
+      "locked": {
+        "lastModified": 1661279986,
+        "narHash": "sha256-qcaYzA2nPJEw33bmgEfnT0UYADS6wEtw3D2wIfmPJmc=",
+        "owner": "nix-community",
+        "repo": "disko",
+        "rev": "9bca66ca7d2f8c9ac39d1f4a067ae45e681b87f9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "disko",
+        "type": "github"
+      }
+    },
     "home-manager": {
       "inputs": {
         "nixpkgs": [
@@ -54,6 +72,22 @@
     },
     "nixpkgs": {
       "locked": {
+        "lastModified": 1660646295,
+        "narHash": "sha256-V4G+egGRc3elXPTr7QLJ7r7yrYed0areIKDiIAlMLC8=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "762b003329510ea855b4097a37511eb19c7077f0",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs_2": {
+      "locked": {
         "lastModified": 1659522808,
         "narHash": "sha256-HBcM19nGhI3IWwPNVlYb0MZ8VW6iKp4JbAVkeIHVykc=",
         "owner": "nixos",
@@ -85,10 +119,11 @@
     },
     "root": {
       "inputs": {
+        "disko": "disko",
         "home-manager": "home-manager",
         "impermanence": "impermanence",
         "nix-index": "nix-index",
-        "nixpkgs": "nixpkgs",
+        "nixpkgs": "nixpkgs_2",
         "nur": "nur",
         "wallpapers": "wallpapers"
       }
diff --git a/flake.nix b/flake.nix
index 902324e..24618c7 100644
--- a/flake.nix
+++ b/flake.nix
@@ -11,6 +11,8 @@
 
     impermanence.url = "github:nix-community/impermanence";
 
+    disko.url = "github:nix-community/disko";
+
     nur.url = "github:nix-community/NUR";
 
     nix-index.url = "github:Mic92/nix-index-database";
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))
+  ];
 }