mirror of
https://gitlab.com/ahoneybun/nyxi-installer.git
synced 2025-05-12 11:04:02 -06:00
working logic with nvme
This commit is contained in:
parent
d886565041
commit
74d52c4d07
1 changed files with 55 additions and 45 deletions
100
src/main.rs
100
src/main.rs
|
@ -54,21 +54,61 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn format_partitions() {
|
fn format_partitions(drive_name: &str) {
|
||||||
|
let efi_number = "p1";
|
||||||
|
let root_number = "p2";
|
||||||
|
let efi_path = format!("{}p1", drive_name);
|
||||||
|
let root_path = format!("{}p2", drive_name);
|
||||||
|
|
||||||
let _efi_partition = Command::new("mkfs.fat")
|
let _efi_partition = Command::new("mkfs.fat")
|
||||||
.arg("-F32")
|
.arg("-F32")
|
||||||
.arg("-n")
|
.arg("-n")
|
||||||
.arg("EFI")
|
.arg("EFI")
|
||||||
// Replace with non static variable
|
.arg(&efi_path)
|
||||||
.arg("/dev/nvme1n1p1")
|
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to partition boot partition as FAT32");
|
.expect("Failed to format boot partition as FAT32");
|
||||||
|
|
||||||
let _root_partition = Command::new("mkfs.ext4")
|
let _root_partition = Command::new("mkfs.ext4")
|
||||||
// Replace with non static variable
|
.arg(&root_path)
|
||||||
.arg("/dev/nvme1n1p2")
|
|
||||||
.output()
|
.output()
|
||||||
.expect("Failed to partition root partition as ext4");
|
.expect("Failed to format root partition as ext4");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_partitions(drive_name: &str) {
|
||||||
|
let efi_path = format!("{}p1", drive_name);
|
||||||
|
let root_path = format!("{}p2", drive_name);
|
||||||
|
|
||||||
|
let root_source = Some(Path::new(&root_path));
|
||||||
|
let root_target = Path::new("/mnt");
|
||||||
|
|
||||||
|
mount(
|
||||||
|
root_source,
|
||||||
|
root_target,
|
||||||
|
Some("ext4"),
|
||||||
|
MsFlags::empty(),
|
||||||
|
None::<&[u8]>,
|
||||||
|
)
|
||||||
|
.expect("Failed to mount root partition");
|
||||||
|
|
||||||
|
// Creates the boot directory in /mnt/boot
|
||||||
|
let _create_boot_directory = Command::new("mkdir")
|
||||||
|
.arg("-p")
|
||||||
|
.arg("/mnt/boot")
|
||||||
|
.output()
|
||||||
|
.expect("Failed to create boot directory");
|
||||||
|
|
||||||
|
// replace static path with a variable
|
||||||
|
let boot_source = Some(Path::new(&efi_path));
|
||||||
|
let boot_target = Path::new("/mnt/boot");
|
||||||
|
|
||||||
|
mount(
|
||||||
|
boot_source,
|
||||||
|
boot_target,
|
||||||
|
Some("vfat"),
|
||||||
|
MsFlags::empty(),
|
||||||
|
None::<&[u8]>,
|
||||||
|
)
|
||||||
|
.expect("Failed to mount boot partition");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn grab_flake() {
|
fn grab_flake() {
|
||||||
|
@ -167,52 +207,22 @@ fn main() {
|
||||||
|
|
||||||
let drive_name = drive_name.trim();
|
let drive_name = drive_name.trim();
|
||||||
|
|
||||||
// Partitioning the selected drive
|
|
||||||
let _ = format_drive(drive_name);
|
|
||||||
|
|
||||||
// Formatting the partitions
|
|
||||||
format_partitions();
|
|
||||||
|
|
||||||
// Download nix files
|
// Download nix files
|
||||||
grab_flake();
|
grab_flake();
|
||||||
grab_config();
|
grab_config();
|
||||||
grab_home();
|
grab_home();
|
||||||
grab_gnome();
|
grab_gnome();
|
||||||
|
|
||||||
|
// Partitioning the selected drive
|
||||||
|
let _ = format_drive(drive_name);
|
||||||
|
|
||||||
|
// Formatting the partitions
|
||||||
|
format_partitions(drive_name);
|
||||||
|
|
||||||
// Mounting the partitions
|
// Mounting the partitions
|
||||||
// replace static path with a variable
|
mount_partitions(drive_name);
|
||||||
let root_source = Some(Path::new("/dev/nvme1n1p2"));
|
|
||||||
let root_target = Path::new("/mnt");
|
|
||||||
|
|
||||||
mount(
|
|
||||||
root_source,
|
|
||||||
root_target,
|
|
||||||
Some("ext4"),
|
|
||||||
MsFlags::empty(),
|
|
||||||
None::<&[u8]>,
|
|
||||||
)
|
|
||||||
.expect("Failed to mount root partition");
|
|
||||||
|
|
||||||
// Creates the boot directory in /mnt/boot
|
|
||||||
let _create_boot_directory = Command::new("mkdir")
|
|
||||||
.arg("-p")
|
|
||||||
.arg("/mnt/boot")
|
|
||||||
.output()
|
|
||||||
.expect("Failed to create boot directory");
|
|
||||||
|
|
||||||
// replace static path with a variable
|
|
||||||
let boot_source = Some(Path::new("/dev/nvme1n1p1"));
|
|
||||||
let boot_target = Path::new("/mnt/boot");
|
|
||||||
|
|
||||||
mount(
|
|
||||||
boot_source,
|
|
||||||
boot_target,
|
|
||||||
Some("vfat"),
|
|
||||||
MsFlags::empty(),
|
|
||||||
None::<&[u8]>,
|
|
||||||
)
|
|
||||||
.expect("Failed to mount boot partition");
|
|
||||||
|
|
||||||
|
// Creates the init nix config in /mnt/etc/nixos
|
||||||
let _nixos_gen_config = Command::new("nixos-generate-config")
|
let _nixos_gen_config = Command::new("nixos-generate-config")
|
||||||
.arg("--root")
|
.arg("--root")
|
||||||
.arg("/mnt")
|
.arg("/mnt")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue