Skip to content

Commit

Permalink
feat: support disko for recovery disk
Browse files Browse the repository at this point in the history
  • Loading branch information
misumisumi committed May 12, 2024
1 parent 678a712 commit 883363d
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 47 deletions.
27 changes: 24 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down
3 changes: 2 additions & 1 deletion machines/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let
modules =
[
../modules
inputs.disko.nixosModules.disko
inputs.home-manager.nixosModules.home-manager
inputs.musnix.nixosModules.musnix
inputs.nur.nixosModules.nur
Expand Down Expand Up @@ -54,7 +55,7 @@ in
hostname = "recovery";
user = "nixos";
wm = "gnome";
scheme = "full";
scheme = "small";
};
recovery-cui = settings {
hostname = "recovery";
Expand Down
1 change: 1 addition & 0 deletions machines/recovery/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib, wm, ... }: {
imports =
[
./filesystem.nix
./gpu.nix
./hardware-configuration.nix
./network.nix
Expand Down
104 changes: 104 additions & 0 deletions machines/recovery/filesystem.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{ lib, ... }:
let
device = "/dev/disk/by-id/usb-SAMSUNG_MZALQ128HBHQ_DD56419883ED9-0:0";
in
{
disko.devices = {
disk = {
root = {
inherit device;
type = "disk";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
};
lvm-recovery = {
size = "100%";
type = "8E00";
content = {
type = "lvm_pv";
vg = "lvm-recovery";
};
};
luks-recovery = {
size = "32G";
content = {
type = "luks";
name = "crypted-recovery";
extraOpenArgs = [ ];
settings = {
# if you want to use the key for interactive login be sure there is no trailing newline
# for example use `echo -n "password" > /tmp/secret.key`
keyFile = "/tmp/secrets/luks.key";
allowDiscards = true;
};
# additionalKeyFiles = [ "/tmp/secrets/additionalSecret.key" ];
content = {
type = "lvm_pv";
vg = "secrets-recovery";
};
};
};
};
};
};
};
lvm_vg = {
lvm-recovery = {
type = "lvm_vg";
lvs = {
root = {
size = "4G";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [
"defaults"
];
};
};
nix = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/nix";
};
};
home = {
size = "16G";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/home";
};
};
};
};
secrets-recovery = {
type = "lvm_vg";
lvs = {
secrets = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
};
};
};
};
};
};
}
45 changes: 2 additions & 43 deletions machines/recovery/hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,15 @@
, ...
}: {
imports = [
(modulesPath + "/installer/cd-dvd/installation-cd-minimal.nix")
(modulesPath + "/installer/scan/not-detected.nix")
];

boot = {
initrd = {
availableKernelModules = [ "ahci" "nvme" "xhci_pci" "virtio_pci" "usbhid" "usb_storage" "uas" "sr_mod" "sd_mod" "virtio_blk" ];
availableKernelModules = [ "ahci" "nvme" "xhci_pci" "usbhid" "usb_storage" "uas" "sr_mod" "sd_mod" ];
kernelModules = [ "dm-snapshot" ];
luks.devices = {
luksroot = {
device = "/dev/disk/by-partlabel/GENERALLUKSROOT";
preLVM = true;
allowDiscards = true;
};
};
};
# kernelModules = [ "kvm-amd" "kvm-intel" ];
# extraModulePackages = [ ];
# resumeDevice = "/dev/mapper/VolGroupGeneral-swap";
# kernelParams = [ "resume_offset=resume_size" ];
};

fileSystems = {
"/" = {
label = "general-root";
fsType = "ext4";
};
"/nix" = {
label = "general-nix";
fsType = "ext4";
};
"/var" = {
label = "general-var";
fsType = "ext4";
};
"/home" = {
label = "general-home";
fsType = "ext4";
};
"/boot" = {
label = "ge-boot";
fsType = "vfat";
};
};
swapDevices = [
{
device = "/dev/mapper/VolGroupGeneral-swap";
priority = 10;
}
];

hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
1 change: 1 addition & 0 deletions machines/recovery/network.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
, ...
}: {
networking = {
wireless.enable = false;
hostName = "${hostname}";

networkmanager = {
Expand Down
10 changes: 10 additions & 0 deletions machines/recovery/system.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{ lib, ... }:
{
boot = {
loader.timeout = 10;
supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ];
# Use RAM disk as /tmp
tmp = {
useTmpfs = true;
tmpfsSize = "80%";
};
};
nix = {
# settings = {
# cores = "0";
Expand Down

0 comments on commit 883363d

Please sign in to comment.