Compare commits

...

12 commits

Author SHA1 Message Date
Aaron Honeycutt
0c4f154325 add btrfs support to shell 2025-04-09 21:14:25 -06:00
Aaron Honeycutt
2679312b9f partitioning is working 2025-04-09 21:13:42 -06:00
Aaron Honeycutt
ea97e91116 fix names 2025-04-09 21:08:33 -06:00
Aaron Honeycutt
7d472cee71 add nix crate 2025-04-09 20:54:48 -06:00
Aaron Honeycutt
4121a00eea add code for nixos-install (untested) 2025-04-09 20:53:19 -06:00
Aaron Honeycutt
df9d271f42 correct flash drive size 2025-04-09 20:50:45 -06:00
Aaron Honeycutt
e47764618a add garrus to the host menu 2025-04-09 20:42:49 -06:00
Aaron Honeycutt
8b16d6c481 clean up incorrect code 2025-04-09 20:31:54 -06:00
Aaron Honeycutt
6efe2ba259 add host selection menu 2025-04-09 20:30:35 -06:00
Aaron Honeycutt
8ddbfe05d8 add Command for testing and testing for a flash drive 2025-04-09 20:22:29 -06:00
Aaron Honeycutt
ea7303c2ee update shell file and code for curl 2025-04-09 19:55:19 -06:00
Aaron Honeycutt
382e4e3f06 add nix-shell for development 2025-04-09 19:16:05 -06:00
4 changed files with 259 additions and 12 deletions

120
Cargo.lock generated
View file

@ -70,6 +70,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]] [[package]]
name = "clang-sys" name = "clang-sys"
version = "1.8.1" version = "1.8.1"
@ -87,6 +93,36 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" 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]] [[package]]
name = "either" name = "either"
version = "1.15.0" version = "1.15.0"
@ -138,7 +174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -159,7 +195,7 @@ version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf"
dependencies = [ dependencies = [
"windows-sys", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -210,6 +246,18 @@ dependencies = [
"windows-targets", "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]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.15" version = "0.4.15"
@ -252,6 +300,18 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 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]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -287,6 +347,8 @@ dependencies = [
name = "nyxi-installer" name = "nyxi-installer"
version = "2.0.0" version = "2.0.0"
dependencies = [ dependencies = [
"curl",
"nix",
"rsfdisk", "rsfdisk",
"sys_metrics", "sys_metrics",
] ]
@ -297,6 +359,24 @@ version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" 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]] [[package]]
name = "peeking_take_while" name = "peeking_take_while"
version = "0.1.2" version = "0.1.2"
@ -420,7 +500,16 @@ dependencies = [
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"windows-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",
] ]
[[package]] [[package]]
@ -449,6 +538,16 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 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]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"
@ -549,6 +648,12 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "which" name = "which"
version = "4.4.2" version = "4.4.2"
@ -561,6 +666,15 @@ dependencies = [
"rustix", "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]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.59.0" version = "0.59.0"

View file

@ -4,5 +4,7 @@ version = "2.0.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
curl = "0.4.47"
nix = "0.29.0"
rsfdisk = "0.1.0" rsfdisk = "0.1.0"
sys_metrics = "0.2.7" sys_metrics = "0.2.7"

View file

@ -13,6 +13,9 @@
llvmPackages.clang llvmPackages.clang
# System # System
btrfs-progs
e2fsprogs
openssl
pkg-config pkg-config
util-linux util-linux
]; ];
@ -21,6 +24,6 @@
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang"
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
echo "Ready to make some rust!" echo "We're ready to make some Rust!"
''; '';
} }

View file

@ -1,9 +1,14 @@
use std::io; use std::io;
use std::io::{stdout, Write};
use std::fs::File;
use std::process::Command;
use sys_metrics::disks; use sys_metrics::disks;
use rsfdisk::fdisk::Fdisk; use rsfdisk::fdisk::Fdisk;
use rsfdisk::core::partition_table::PartitionTableKind; use rsfdisk::core::partition_table::PartitionTableKind;
use rsfdisk::core::partition::{Guid, Partition, PartitionKind, PartitionList}; use rsfdisk::core::partition::{Guid, Partition, PartitionKind, PartitionList};
use curl::easy::Easy;
fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
let mut disk = Fdisk::builder() let mut disk = Fdisk::builder()
.assign_device(drive_name) .assign_device(drive_name)
@ -29,9 +34,11 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
let root = Partition::builder() let root = Partition::builder()
.partition_type(partition_type) .partition_type(partition_type)
.name("Root") .name("Root")
.size_in_sectors(499_033_071_616) .size_in_sectors(121_634_816)
// 500GB
//.size_in_sectors(499_033_071_61)
.build()?; .build()?;
let _ = disk.partition_add(root)?; let _ = disk.partition_add(root)?;
disk.partition_table_write_to_disk()?; disk.partition_table_write_to_disk()?;
@ -39,12 +46,64 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
Ok(()) Ok(())
} }
fn mount_parts() { 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 main() { fn main() {
println!("--------------------------------------");
println!("| Welcome to the Nyxi Installer 2.0! |");
println!("--------------------------------------");
println!("");
println!("Availble disks for installation:"); println!("Availble disks for installation:");
println!("---------------------------------");
println!(""); println!("");
match disks::get_physical_ioblocks() { match disks::get_physical_ioblocks() {
@ -57,7 +116,7 @@ fn main() {
} }
let mut drive_name = String::new(); let mut drive_name = String::new();
println!(""); println!("");
println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda"); 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); println!("Which drive do we want to use for this installation?: {}", drive_name);
@ -65,12 +124,81 @@ fn main() {
io::stdin() io::stdin()
.read_line(&mut drive_name) .read_line(&mut drive_name)
.expect("Failed to read line"); .expect("Failed to read line");
let drive_name = drive_name.trim();
// let deposit_number: f64 = deposit_amount.parse().expect("Input not an integer"); let drive_name = drive_name.trim();
// Partitioning the selected drive // Partitioning the selected drive
format_drive(drive_name); 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."),
}
}
} }