mirror of
https://gitlab.com/ahoneybun/nyxi-installer.git
synced 2025-05-12 11:04:02 -06:00
it works! now to clean up
This commit is contained in:
parent
1498465df6
commit
5fe1bc8b44
1 changed files with 66 additions and 77 deletions
143
src/main.rs
143
src/main.rs
|
@ -41,9 +41,9 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
|
|||
.partition_type(partition_type)
|
||||
.name("Root")
|
||||
// Flash drive testing
|
||||
.size_in_sectors(121_634_816)
|
||||
//.size_in_sectors(121_634_816)
|
||||
// Internal drive testing
|
||||
// .size_in_sectors(499_033_071_61)
|
||||
.size_in_sectors(499_033_071_61)
|
||||
// replace static int with a variable
|
||||
.build()?;
|
||||
|
||||
|
@ -59,66 +59,18 @@ fn format_partitions() {
|
|||
.arg("-F32")
|
||||
.arg("-n")
|
||||
.arg("EFI")
|
||||
// replace static path with a variable
|
||||
.arg("/dev/sda1")
|
||||
// Replace with non static variable
|
||||
.arg("/dev/nvme1n1p1")
|
||||
.output()
|
||||
.expect("Failed to partition boot partition as FAT32");
|
||||
|
||||
let _root_partition = Command::new("mkfs.ext4")
|
||||
// replace static path with a variable
|
||||
.arg("/dev/sda2")
|
||||
// Replace with non static variable
|
||||
.arg("/dev/nvme1n1p2")
|
||||
.output()
|
||||
.expect("Failed to partition root partition as ext4");
|
||||
}
|
||||
|
||||
fn mount_root() {
|
||||
// replace static path with a variable
|
||||
let root_source = Some(Path::new("/dev/sda2"));
|
||||
let root_target = Path::new("/mnt");
|
||||
|
||||
mount(
|
||||
root_source,
|
||||
root_target,
|
||||
Some("ext4"),
|
||||
MsFlags::empty(),
|
||||
None::<&[u8]>,
|
||||
)
|
||||
.expect("Failed to mount root partition");
|
||||
|
||||
// Deletes the boot directory
|
||||
// Shouldn't be needed with a blank drive
|
||||
// So just for testing
|
||||
let _delete_boot_directory = Command::new("rm")
|
||||
.arg("-r")
|
||||
.arg("/mnt/boot")
|
||||
.output()
|
||||
.expect("Failed to delete boot directory");
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
fn mount_boot() {
|
||||
// replace static path with a variable
|
||||
let boot_source = Some(Path::new("/dev/sda1"));
|
||||
let boot_target = Path::new("/mnt/boot");
|
||||
|
||||
mount(
|
||||
boot_source,
|
||||
boot_target,
|
||||
Some("vfat"),
|
||||
MsFlags::empty(),
|
||||
None::<&[u8]>,
|
||||
)
|
||||
.expect("Failed to mount boot partition");
|
||||
|
||||
println!("");
|
||||
}
|
||||
|
||||
fn grab_flake() {
|
||||
let mut easy = Easy::new();
|
||||
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/flake.nix").unwrap();
|
||||
|
@ -221,28 +173,66 @@ fn main() {
|
|||
// Formatting the partitions
|
||||
format_partitions();
|
||||
|
||||
// Mounting the partitions
|
||||
// mount_root();
|
||||
// mount_boot();
|
||||
|
||||
let _mount_root = Command::new("mount")
|
||||
.arg("/dev/sda2")
|
||||
.arg("/mnt")
|
||||
.output()
|
||||
.expect("Failed to mount root");
|
||||
|
||||
let _mount_boot = Command::new("mount")
|
||||
.arg("/dev/sda1")
|
||||
.arg("/mnt/boot")
|
||||
.output()
|
||||
.expect("Failed to mount root");
|
||||
|
||||
// Download nix files
|
||||
grab_flake();
|
||||
grab_config();
|
||||
grab_home();
|
||||
grab_gnome();
|
||||
|
||||
// Mounting the partitions
|
||||
// replace static path with a variable
|
||||
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");
|
||||
|
||||
// let _mount_root = Command::new("mount")
|
||||
// // Replace with non static variable
|
||||
// .arg("/dev/nvme1n1p2")
|
||||
// .arg("/mnt")
|
||||
// .output()
|
||||
// .expect("Failed to mount root");
|
||||
|
||||
let _delete_boot_directory = Command::new("rm")
|
||||
.arg("-r")
|
||||
.arg("/mnt/boot")
|
||||
.output()
|
||||
.expect("Failed to delete boot directory");
|
||||
|
||||
// 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");
|
||||
|
||||
// let _mount_boot = Command::new("mount")
|
||||
// // Replace with non static variable
|
||||
// .arg("/dev/nvme1n1p1")
|
||||
// .arg("/mnt/boot")
|
||||
// .output()
|
||||
// .expect("Failed to mount boot");
|
||||
|
||||
let _nixos_gen_config = Command::new("nixos-generate-config")
|
||||
.arg("--root")
|
||||
.arg("/mnt")
|
||||
|
@ -250,11 +240,10 @@ fn main() {
|
|||
.expect("Failed to execute command");
|
||||
|
||||
// Copies the nix files to /mnt/etc/nixos/
|
||||
let _nix_copy = Command::new("mv")
|
||||
.args(["flake.nix", "configration.nix", "home.nix"])
|
||||
.arg("/mnt/etc/nixos")
|
||||
let nix_move = Command::new("mv")
|
||||
.args(["-f", "flake.nix", "configuration.nix", "home.nix", "/mnt/etc/nixos"])
|
||||
.output()
|
||||
.expect("Failed to copy nix files over");
|
||||
.expect("Failed to move nix files over");
|
||||
|
||||
// Host selection
|
||||
loop {
|
||||
|
@ -289,15 +278,15 @@ fn main() {
|
|||
}
|
||||
|
||||
// Copies the system nix files to /mnt/etc/nixos/
|
||||
let _garrus_nix_copy = Command::new("cp")
|
||||
.args(["garrus.nix", "gnome.nix"])
|
||||
.arg("/mnt/etc/nixos")
|
||||
let _garrus_nix_copy = Command::new("mv")
|
||||
.args(["garrus.nix", "gnome.nix", "/mnt/etc/nixos"])
|
||||
.output()
|
||||
.expect("Failed to copy nix files over");
|
||||
|
||||
let mut nixos_install = Command::new("nixos-install")
|
||||
.arg("--flake")
|
||||
.arg("/mnt/etc/nixos#garrus")
|
||||
.arg("--no-root-passwd")
|
||||
.stdout(Stdio::inherit())
|
||||
.stderr(Stdio::inherit())
|
||||
.spawn()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue