add Command for testing and testing for a flash drive

This commit is contained in:
Aaron Honeycutt 2025-04-09 20:22:29 -06:00
parent ea7303c2ee
commit 8ddbfe05d8
3 changed files with 139 additions and 4 deletions

View file

@ -1,6 +1,7 @@
use std::io;
use std::io::{stdout, Write};
use std::fs::File;
use std::process::Command;
use sys_metrics::disks;
use rsfdisk::fdisk::Fdisk;
use rsfdisk::core::partition_table::PartitionTableKind;
@ -33,7 +34,10 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
let root = Partition::builder()
.partition_type(partition_type)
.name("Root")
.size_in_sectors(499_033_071_616)
// 132,120,576 sectors for a 64GB flash drive
.size_in_sectors(132_120_576)
// 500GB
//.size_in_sectors(499_033_071_61)
.build()?;
let _ = disk.partition_add(root)?;
@ -45,6 +49,29 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
fn mount_parts() {}
// fn grab_configs() {
// let mut flakeConfig = Easy::new();
// let mut mainConfig = Easy::new();
// let mut homeConfig = Easy::new();
// flakeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap();
// mainConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix").unwrap();
// homeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix").unwrap();
// let mut flakeFile = File::create("flake.nix").unwrap();
// let mut mainFile = File::create("configuration.nix").unwrap();
// let mut homeFile = File::create("home.nix").unwrap();
// {
// let mut flakeTransfer = easy.transfer();
// transfer.write_function(|data| {
// flakeFile.write_all(data).unwrap();
// Ok(data.len())
// }).unwrap();
// transfer.perform().unwrap();
// }
// }
fn grab_flake() {
let mut easy = Easy::new();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap();
@ -93,6 +120,15 @@ fn grab_home() {
}
}
fn nix_gen() {
let output = Command::new("nixos-generate-config")
.arg("no-file-systems")
.arg("--root")
.arg("/mnt")
.output()
.expect("Failed to execute command");
}
fn main() {
println!("--------------------------------------");
println!("| Welcome to the Nyxi Installer 2.0! |");
@ -129,9 +165,12 @@ fn main() {
// Partitioning the selected drive
format_drive(drive_name);
// placeholder for nix-generate-config
// Download nix files
grab_flake();
grab_config();
grab_home();
nix_gen();
}