From 40d030ae7536767fae006186e708095ce570a39c Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Mon, 21 Apr 2025 12:44:31 -0600 Subject: [PATCH 1/6] remove old comment --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4cbaff9..fad2e98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,7 +90,6 @@ fn mount_partitions(drive_name: &str) { .output() .expect("Failed to create boot directory"); - // replace static path with a variable let boot_source = Some(Path::new(&efi_path)); let boot_target = Path::new("/mnt/boot"); From 74088084671b9c0f93d40007eaae6960fe162603 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Mon, 21 Apr 2025 18:02:33 -0600 Subject: [PATCH 2/6] make data dir for the nix files to not overwrite the flake --- .gitignore | 8 +------- src/main.rs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 94eb0df..d1ff78e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,4 @@ result # Main nix files -flake.nix -configuration.nix -home.nix - -# Extra nix files -garrus.nix -gnome.nix +/data diff --git a/src/main.rs b/src/main.rs index fad2e98..7722de5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,7 +107,7 @@ fn grab_flake() { let mut easy = Easy::new(); easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/flake.nix").unwrap(); - let mut file = File::create("flake.nix").unwrap(); + let mut file = File::create("data/flake.nix").unwrap(); { let mut transfer = easy.transfer(); @@ -123,7 +123,7 @@ fn grab_config() { let mut easy = Easy::new(); easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/configuration.nix").unwrap(); - let mut file = File::create("configuration.nix").unwrap(); + let mut file = File::create("data/configuration.nix").unwrap(); { let mut transfer = easy.transfer(); @@ -139,7 +139,7 @@ fn grab_home() { let mut easy = Easy::new(); easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/home.nix").unwrap(); - let mut file = File::create("home.nix").unwrap(); + let mut file = File::create("data/home.nix").unwrap(); { let mut transfer = easy.transfer(); @@ -155,7 +155,7 @@ fn grab_gnome(){ let mut gnome_config = Easy::new(); gnome_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix").unwrap(); - let mut config_file = File::create("gnome.nix").unwrap(); + let mut config_file = File::create("data/gnome.nix").unwrap(); { let mut transfer = gnome_config.transfer(); @@ -223,7 +223,8 @@ fn main() { // Copies the nix files to /mnt/etc/nixos/ let _nix_move = Command::new("mv") - .args(["-f", "flake.nix", "configuration.nix", "home.nix", "/mnt/etc/nixos"]) + .args(["-f", "data/flake.nix", "data/configuration.nix", "data/home.nix"]) + .arg("/mnt/etc/nixos") .output() .expect("Failed to move nix files over"); @@ -259,7 +260,7 @@ fn main() { let mut garrus_config = Easy::new(); garrus_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix").unwrap(); - let mut config_file = File::create("garrus.nix").unwrap(); + let mut config_file = File::create("data/garrus.nix").unwrap(); { let mut transfer = garrus_config.transfer(); @@ -272,7 +273,7 @@ fn main() { // Copies the system nix files to /mnt/etc/nixos/ let _garrus_nix_copy = Command::new("mv") - .args(["garrus.nix", "gnome.nix", "/mnt/etc/nixos"]) + .args(["data/garrus.nix", "data/gnome.nix", "/mnt/etc/nixos"]) .output() .expect("Failed to copy nix files over"); @@ -294,7 +295,7 @@ fn main() { let mut vm_config = Easy::new(); vm_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/vm/configuration.nix").unwrap(); - let mut config_file = File::create("vm.nix").unwrap(); + let mut config_file = File::create("data/vm.nix").unwrap(); { let mut transfer = vm_config.transfer(); @@ -307,7 +308,7 @@ fn main() { // Copies the system nix files to /mnt/etc/nixos/ let _garrus_nix_copy = Command::new("mv") - .args(["vm.nix", "/mnt/etc/nixos"]) + .args(["data/vm.nix", "/mnt/etc/nixos"]) .output() .expect("Failed to copy nix files over"); From 7ba1ccb07a4049787321cb9d29d57ce1faf666b1 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Mon, 21 Apr 2025 19:09:12 -0600 Subject: [PATCH 3/6] use Command for mounting the boot partition due to mount options --- src/main.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7722de5..3e2befb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,14 +93,22 @@ fn mount_partitions(drive_name: &str) { let boot_source = Some(Path::new(&efi_path)); 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") + .args(["-t", "vfat"]) + .args(["-o", "umask=0077"]) + .arg(&efi_path) + .arg("/mnt/boot") + .output() + .expect("Failed to mount boot partition"); + + // mount( + // boot_source, + // boot_target, + // Some("vfat"), + // MsFlags::empty(), + // None::<&[u8]>, + // ) + // .expect("Failed to mount boot partition"); } fn grab_flake() { From 125af53329e68d955f41873ee1fffd3614d33bb1 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Tue, 22 Apr 2025 12:26:22 -0600 Subject: [PATCH 4/6] add steps for using the bash installer --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a664e69..fd5496f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ mkpasswd -m sha-512 curl $PATH ``` +## Older Bash installer + +```bash +sh <(curl -L https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh) +``` + # Development ![docs/development](https://gitlab.com/ahoneybun/nyxi-installer/-/blob/rust-rewrite/docs/development.md) From 679c998e842f13873dc73c0d1230bc49d1145bfd Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Tue, 22 Apr 2025 12:37:14 -0600 Subject: [PATCH 5/6] add nix develop to docs --- docs/development.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/development.md b/docs/development.md index 3bc6b7f..5808ad7 100644 --- a/docs/development.md +++ b/docs/development.md @@ -20,6 +20,14 @@ This is if you are already running NixOS or using the `nix` packagemanager on yo nix-shell ``` +## Flakes + +If you have flakes enabled you can use `nix develop` instead. + +```bash +nix develop +``` + ## Ubuntu Install these packages for developing using `apt`. From 8ad801669aab2e8b8934e00a725e371ccd64aeb6 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 23 Apr 2025 18:38:22 -0600 Subject: [PATCH 6/6] swap back to main --- src/main.rs | 119 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3e2befb..4b9f9e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,15 @@ +use rsfdisk::core::partition::{Guid, Partition, PartitionKind}; +use rsfdisk::core::partition_table::PartitionTableKind; +use rsfdisk::fdisk::Fdisk; +use std::fs::File; use std::io; use std::io::Write; -use std::fs::File; -use std::process::{Command, Stdio}; use std::path::Path; +use std::process::{Command, Stdio}; use sys_metrics::disks; -use rsfdisk::fdisk::Fdisk; -use rsfdisk::core::partition_table::PartitionTableKind; -use rsfdisk::core::partition::{Guid, Partition, PartitionKind}; -use nix::mount::{mount, MsFlags}; use curl::easy::Easy; +use nix::mount::{mount, MsFlags}; fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let mut disk = Fdisk::builder() @@ -20,9 +20,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let partition_type = PartitionKind::builder() - .guid(Guid::EfiSystem) - .build()?; + let partition_type = PartitionKind::builder().guid(Guid::EfiSystem).build()?; let boot = Partition::builder() .partition_type(partition_type) @@ -113,64 +111,77 @@ fn mount_partitions(drive_name: &str) { fn grab_flake() { let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/flake.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix") + .unwrap(); let mut file = File::create("data/flake.nix").unwrap(); { let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + 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/rust-rewrite/configuration.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix") + .unwrap(); let mut file = File::create("data/configuration.nix").unwrap(); { let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + 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/rust-rewrite/home.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix") + .unwrap(); let mut file = File::create("data/home.nix").unwrap(); { let mut transfer = easy.transfer(); - transfer.write_function(|data| { - file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + transfer + .write_function(|data| { + file.write_all(data).unwrap(); + Ok(data.len()) + }) + .unwrap(); transfer.perform().unwrap(); } } -fn grab_gnome(){ +fn grab_gnome() { let mut gnome_config = Easy::new(); - gnome_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix").unwrap(); + gnome_config + .url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix") + .unwrap(); let mut config_file = File::create("data/gnome.nix").unwrap(); { let mut transfer = gnome_config.transfer(); - transfer.write_function(|data| { - config_file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + transfer + .write_function(|data| { + config_file.write_all(data).unwrap(); + Ok(data.len()) + }) + .unwrap(); transfer.perform().unwrap(); } } @@ -191,7 +202,7 @@ fn main() { println!("Disk: {}", disk.device_name); } } - Err(_e) => println!("{}",_e), + Err(_e) => println!("{}", _e), } let mut drive_name = String::new(); @@ -199,7 +210,10 @@ fn main() { println!(""); println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda"); println!(""); - 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 + ); io::stdin() .read_line(&mut drive_name) @@ -231,7 +245,12 @@ fn main() { // Copies the nix files to /mnt/etc/nixos/ let _nix_move = Command::new("mv") - .args(["-f", "data/flake.nix", "data/configuration.nix", "data/home.nix"]) + .args([ + "-f", + "data/flake.nix", + "data/configuration.nix", + "data/home.nix", + ]) .arg("/mnt/etc/nixos") .output() .expect("Failed to move nix files over"); @@ -239,10 +258,12 @@ fn main() { // Fixes a security issue with boot let _boot_fix = Command::new("sed") .arg("-i") - .arg(r#"/fsType = "vfat"/ { + .arg( + r#"/fsType = "vfat"/ { n s/\(options = \[.*\)\]/\1"umask=0077 "]/ - }"#) + }"#, + ) .arg("/mnt/etc/nixos/hardware-configuration.nix") .output() .expect("Failed to apply boot fix"); @@ -272,10 +293,12 @@ fn main() { { let mut transfer = garrus_config.transfer(); - transfer.write_function(|data| { - config_file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + transfer + .write_function(|data| { + config_file.write_all(data).unwrap(); + Ok(data.len()) + }) + .unwrap(); transfer.perform().unwrap(); } @@ -297,8 +320,8 @@ fn main() { let install_status = nixos_install.wait(); println!("Exited with status {:?}", install_status); - break - }, + break; + } "2" => { let mut vm_config = Easy::new(); vm_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/vm/configuration.nix").unwrap(); @@ -307,10 +330,12 @@ fn main() { { let mut transfer = vm_config.transfer(); - transfer.write_function(|data| { - config_file.write_all(data).unwrap(); - Ok(data.len()) - }).unwrap(); + transfer + .write_function(|data| { + config_file.write_all(data).unwrap(); + Ok(data.len()) + }) + .unwrap(); transfer.perform().unwrap(); } @@ -348,7 +373,7 @@ fn main() { println!("Exited with status {:?}", install_status); break; - }, + } _ => println!("Invalid choice, try again."), } }