mirror of
https://gitlab.com/ahoneybun/nyxi-installer.git
synced 2025-05-13 03:23:01 -06:00
Compare commits
No commits in common. "0c4f154325d045919d3cee33abe8226b12a0ec15" and "64ba913d398748e04582c06ba6e435842fa9a969" have entirely different histories.
0c4f154325
...
64ba913d39
4 changed files with 12 additions and 259 deletions
120
Cargo.lock
generated
120
Cargo.lock
generated
|
@ -70,12 +70,6 @@ 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"
|
||||||
|
@ -93,36 +87,6 @@ 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"
|
||||||
|
@ -174,7 +138,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -195,7 +159,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 0.59.0",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -246,18 +210,6 @@ 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"
|
||||||
|
@ -300,18 +252,6 @@ 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"
|
||||||
|
@ -347,8 +287,6 @@ 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",
|
||||||
]
|
]
|
||||||
|
@ -359,24 +297,6 @@ 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"
|
||||||
|
@ -500,16 +420,7 @@ dependencies = [
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys",
|
||||||
]
|
|
||||||
|
|
||||||
[[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]]
|
||||||
|
@ -538,16 +449,6 @@ 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"
|
||||||
|
@ -648,12 +549,6 @@ 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"
|
||||||
|
@ -666,15 +561,6 @@ 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"
|
||||||
|
|
|
@ -4,7 +4,5 @@ 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"
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
llvmPackages.clang
|
llvmPackages.clang
|
||||||
|
|
||||||
# System
|
# System
|
||||||
btrfs-progs
|
|
||||||
e2fsprogs
|
|
||||||
openssl
|
|
||||||
pkg-config
|
pkg-config
|
||||||
util-linux
|
util-linux
|
||||||
];
|
];
|
||||||
|
@ -24,6 +21,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 "We're ready to make some Rust!"
|
echo "Ready to make some rust!"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
136
src/main.rs
136
src/main.rs
|
@ -1,14 +1,9 @@
|
||||||
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)
|
||||||
|
@ -34,9 +29,7 @@ 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(121_634_816)
|
.size_in_sectors(499_033_071_616)
|
||||||
// 500GB
|
|
||||||
//.size_in_sectors(499_033_071_61)
|
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let _ = disk.partition_add(root)?;
|
let _ = disk.partition_add(root)?;
|
||||||
|
@ -46,64 +39,12 @@ 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() {
|
||||||
|
@ -127,78 +68,9 @@ fn main() {
|
||||||
|
|
||||||
let drive_name = drive_name.trim();
|
let drive_name = drive_name.trim();
|
||||||
|
|
||||||
|
// let deposit_number: f64 = deposit_amount.parse().expect("Input not an integer");
|
||||||
|
|
||||||
// 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."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue