diff --git a/Cargo.lock b/Cargo.lock index 5a5e4e6..0089cb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,12 +70,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - [[package]] name = "clang-sys" version = "1.8.1" @@ -93,36 +87,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "curl" -version = "0.4.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9fb4d13a1be2b58f14d60adba57c9834b78c62fd86c3e76a148f732686e9265" -dependencies = [ - "curl-sys", - "libc", - "openssl-probe", - "openssl-sys", - "schannel", - "socket2", - "windows-sys 0.52.0", -] - -[[package]] -name = "curl-sys" -version = "0.4.80+curl-8.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f7df2eac63200c3ab25bde3b2268ef2ee56af3d238e76d61f01c3c49bff734" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", - "windows-sys 0.52.0", -] - [[package]] name = "either" version = "1.15.0" @@ -174,7 +138,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -195,7 +159,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -246,18 +210,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "libz-sys" -version = "1.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -300,18 +252,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "nix" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" -dependencies = [ - "bitflags", - "cfg-if", - "cfg_aliases", - "libc", -] - [[package]] name = "nom" version = "7.1.3" @@ -347,8 +287,6 @@ dependencies = [ name = "nyxi-installer" version = "2.0.0" dependencies = [ - "curl", - "nix", "rsfdisk", "sys_metrics", ] @@ -359,24 +297,6 @@ version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" -[[package]] -name = "openssl-probe" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" - -[[package]] -name = "openssl-sys" -version = "0.9.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -500,16 +420,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", -] - -[[package]] -name = "schannel" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" -dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -538,16 +449,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "socket2" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "syn" version = "1.0.109" @@ -648,12 +549,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "which" version = "4.4.2" @@ -666,15 +561,6 @@ dependencies = [ "rustix", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.59.0" diff --git a/Cargo.toml b/Cargo.toml index 05bc2ba..6017b19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,5 @@ version = "2.0.0" edition = "2021" [dependencies] -curl = "0.4.47" -nix = "0.29.0" rsfdisk = "0.1.0" sys_metrics = "0.2.7" diff --git a/shell.nix b/shell.nix index 7f9e443..826e6ba 100644 --- a/shell.nix +++ b/shell.nix @@ -13,9 +13,6 @@ llvmPackages.clang # System - btrfs-progs - e2fsprogs - openssl pkg-config util-linux ]; @@ -24,6 +21,6 @@ export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" export RUST_BACKTRACE=1 - echo "We're ready to make some Rust!" + echo "Ready to make some rust!" ''; } diff --git a/src/main.rs b/src/main.rs index 9f4970d..e6674ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,9 @@ 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; use rsfdisk::core::partition::{Guid, Partition, PartitionKind, PartitionList}; -use curl::easy::Easy; - fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let mut disk = Fdisk::builder() .assign_device(drive_name) @@ -34,11 +29,9 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let root = Partition::builder() .partition_type(partition_type) .name("Root") - .size_in_sectors(121_634_816) - // 500GB - //.size_in_sectors(499_033_071_61) + .size_in_sectors(499_033_071_616) .build()?; - + let _ = disk.partition_add(root)?; disk.partition_table_write_to_disk()?; @@ -46,64 +39,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { Ok(()) } -fn mount_parts() {} - -fn grab_flake() { - let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); - - let mut file = File::create("flake.nix").unwrap(); - - { - let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); - transfer.perform().unwrap(); - } -} - -fn grab_config() { - let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix").unwrap(); - - let mut file = File::create("configuration.nix").unwrap(); - - { - let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); - transfer.perform().unwrap(); - } -} - -fn grab_home() { - let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix").unwrap(); - - let mut file = File::create("home.nix").unwrap(); - - { - let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); - transfer.perform().unwrap(); - } +fn mount_parts() { + } fn main() { - println!("--------------------------------------"); - println!("| Welcome to the Nyxi Installer 2.0! |"); - println!("--------------------------------------"); - println!(""); - println!("Availble disks for installation:"); - println!("---------------------------------"); println!(""); match disks::get_physical_ioblocks() { @@ -116,7 +57,7 @@ fn main() { } let mut drive_name = String::new(); - + println!(""); println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda"); println!("Which drive do we want to use for this installation?: {}", drive_name); @@ -124,81 +65,12 @@ fn main() { io::stdin() .read_line(&mut drive_name) .expect("Failed to read line"); - + let drive_name = drive_name.trim(); + // let deposit_number: f64 = deposit_amount.parse().expect("Input not an integer"); + // Partitioning the selected drive format_drive(drive_name); - // Formatting the partitions - let efi_partition = Command::new("mkfs.fat") - .arg("-F32") - .arg("-n") - .arg("EFI") - .arg("/dev/sda1") - .output() - .expect("Failed to partition boot partition as FAT32"); - - let root_partition = Command::new("mkfs.ext4") - .arg("/dev/sda2") - .output() - .expect("Failed to partition root partition as ext4"); - - // Download nix files - grab_flake(); - grab_config(); - grab_home(); - - let nixos_gen_config = Command::new("nixos-generate-config") - .arg("no-file-systems") - .arg("--root") - .arg("/mnt") - .output() - .expect("Failed to execute command"); - - // Host selection - loop { - println!(""); - println!("Host selection"); - println!("1. Lemur Pro 13 (Garrus)"); - println!("2. Device 2"); - println!("3. Quit"); - println!(""); - - println!("Enter your host for installation:"); - - let mut choice = String::new(); - io::stdin().read_line(&mut choice).unwrap(); - - 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 configFile = File::create("configuration.nix").unwrap(); - - { - let mut transfer = garrusConfig.transfer(); - transfer.write_function(|data| { - configFile.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); - transfer.perform().unwrap(); - } - break - } - "2" => { - let nixos_install = Command::new("nixos-install") - .arg("--flake") - .arg("/mnt/etc/nixos#garrus") - .output() - .expect("Fiale to execute command"); - }, - "3" => { - println!("Goodbye!"); - break; - }, - _ => println!("Invalid choice, try again."), - } - } }