From efb80cacea044976bbecddce44e6129fe0bb0bf9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 09:47:33 -0600 Subject: [PATCH 1/3] correct partition type for EFI --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9f4970d..8dae014 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let partition_type = PartitionKind::builder() - .guid(Guid::LinuxRootx86_64) + let boot_part_type = PartitionKind::builder() + .guid(Guid::EfiSystem) .build()?; let boot = Partition::builder() - .partition_type(partition_type.clone()) + .boot_part_type(partition_type.clone()) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -31,8 +31,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; + let root_part_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) + .build()?; + let root = Partition::builder() - .partition_type(partition_type) + .root_part_type(partition_type) .name("Root") .size_in_sectors(121_634_816) // 500GB From e3e65277012effb88afa84d48d0364d650d0c2d9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 14:52:05 -0600 Subject: [PATCH 2/3] Revert "correct partition type for EFI" This reverts commit efb80cacea044976bbecddce44e6129fe0bb0bf9 --- src/main.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8dae014..9f4970d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let boot_part_type = PartitionKind::builder() - .guid(Guid::EfiSystem) + let partition_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) .build()?; let boot = Partition::builder() - .boot_part_type(partition_type.clone()) + .partition_type(partition_type.clone()) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -31,12 +31,8 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; - let root_part_type = PartitionKind::builder() - .guid(Guid::LinuxRootx86_64) - .build()?; - let root = Partition::builder() - .root_part_type(partition_type) + .partition_type(partition_type) .name("Root") .size_in_sectors(121_634_816) // 500GB From 4e567a79b00e748d5ec9232723c78bc33ab66a71 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 15:22:45 -0600 Subject: [PATCH 3/3] clean up cargo warning/info messages --- src/main.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9f4970d..ae63a5b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use std::io; -use std::io::{stdout, Write}; +use std::io::Write; use std::fs::File; use std::process::Command; use sys_metrics::disks; use rsfdisk::fdisk::Fdisk; use rsfdisk::core::partition_table::PartitionTableKind; -use rsfdisk::core::partition::{Guid, Partition, PartitionKind, PartitionList}; +use rsfdisk::core::partition::{Guid, Partition, PartitionKind}; use curl::easy::Easy; @@ -46,7 +46,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { Ok(()) } -fn mount_parts() {} +// fn mount_parts() {} fn grab_flake() { let mut easy = Easy::new(); @@ -128,10 +128,10 @@ fn main() { let drive_name = drive_name.trim(); // Partitioning the selected drive - format_drive(drive_name); + let _ = format_drive(drive_name); // Formatting the partitions - let efi_partition = Command::new("mkfs.fat") + let _efi_partition = Command::new("mkfs.fat") .arg("-F32") .arg("-n") .arg("EFI") @@ -139,7 +139,7 @@ fn main() { .output() .expect("Failed to partition boot partition as FAT32"); - let root_partition = Command::new("mkfs.ext4") + let _root_partition = Command::new("mkfs.ext4") .arg("/dev/sda2") .output() .expect("Failed to partition root partition as ext4"); @@ -149,7 +149,7 @@ fn main() { grab_config(); grab_home(); - let nixos_gen_config = Command::new("nixos-generate-config") + let _nixos_gen_config = Command::new("nixos-generate-config") .arg("no-file-systems") .arg("--root") .arg("/mnt") @@ -172,15 +172,15 @@ fn main() { match choice.trim() { "1" => { - let mut garrusConfig = Easy::new(); - garrusConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix").unwrap(); + let mut garrus_config = Easy::new(); + garrus_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix").unwrap(); - let mut configFile = File::create("configuration.nix").unwrap(); + let mut config_file = File::create("configuration.nix").unwrap(); { - let mut transfer = garrusConfig.transfer(); + let mut transfer = garrus_config.transfer(); transfer.write_function(|data| { - configFile.write_all(data).unwrap(); + config_file.write_all(data).unwrap(); Ok(data.len()) }).unwrap(); transfer.perform().unwrap(); @@ -188,7 +188,7 @@ fn main() { break } "2" => { - let nixos_install = Command::new("nixos-install") + let _nixos_install = Command::new("nixos-install") .arg("--flake") .arg("/mnt/etc/nixos#garrus") .output() @@ -201,4 +201,4 @@ fn main() { _ => println!("Invalid choice, try again."), } } -} +} \ No newline at end of file