From 888bba4c341005380b5b0fd6585554893c3dfb5e Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 14:21:00 -0600 Subject: [PATCH 01/48] init commit --- .gitignore | 1 + Cargo.lock | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 7 +++ src/main.rs | 30 ++++++++++++ 4 files changed, 170 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..99c4c00 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,132 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "io-kit-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2d4429acc1deff0fbdece0325b4997bdb02b2c245ab7023fd5deca0f6348de" +dependencies = [ + "core-foundation-sys", + "mach2", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "nyxi-installer" +version = "2.0.0" +dependencies = [ + "sys_metrics", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sys_metrics" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9b266b80f59f86e2e1e0a4938e316e32c3730d94a749f236305152279f77484" +dependencies = [ + "core-foundation-sys", + "glob", + "io-kit-sys", + "lazy_static", + "libc", + "mach", + "serde", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..564397c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "nyxi-installer" +version = "2.0.0" +edition = "2021" + +[dependencies] +sys_metrics = "0.2.7" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3afa952 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,30 @@ +use std::io; +use sys_metrics::disks; + +fn main() { + println!("Availble disks for installation:"); + println!(""); + + match disks::get_physical_ioblocks() { + Ok(disk_list) => { + for disk in disk_list { + println!("Disk: {}", disk.device_name); + } + } + Err(_e) => println!("{}",_e), + } + + let mut drive_name = String::new(); + + println!(""); + println!("Which drive do we want to use for this installation?: {}", drive_name); + + 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"); + +} From 725967fe25415a3772814d65353bcd74ce2e8a17 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 19:36:41 -0600 Subject: [PATCH 02/48] rsdisk working --- Cargo.lock | 533 +++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + src/main.rs | 47 ++++- 3 files changed, 579 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99c4c00..aa0100b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,18 +2,182 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.100", + "which", +] + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "cc" +version = "1.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +dependencies = [ + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "embed-doc-image" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af36f591236d9d822425cb6896595658fa558fcebf5ee8accac1d4b92c47166e" +dependencies = [ + "base64", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "enum-iterator" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" +dependencies = [ + "enum-iterator-derive", +] + +[[package]] +name = "enum-iterator-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + [[package]] name = "glob" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "indexmap" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "io-kit-sys" version = "0.3.0" @@ -30,12 +194,40 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +[[package]] +name = "libloading" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "log" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" + [[package]] name = "mach" version = "0.3.2" @@ -54,13 +246,107 @@ dependencies = [ "libc", ] +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "minimal-lexical" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num_enum" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "nyxi-installer" version = "2.0.0" dependencies = [ + "nix", + "rsfdisk", "sys_metrics", ] +[[package]] +name = "once_cell" +version = "1.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "prettyplease" +version = "0.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +dependencies = [ + "proc-macro2", + "syn 2.0.100", +] + +[[package]] +name = "proc-macro-crate" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.94" @@ -79,6 +365,83 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rsfdisk" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b3cacc1af2ca434035b8c885b1ef4d64a663581df95134653feba07fccae0c" +dependencies = [ + "embed-doc-image", + "enum-iterator", + "libc", + "log", + "num_enum", + "once_cell", + "pkg-config", + "rsfdisk-sys", + "thiserror", + "typed-builder", +] + +[[package]] +name = "rsfdisk-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39b186475d9df76290bba3de5196eeed64b95e77861095ea8b244f962f47575" +dependencies = [ + "bindgen", + "cc", + "pkg-config", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "serde" version = "1.0.219" @@ -96,7 +459,24 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.100", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] @@ -125,8 +505,159 @@ dependencies = [ "serde", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typed-builder" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9d30e3a08026c78f246b173243cf07b3696d274debd26680773b6773c2afc7" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c36781cc0e46a83726d9879608e4cf6c2505237e263a8eb8c24502989cfdb28" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "unicode-ident" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml index 564397c..6017b19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,5 @@ version = "2.0.0" edition = "2021" [dependencies] +rsfdisk = "0.1.0" sys_metrics = "0.2.7" diff --git a/src/main.rs b/src/main.rs index 3afa952..a740890 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,47 @@ use std::io; use sys_metrics::disks; +use rsfdisk::fdisk::Fdisk; +use rsfdisk::core::partition_table::PartitionTableKind; +use rsfdisk::core::partition::{Guid, Partition, PartitionKind, PartitionList}; + +fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { + let mut disk = Fdisk::builder() + .assign_device(drive_name) + .enable_read_write() + .wipe_device_metadata() + .build()?; + + disk.partition_table_create(PartitionTableKind::GPT)?; + + let partition_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) + .build()?; + + let boot = Partition::builder() + .partition_type(partition_type.clone()) + .name("EFI") + //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. + .size_in_sectors(2_097_152) + .build()?; + + let _ = disk.partition_add(boot)?; + + let root = Partition::builder() + .partition_type(partition_type) + .name("Root") + .size_in_sectors(499_033_071_616) + .build()?; + + let _ = disk.partition_add(root)?; + + disk.partition_table_write_to_disk()?; + + Ok(()) +} + +fn mount_parts() { + +} fn main() { println!("Availble disks for installation:"); @@ -23,8 +65,11 @@ fn main() { .read_line(&mut drive_name) .expect("Failed to read line"); - 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 + format_drive(drive_name); + } From 3e2ac09e373398812bf7b3186785264d991e3479 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 19:39:33 -0600 Subject: [PATCH 03/48] add development nix-shell file --- shell.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 shell.nix diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..826e6ba --- /dev/null +++ b/shell.nix @@ -0,0 +1,26 @@ +{ pkgs ? import {} }: + + pkgs.mkShell { + buildInputs = with pkgs; [ + # Rust + cargo + rustc + + # Compiler + gnumake + clang + llvmPackages.libclang + llvmPackages.clang + + # System + pkg-config + util-linux + ]; + + shellHook = '' + export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" + export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" + export RUST_BACKTRACE=1 + echo "Ready to make some rust!" + ''; +} From db898d510d158fcd956efdec0b8c8bf6df9030bf Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 19:43:01 -0600 Subject: [PATCH 04/48] add README --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b1e531 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# The NixOS Installer + +This installer is named after my doggo Onyxia. + +## Starting the Installer + +```bash +sh <(curl -L https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh) +``` + +At the core of this installer it does the following: + +- Partition the drive of your choice using the `rsfdisk` crate. +- Uses `flake.nix` to set certain modules depending on the system like nixos-hardware for the Pinebook Pro +- Installs a base of NixOS (`configuration.nix`) + +nix files are from [this repo](https://gitlab.com/ahoneybun/nix-configs/) but that can be changed as needed. + +This sets the hashedPassword to my own so you will need to update it to match your own as well as the username. I created the hash with this command: + +```bash +mkpasswd -m sha-512 +``` From 2281629835e97bae66b4a9ada9332ad5775f42a0 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 19:54:51 -0600 Subject: [PATCH 05/48] add note about full path for drive --- Cargo.lock | 19 ------------------- src/main.rs | 1 + 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa0100b..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" @@ -258,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" @@ -305,7 +287,6 @@ dependencies = [ name = "nyxi-installer" version = "2.0.0" dependencies = [ - "nix", "rsfdisk", "sys_metrics", ] diff --git a/src/main.rs b/src/main.rs index a740890..e6674ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,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); io::stdin() From 64ba913d398748e04582c06ba6e435842fa9a969 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sun, 23 Mar 2025 19:55:07 -0600 Subject: [PATCH 06/48] remove command with curl as this is not valid --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9b1e531..0b9f3d2 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ This installer is named after my doggo Onyxia. ## Starting the Installer ```bash -sh <(curl -L https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh) ``` At the core of this installer it does the following: From 382e4e3f063cbaa61ea4114c78a212249b81c291 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 19:16:05 -0600 Subject: [PATCH 07/48] add nix-shell for development --- shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index 826e6ba..df7b7fc 100644 --- a/shell.nix +++ b/shell.nix @@ -21,6 +21,6 @@ export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" export RUST_BACKTRACE=1 - echo "Ready to make some rust!" + echo "We're ready to make some Rust!" ''; } From ea7303c2eee5a92ca2a6234f1b3bcf19858195ec Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 19:55:19 -0600 Subject: [PATCH 08/48] update shell file and code for curl --- shell.nix | 1 + src/main.rs | 71 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/shell.nix b/shell.nix index df7b7fc..f3174fb 100644 --- a/shell.nix +++ b/shell.nix @@ -13,6 +13,7 @@ llvmPackages.clang # System + openssl pkg-config util-linux ]; diff --git a/src/main.rs b/src/main.rs index e6674ad..c922407 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,13 @@ use std::io; +use std::io::{stdout, Write}; +use std::fs::File; 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) @@ -31,7 +35,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { .name("Root") .size_in_sectors(499_033_071_616) .build()?; - + let _ = disk.partition_add(root)?; disk.partition_table_write_to_disk()?; @@ -39,12 +43,64 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { 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() { + println!("--------------------------------------"); + println!("| Welcome to the Nyxi Installer 2.0! |"); + println!("--------------------------------------"); + println!(""); + println!("Availble disks for installation:"); + println!("---------------------------------"); println!(""); match disks::get_physical_ioblocks() { @@ -57,7 +113,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); @@ -65,7 +121,7 @@ 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"); @@ -73,4 +129,9 @@ fn main() { // Partitioning the selected drive format_drive(drive_name); + // Download nix files + grab_flake(); + grab_config(); + grab_home(); + } From 8ddbfe05d850e2c8f90dd1a9f3c57b219adfafa1 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:22:29 -0600 Subject: [PATCH 09/48] add Command for testing and testing for a flash drive --- Cargo.lock | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 1 + src/main.rs | 41 ++++++++++++++++++++- 3 files changed, 139 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0089cb2..4453c35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,6 +87,36 @@ 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" @@ -138,7 +168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -159,7 +189,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -210,6 +240,18 @@ 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" @@ -287,6 +329,7 @@ dependencies = [ name = "nyxi-installer" version = "2.0.0" dependencies = [ + "curl", "rsfdisk", "sys_metrics", ] @@ -297,6 +340,24 @@ 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" @@ -420,7 +481,16 @@ dependencies = [ "errno", "libc", "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]] @@ -449,6 +519,16 @@ 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" @@ -549,6 +629,12 @@ 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" @@ -561,6 +647,15 @@ 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 6017b19..f5d8dd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,6 @@ version = "2.0.0" edition = "2021" [dependencies] +curl = "0.4.47" rsfdisk = "0.1.0" sys_metrics = "0.2.7" diff --git a/src/main.rs b/src/main.rs index c922407..5a5319e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ 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; @@ -33,7 +34,10 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let root = Partition::builder() .partition_type(partition_type) .name("Root") - .size_in_sectors(499_033_071_616) + // 132,120,576 sectors for a 64GB flash drive + .size_in_sectors(132_120_576) + // 500GB + //.size_in_sectors(499_033_071_61) .build()?; let _ = disk.partition_add(root)?; @@ -45,6 +49,29 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { fn mount_parts() {} +// fn grab_configs() { +// let mut flakeConfig = Easy::new(); +// let mut mainConfig = Easy::new(); +// let mut homeConfig = Easy::new(); + +// flakeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); +// mainConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix").unwrap(); +// homeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix").unwrap(); + +// let mut flakeFile = File::create("flake.nix").unwrap(); +// let mut mainFile = File::create("configuration.nix").unwrap(); +// let mut homeFile = File::create("home.nix").unwrap(); + +// { +// let mut flakeTransfer = easy.transfer(); +// transfer.write_function(|data| { +// flakeFile.write_all(data).unwrap(); +// Ok(data.len()) +// }).unwrap(); +// transfer.perform().unwrap(); +// } +// } + fn grab_flake() { let mut easy = Easy::new(); easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); @@ -93,6 +120,15 @@ fn grab_home() { } } +fn nix_gen() { + let output = Command::new("nixos-generate-config") + .arg("no-file-systems") + .arg("--root") + .arg("/mnt") + .output() + .expect("Failed to execute command"); +} + fn main() { println!("--------------------------------------"); println!("| Welcome to the Nyxi Installer 2.0! |"); @@ -129,9 +165,12 @@ fn main() { // Partitioning the selected drive format_drive(drive_name); + // placeholder for nix-generate-config + // Download nix files grab_flake(); grab_config(); grab_home(); + nix_gen(); } From 6efe2ba259fecb66a7f6f62a3728172b3c1f495e Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:30:35 -0600 Subject: [PATCH 10/48] add host selection menu --- src/main.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main.rs b/src/main.rs index 5a5319e..f2beb7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -173,4 +173,31 @@ fn main() { grab_home(); nix_gen(); + + // Host selection + loop { + println!(""); + println!("Host selection"); + println!("1. Device 1"); + println!("2. Device 2"); + println!("3. Device 3"); + println!(""); + + println!("Enter your host for installation:"); + + let mut choice = String::new(); + io::stdin().read_line(&mut choice).unwrap(); + + match choice.trim() { + "1" => println!("Hello, world!"), + "2" => { + println!("2 + 2 = {}", 2 + 2); + }, + "3" => { + println!("Goodbye!"); + break; + }, + _ => println!("Invalid choice, try again."), + } + } } From 8b16d6c481bcb95b59ae05247692d07dea84f78c Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:31:54 -0600 Subject: [PATCH 11/48] clean up incorrect code --- src/main.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index f2beb7d..284b544 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,15 +120,6 @@ fn grab_home() { } } -fn nix_gen() { - let output = Command::new("nixos-generate-config") - .arg("no-file-systems") - .arg("--root") - .arg("/mnt") - .output() - .expect("Failed to execute command"); -} - fn main() { println!("--------------------------------------"); println!("| Welcome to the Nyxi Installer 2.0! |"); @@ -160,8 +151,6 @@ fn main() { 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); @@ -172,7 +161,12 @@ fn main() { grab_config(); grab_home(); - nix_gen(); + let output = Command::new("nixos-generate-config") + .arg("no-file-systems") + .arg("--root") + .arg("/mnt") + .output() + .expect("Failed to execute command"); // Host selection loop { From e47764618a233f7cbf7c401250c1d3398eccc639 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:42:49 -0600 Subject: [PATCH 12/48] add garrus to the host menu --- src/main.rs | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/src/main.rs b/src/main.rs index 284b544..b80f143 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,29 +49,6 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { fn mount_parts() {} -// fn grab_configs() { -// let mut flakeConfig = Easy::new(); -// let mut mainConfig = Easy::new(); -// let mut homeConfig = Easy::new(); - -// flakeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); -// mainConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix").unwrap(); -// homeConfig.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix").unwrap(); - -// let mut flakeFile = File::create("flake.nix").unwrap(); -// let mut mainFile = File::create("configuration.nix").unwrap(); -// let mut homeFile = File::create("home.nix").unwrap(); - -// { -// let mut flakeTransfer = easy.transfer(); -// transfer.write_function(|data| { -// flakeFile.write_all(data).unwrap(); -// Ok(data.len()) -// }).unwrap(); -// transfer.perform().unwrap(); -// } -// } - fn grab_flake() { let mut easy = Easy::new(); easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); @@ -172,7 +149,7 @@ fn main() { loop { println!(""); println!("Host selection"); - println!("1. Device 1"); + println!("1. Lemur Pro 13 (Garrus)"); println!("2. Device 2"); println!("3. Device 3"); println!(""); @@ -183,7 +160,22 @@ fn main() { io::stdin().read_line(&mut choice).unwrap(); match choice.trim() { - "1" => println!("Hello, world!"), + "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" => { println!("2 + 2 = {}", 2 + 2); }, From df9d271f4257b4ebbfd8930705d3621718b5226c Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:50:45 -0600 Subject: [PATCH 13/48] correct flash drive size --- src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index b80f143..65084d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,8 +34,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let root = Partition::builder() .partition_type(partition_type) .name("Root") - // 132,120,576 sectors for a 64GB flash drive - .size_in_sectors(132_120_576) + .size_in_sectors(121_634_816) // 500GB //.size_in_sectors(499_033_071_61) .build()?; @@ -138,7 +137,7 @@ fn main() { grab_config(); grab_home(); - let output = Command::new("nixos-generate-config") + let nixos_gen_con = Command::new("nixos-generate-config") .arg("no-file-systems") .arg("--root") .arg("/mnt") @@ -151,7 +150,7 @@ fn main() { println!("Host selection"); println!("1. Lemur Pro 13 (Garrus)"); println!("2. Device 2"); - println!("3. Device 3"); + println!("3. Quit"); println!(""); println!("Enter your host for installation:"); From 4121a00eea9eb450a7da6d3836581c6bdc021cd9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:53:19 -0600 Subject: [PATCH 14/48] add code for nixos-install (untested) --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 65084d7..d165520 100644 --- a/src/main.rs +++ b/src/main.rs @@ -137,7 +137,7 @@ fn main() { grab_config(); grab_home(); - let nixos_gen_con = Command::new("nixos-generate-config") + let nixos-gen-config = Command::new("nixos-generate-config") .arg("no-file-systems") .arg("--root") .arg("/mnt") @@ -176,7 +176,10 @@ fn main() { break } "2" => { - println!("2 + 2 = {}", 2 + 2); + let nixos-install = Command::new("nixos-install") + .arg("--flake") + .arg("/mnt/etc/nixos#garrus") + .expect("Fiale to execute command"); }, "3" => { println!("Goodbye!"); From 7d472cee71a0141988aad8b4b70840f51bc2426a Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 20:54:48 -0600 Subject: [PATCH 15/48] add nix crate --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 1 + 2 files changed, 20 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 4453c35..5a5e4e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,12 @@ 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" @@ -294,6 +300,18 @@ 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" @@ -330,6 +348,7 @@ name = "nyxi-installer" version = "2.0.0" dependencies = [ "curl", + "nix", "rsfdisk", "sys_metrics", ] diff --git a/Cargo.toml b/Cargo.toml index f5d8dd9..05bc2ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,5 +5,6 @@ edition = "2021" [dependencies] curl = "0.4.47" +nix = "0.29.0" rsfdisk = "0.1.0" sys_metrics = "0.2.7" From ea97e91116caec0576f810d7e70cd41ed2012573 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 21:08:33 -0600 Subject: [PATCH 16/48] fix names --- src/main.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index d165520..a00d85f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,14 +130,28 @@ fn main() { // Partitioning the selected drive format_drive(drive_name); - // placeholder for nix-generate-config + // 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.btrfs") + .arg("-L") + .arg("root") + .arg("/dev/sda1") + .output() + .expect("Failed to partition root partition as BTRFS"); // Download nix files grab_flake(); grab_config(); grab_home(); - let nixos-gen-config = Command::new("nixos-generate-config") + let nixos_gen_config = Command::new("nixos-generate-config") .arg("no-file-systems") .arg("--root") .arg("/mnt") @@ -176,9 +190,10 @@ fn main() { break } "2" => { - let nixos-install = Command::new("nixos-install") + let nixos_install = Command::new("nixos-install") .arg("--flake") .arg("/mnt/etc/nixos#garrus") + .output() .expect("Fiale to execute command"); }, "3" => { From 2679312b9f9cbce110d4179e8c4d90eb88f0c9c9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 21:13:42 -0600 Subject: [PATCH 17/48] partitioning is working --- shell.nix | 3 ++- src/main.rs | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/shell.nix b/shell.nix index f3174fb..389b07c 100644 --- a/shell.nix +++ b/shell.nix @@ -12,7 +12,8 @@ llvmPackages.libclang llvmPackages.clang - # System + # Systemi + e2fsprogs openssl pkg-config util-linux diff --git a/src/main.rs b/src/main.rs index a00d85f..9f4970d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,12 +139,10 @@ fn main() { .output() .expect("Failed to partition boot partition as FAT32"); - let root_partition = Command::new("mkfs.btrfs") - .arg("-L") - .arg("root") - .arg("/dev/sda1") + let root_partition = Command::new("mkfs.ext4") + .arg("/dev/sda2") .output() - .expect("Failed to partition root partition as BTRFS"); + .expect("Failed to partition root partition as ext4"); // Download nix files grab_flake(); From 0c4f154325d045919d3cee33abe8226b12a0ec15 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 9 Apr 2025 21:14:25 -0600 Subject: [PATCH 18/48] add btrfs support to shell --- shell.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell.nix b/shell.nix index 389b07c..7f9e443 100644 --- a/shell.nix +++ b/shell.nix @@ -12,7 +12,8 @@ llvmPackages.libclang llvmPackages.clang - # Systemi + # System + btrfs-progs e2fsprogs openssl pkg-config From efb80cacea044976bbecddce44e6129fe0bb0bf9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 09:47:33 -0600 Subject: [PATCH 19/48] correct partition type for EFI --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9f4970d..8dae014 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let partition_type = PartitionKind::builder() - .guid(Guid::LinuxRootx86_64) + let boot_part_type = PartitionKind::builder() + .guid(Guid::EfiSystem) .build()?; let boot = Partition::builder() - .partition_type(partition_type.clone()) + .boot_part_type(partition_type.clone()) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -31,8 +31,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; + let root_part_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) + .build()?; + let root = Partition::builder() - .partition_type(partition_type) + .root_part_type(partition_type) .name("Root") .size_in_sectors(121_634_816) // 500GB From e3e65277012effb88afa84d48d0364d650d0c2d9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 14:52:05 -0600 Subject: [PATCH 20/48] Revert "correct partition type for EFI" This reverts commit efb80cacea044976bbecddce44e6129fe0bb0bf9 --- src/main.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8dae014..9f4970d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,12 +18,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let boot_part_type = PartitionKind::builder() - .guid(Guid::EfiSystem) + let partition_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) .build()?; let boot = Partition::builder() - .boot_part_type(partition_type.clone()) + .partition_type(partition_type.clone()) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -31,12 +31,8 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; - let root_part_type = PartitionKind::builder() - .guid(Guid::LinuxRootx86_64) - .build()?; - let root = Partition::builder() - .root_part_type(partition_type) + .partition_type(partition_type) .name("Root") .size_in_sectors(121_634_816) // 500GB From 4e567a79b00e748d5ec9232723c78bc33ab66a71 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 15:22:45 -0600 Subject: [PATCH 21/48] clean up cargo warning/info messages --- src/main.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9f4970d..ae63a5b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use std::io; -use std::io::{stdout, Write}; +use std::io::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 rsfdisk::core::partition::{Guid, Partition, PartitionKind}; use curl::easy::Easy; @@ -46,7 +46,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { Ok(()) } -fn mount_parts() {} +// fn mount_parts() {} fn grab_flake() { let mut easy = Easy::new(); @@ -128,10 +128,10 @@ fn main() { let drive_name = drive_name.trim(); // Partitioning the selected drive - format_drive(drive_name); + let _ = format_drive(drive_name); // Formatting the partitions - let efi_partition = Command::new("mkfs.fat") + let _efi_partition = Command::new("mkfs.fat") .arg("-F32") .arg("-n") .arg("EFI") @@ -139,7 +139,7 @@ fn main() { .output() .expect("Failed to partition boot partition as FAT32"); - let root_partition = Command::new("mkfs.ext4") + let _root_partition = Command::new("mkfs.ext4") .arg("/dev/sda2") .output() .expect("Failed to partition root partition as ext4"); @@ -149,7 +149,7 @@ fn main() { grab_config(); grab_home(); - let nixos_gen_config = Command::new("nixos-generate-config") + let _nixos_gen_config = Command::new("nixos-generate-config") .arg("no-file-systems") .arg("--root") .arg("/mnt") @@ -172,15 +172,15 @@ fn main() { 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 garrus_config = Easy::new(); + garrus_config.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 config_file = File::create("configuration.nix").unwrap(); { - let mut transfer = garrusConfig.transfer(); + let mut transfer = garrus_config.transfer(); transfer.write_function(|data| { - configFile.write_all(data).unwrap(); + config_file.write_all(data).unwrap(); Ok(data.len()) }).unwrap(); transfer.perform().unwrap(); @@ -188,7 +188,7 @@ fn main() { break } "2" => { - let nixos_install = Command::new("nixos-install") + let _nixos_install = Command::new("nixos-install") .arg("--flake") .arg("/mnt/etc/nixos#garrus") .output() @@ -201,4 +201,4 @@ fn main() { _ => println!("Invalid choice, try again."), } } -} +} \ No newline at end of file From df7ab3e3ad15bde637c1534a5b7cbcc2a677ac5b Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 18:01:52 -0600 Subject: [PATCH 22/48] update gitignore for nix files the installer will download --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ea8c4bf..7f1fe06 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /target +flake.nix +configuration.nix +home.nix From 329b99443d5b682a4853c95bedc10d0b02670f2e Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 18:09:18 -0600 Subject: [PATCH 23/48] add partition function --- src/main.rs | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index ae63a5b..b6bb7a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,9 +34,10 @@ 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) + // Flash drive testing + // .size_in_sectors(121_634_816) + // Internal drive testing + .size_in_sectors(499_033_071_61) .build()?; let _ = disk.partition_add(root)?; @@ -46,6 +47,21 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { Ok(()) } +fn format_partitions() { + let _efi_partition = Command::new("mkfs.fat") + .arg("-F32") + .arg("-n") + .arg("EFI") + .arg("/dev/nvme1n1p1") + .output() + .expect("Failed to partition boot partition as FAT32"); + + let _root_partition = Command::new("mkfs.ext4") + .arg("/dev/nvme1n1p2") + .output() + .expect("Failed to partition root partition as ext4"); +} + // fn mount_parts() {} fn grab_flake() { @@ -120,6 +136,8 @@ fn main() { 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); + println!(""); + println!("If you're on the Lemur nvme1n1 is the test drive"); io::stdin() .read_line(&mut drive_name) @@ -131,18 +149,7 @@ fn main() { let _ = 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"); + format_partitions(); // Download nix files grab_flake(); @@ -201,4 +208,4 @@ fn main() { _ => println!("Invalid choice, try again."), } } -} \ No newline at end of file +} From b7c45f60c45d0ea28f22f062addf1b931a1e753c Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 18:15:40 -0600 Subject: [PATCH 24/48] fix garrus filename --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index b6bb7a5..ee0addb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -182,7 +182,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("configuration.nix").unwrap(); + let mut config_file = File::create("garrus.nix").unwrap(); { let mut transfer = garrus_config.transfer(); From 3182e823cca405ba1c1c747cc288f84848aeca4d Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 18:58:08 -0600 Subject: [PATCH 25/48] update nix-configs to rust-rewrite branch --- src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index ee0addb..0ec2d6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,7 +66,7 @@ fn format_partitions() { fn grab_flake() { let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/flake.nix").unwrap(); let mut file = File::create("flake.nix").unwrap(); @@ -82,7 +82,7 @@ fn grab_flake() { fn grab_config() { let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/configuration.nix").unwrap(); let mut file = File::create("configuration.nix").unwrap(); @@ -98,7 +98,7 @@ fn grab_config() { fn grab_home() { let mut easy = Easy::new(); - easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix").unwrap(); + easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/home.nix").unwrap(); let mut file = File::create("home.nix").unwrap(); From 27bfd3eefacfb2ad7544806df974bfb580eb2dcd Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 20:16:34 -0600 Subject: [PATCH 26/48] add mount feature for nix crate --- Cargo.toml | 2 +- src/main.rs | 77 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 05bc2ba..69aee11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] curl = "0.4.47" -nix = "0.29.0" +nix = { version = "0.29.0", features = ["mount"] } rsfdisk = "0.1.0" sys_metrics = "0.2.7" diff --git a/src/main.rs b/src/main.rs index 0ec2d6e..873ce01 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,16 @@ use std::io; use std::io::Write; +use std::fs; use std::fs::File; use std::process::Command; +use std::path::Path; 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 std::os::unix::ffi::OsStrExt; use curl::easy::Easy; fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { @@ -38,6 +42,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { // .size_in_sectors(121_634_816) // Internal drive testing .size_in_sectors(499_033_071_61) + // replace static int with a variable .build()?; let _ = disk.partition_add(root)?; @@ -52,17 +57,71 @@ fn format_partitions() { .arg("-F32") .arg("-n") .arg("EFI") + // replace static path with a 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/nvme1n1p2") .output() .expect("Failed to partition root partition as ext4"); } -// fn mount_parts() {} +fn mount_root() { + // replace static path with a variable + let root_source = Some(Path::new("/dev/nvme1n1p2")); + let root_target = Path::new("/mnt"); + + // unmounts root before hand to fix bugs + let _umount_root = Command::new("umount") + // replace static path with a variable + .arg("/dev/nvme1n1p2") + .output() + .expect("Failed to unmount root"); + + 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("/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/nvme1n1p1")); + let boot_target = Path::new("/mnt/boot"); + + mount( + boot_source, + boot_target, + Some("FAT32"), + MsFlags::empty(), + None::<&[u8]>, + ) + .expect("Failed to mount boot partition"); + + println!(""); +} fn grab_flake() { let mut easy = Easy::new(); @@ -151,6 +210,11 @@ fn main() { // Formatting the partitions format_partitions(); + // Mounting the partitions + mount_root(); + + // mount_boot(); + // Download nix files grab_flake(); grab_config(); @@ -192,14 +256,17 @@ fn main() { }).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"); + .expect("Failed to execute command"); + + break + } + "2" => { + println!("Nix the world!"); }, "3" => { println!("Goodbye!"); From 343c8c149bb71fdc767802a7e71bc9685ec5aa76 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 20:25:35 -0600 Subject: [PATCH 27/48] boot partition is not mounting --- .gitignore | 1 + src/main.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7f1fe06..69dd811 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ flake.nix configuration.nix home.nix +garrus.nix diff --git a/src/main.rs b/src/main.rs index 873ce01..8d42b76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,7 +114,7 @@ fn mount_boot() { mount( boot_source, boot_target, - Some("FAT32"), + Some("vfat"), MsFlags::empty(), None::<&[u8]>, ) From 110a12cf341cfe861fc44b1b89fd7814a8d51918 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 20:34:04 -0600 Subject: [PATCH 28/48] adding funny doggo prints --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index 8d42b76..d97e9d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -227,6 +227,11 @@ fn main() { .output() .expect("Failed to execute command"); + println!(""); + println!("Water packed!"); + println!("Treats packed!"); + println!("We're ready for our walk!"); + // Host selection loop { println!(""); From 24febde5f70749ae12a11d8c5702d5816f60b5f7 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 10 Apr 2025 20:45:34 -0600 Subject: [PATCH 29/48] messing with the spacing a bit --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index d97e9d7..fe3ba6f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -194,9 +194,9 @@ fn main() { 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); - println!(""); println!("If you're on the Lemur nvme1n1 is the test drive"); + println!(""); + println!("Which drive do we want to use for this installation?: {}", drive_name); io::stdin() .read_line(&mut drive_name) @@ -228,14 +228,18 @@ fn main() { .expect("Failed to execute command"); println!(""); + println!("-------------------------"); println!("Water packed!"); println!("Treats packed!"); println!("We're ready for our walk!"); + println!("-------------------------"); // Host selection loop { println!(""); - println!("Host selection"); + println!("Host selection:"); + println!("---------------"); + println!(""); println!("1. Lemur Pro 13 (Garrus)"); println!("2. Device 2"); println!("3. Quit"); From 92a1b02e0236353c5685fdb13743a8a4f161d9e9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 06:14:32 -0600 Subject: [PATCH 30/48] remove funny messages and now boot mounts? --- src/main.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index fe3ba6f..029f4e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use std::io; use std::io::Write; -use std::fs; use std::fs::File; use std::process::Command; use std::path::Path; @@ -10,7 +9,6 @@ use rsfdisk::core::partition_table::PartitionTableKind; use rsfdisk::core::partition::{Guid, Partition, PartitionKind}; use nix::mount::{mount, MsFlags}; -use std::os::unix::ffi::OsStrExt; use curl::easy::Easy; fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { @@ -213,7 +211,7 @@ fn main() { // Mounting the partitions mount_root(); - // mount_boot(); + mount_boot(); // Download nix files grab_flake(); @@ -227,12 +225,14 @@ fn main() { .output() .expect("Failed to execute command"); - println!(""); - println!("-------------------------"); - println!("Water packed!"); - println!("Treats packed!"); - println!("We're ready for our walk!"); - println!("-------------------------"); + // Copies the nix files to /mnt/etc/nixos/ + let _nix_copy = Command::new("cp") + .arg("flake.nix") + .arg("configuration.nix") + .arg("home.nix") + .arg("/mnt/etc/nixos") + .output() + .expect("Failed to copy nix files over"); // Host selection loop { @@ -266,12 +266,21 @@ fn main() { transfer.perform().unwrap(); } - let _nixos_install = Command::new("nixos-install") + // Copies the system nix files to /mnt/etc/nixos/ + let _nix_copy = Command::new("cp") + .arg("garrus.nix") + .arg("/mnt/etc/nixos") + .output() + .expect("Failed to copy nix files over"); + + let nixos_install = Command::new("nixos-install") .arg("--flake") .arg("/mnt/etc/nixos#garrus") .output() .expect("Failed to execute command"); + println!("stdout:\n{}", String::from_utf8_lossy(&nixos_install.stdout)); + break } "2" => { From 049771bbac3bb203d56276e9a35d3a991e6586ca Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 07:50:04 -0600 Subject: [PATCH 31/48] it works? maybe? --- .gitignore | 3 +++ src/main.rs | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 69dd811..34537f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ /target +# Main nix files flake.nix configuration.nix home.nix +# Extra nix files garrus.nix +gnome.nix diff --git a/src/main.rs b/src/main.rs index 029f4e5..07e809f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,12 +20,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let partition_type = PartitionKind::builder() - .guid(Guid::LinuxRootx86_64) + let boot_type = PartitionKind::builder() + .guid(Guid::EfiSystem) .build()?; let boot = Partition::builder() - .partition_type(partition_type.clone()) + .partition_type(boot_type.clone()) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -33,8 +33,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; + let root_type = PartitionKind::builder() + .guid(Guid::LinuxRootx86_64) + .build()?; + let root = Partition::builder() - .partition_type(partition_type) + .partition_type(root_type) .name("Root") // Flash drive testing // .size_in_sectors(121_634_816) @@ -169,6 +173,22 @@ fn grab_home() { } } +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 transfer = gnome_config.transfer(); + transfer.write_function(|data| { + config_file.write_all(data).unwrap(); + Ok(data.len()) + }).unwrap(); + transfer.perform().unwrap(); + } +} + fn main() { println!("--------------------------------------"); println!("| Welcome to the Nyxi Installer 2.0! |"); @@ -217,16 +237,16 @@ fn main() { grab_flake(); grab_config(); grab_home(); + grab_gnome(); let _nixos_gen_config = Command::new("nixos-generate-config") - .arg("no-file-systems") .arg("--root") .arg("/mnt") .output() .expect("Failed to execute command"); // Copies the nix files to /mnt/etc/nixos/ - let _nix_copy = Command::new("cp") + let _nix_copy = Command::new("mv") .arg("flake.nix") .arg("configuration.nix") .arg("home.nix") @@ -267,8 +287,9 @@ fn main() { } // Copies the system nix files to /mnt/etc/nixos/ - let _nix_copy = Command::new("cp") + let _garrus_nix_copy = Command::new("cp") .arg("garrus.nix") + .arg("gnome.nix") .arg("/mnt/etc/nixos") .output() .expect("Failed to copy nix files over"); From 1bd5691f790b9b3db052cf047c3e0a335d0aa886 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 18:02:12 -0600 Subject: [PATCH 32/48] revert const --- src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 07e809f..54544e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -212,7 +212,6 @@ fn main() { println!(""); println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda"); - println!("If you're on the Lemur nvme1n1 is the test drive"); println!(""); println!("Which drive do we want to use for this installation?: {}", drive_name); @@ -247,9 +246,7 @@ fn main() { // Copies the nix files to /mnt/etc/nixos/ let _nix_copy = Command::new("mv") - .arg("flake.nix") - .arg("configuration.nix") - .arg("home.nix") + .args(["flake.nix", "configration.nix", "home.nix"]) .arg("/mnt/etc/nixos") .output() .expect("Failed to copy nix files over"); @@ -288,8 +285,7 @@ fn main() { // Copies the system nix files to /mnt/etc/nixos/ let _garrus_nix_copy = Command::new("cp") - .arg("garrus.nix") - .arg("gnome.nix") + .args(["garrus.nix", "gnome.nix"]) .arg("/mnt/etc/nixos") .output() .expect("Failed to copy nix files over"); From d401322fde8a1cc9da55d5731a761ca589c01c50 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 11:56:50 -0600 Subject: [PATCH 33/48] update the README --- README.md | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0b9f3d2..04c0632 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,6 @@ This installer is named after my doggo Onyxia. -## Starting the Installer - -```bash -``` - At the core of this installer it does the following: - Partition the drive of your choice using the `rsfdisk` crate. @@ -20,3 +15,35 @@ This sets the hashedPassword to my own so you will need to update it to match yo ```bash mkpasswd -m sha-512 ``` + +# Development + +## Clone the repository + +```bash +git clone https://gitlab.com/ahoneybun/nyxi-installer.git +``` + +## Enter the repository that you just cloned + +```bash +cd nyxi-installer +``` + +## Enter nix-shell + +This is if you are already running NixOS on your system where development will take place. This will install the needed system packages, set environment variables and such for development. + +```bash +nix-shell +``` + +## Building and testing + +You can use normal `cargo` commands like: + +- `cargo test` +- `cargo build` +- `cargo run` + +**NOTE:** you will need to build the program and run it with `sudo` currently so `cargo run` is not the best for testing. From db4741c423c9b9f77c0582c3fcf6313c798ae1c9 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 21:36:21 -0600 Subject: [PATCH 34/48] add stdin for nixos-install output --- src/main.rs | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main.rs b/src/main.rs index 54544e6..4b31ef4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use std::io; use std::io::Write; use std::fs::File; -use std::process::Command; +use std::process::{Command, Stdio}; use std::path::Path; use sys_metrics::disks; use rsfdisk::fdisk::Fdisk; @@ -20,12 +20,12 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { disk.partition_table_create(PartitionTableKind::GPT)?; - let boot_type = PartitionKind::builder() + let partition_type = PartitionKind::builder() .guid(Guid::EfiSystem) .build()?; let boot = Partition::builder() - .partition_type(boot_type.clone()) + .partition_type(partition_type) .name("EFI") //Assuming 512 bytes per sector, 2_097_152 sectors <=> 1 GiB. .size_in_sectors(2_097_152) @@ -33,17 +33,17 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let _ = disk.partition_add(boot)?; - let root_type = PartitionKind::builder() + let partition_type = PartitionKind::builder() .guid(Guid::LinuxRootx86_64) .build()?; let root = Partition::builder() - .partition_type(root_type) + .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()?; @@ -60,29 +60,22 @@ fn format_partitions() { .arg("-n") .arg("EFI") // replace static path with a variable - .arg("/dev/nvme1n1p1") + .arg("/dev/sda1") .output() .expect("Failed to partition boot partition as FAT32"); let _root_partition = Command::new("mkfs.ext4") // replace static path with a variable - .arg("/dev/nvme1n1p2") + .arg("/dev/sda2") .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/nvme1n1p2")); + let root_source = Some(Path::new("/dev/sda2")); let root_target = Path::new("/mnt"); - // unmounts root before hand to fix bugs - let _umount_root = Command::new("umount") - // replace static path with a variable - .arg("/dev/nvme1n1p2") - .output() - .expect("Failed to unmount root"); - mount( root_source, root_target, @@ -110,7 +103,7 @@ fn mount_root() { fn mount_boot() { // replace static path with a variable - let boot_source = Some(Path::new("/dev/nvme1n1p1")); + let boot_source = Some(Path::new("/dev/sda1")); let boot_target = Path::new("/mnt/boot"); mount( @@ -229,7 +222,6 @@ fn main() { // Mounting the partitions mount_root(); - mount_boot(); // Download nix files @@ -290,13 +282,16 @@ fn main() { .output() .expect("Failed to copy nix files over"); - let nixos_install = Command::new("nixos-install") + let mut nixos_install = Command::new("nixos-install") .arg("--flake") .arg("/mnt/etc/nixos#garrus") - .output() - .expect("Failed to execute command"); + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn() + .unwrap(); - println!("stdout:\n{}", String::from_utf8_lossy(&nixos_install.stdout)); + let install_status = nixos_install.wait(); + println!("Exited with status {:?}", install_status); break } From 1498465df61bb5da86d0befadb522e5c8fce5ea8 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Fri, 11 Apr 2025 21:46:26 -0600 Subject: [PATCH 35/48] switch to using Command for mounting instead of the nix crate for now --- src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4b31ef4..c279f56 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,6 +96,7 @@ fn mount_root() { // 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"); @@ -221,8 +222,20 @@ fn main() { format_partitions(); // Mounting the partitions - mount_root(); - mount_boot(); + // 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(); From 5fe1bc8b44768c091fd90f62981405338da8a956 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sat, 12 Apr 2025 12:56:47 -0600 Subject: [PATCH 36/48] it works! now to clean up --- src/main.rs | 143 ++++++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 77 deletions(-) diff --git a/src/main.rs b/src/main.rs index c279f56..e7cd8b2 100644 --- a/src/main.rs +++ b/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() From d8865650417886d35cfb5e98b3ebdd9ddad7a7e8 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sat, 12 Apr 2025 13:57:56 -0600 Subject: [PATCH 37/48] clear out old code --- src/main.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/main.rs b/src/main.rs index e7cd8b2..4e8c056 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,19 +193,6 @@ fn main() { ) .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") @@ -226,13 +213,6 @@ fn main() { ) .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") @@ -240,7 +220,7 @@ fn main() { .expect("Failed to execute command"); // Copies the nix files to /mnt/etc/nixos/ - let nix_move = Command::new("mv") + let _nix_move = Command::new("mv") .args(["-f", "flake.nix", "configuration.nix", "home.nix", "/mnt/etc/nixos"]) .output() .expect("Failed to move nix files over"); From 74d52c4d075b77da35a4d3dbd4a13db6ab67cbba Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Mon, 14 Apr 2025 19:05:52 -0600 Subject: [PATCH 38/48] working logic with nvme --- src/main.rs | 100 +++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4e8c056..33c52a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,21 +54,61 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { Ok(()) } -fn format_partitions() { +fn format_partitions(drive_name: &str) { + let efi_number = "p1"; + let root_number = "p2"; + let efi_path = format!("{}p1", drive_name); + let root_path = format!("{}p2", drive_name); + let _efi_partition = Command::new("mkfs.fat") .arg("-F32") .arg("-n") .arg("EFI") - // Replace with non static variable - .arg("/dev/nvme1n1p1") + .arg(&efi_path) .output() - .expect("Failed to partition boot partition as FAT32"); + .expect("Failed to format boot partition as FAT32"); let _root_partition = Command::new("mkfs.ext4") - // Replace with non static variable - .arg("/dev/nvme1n1p2") + .arg(&root_path) .output() - .expect("Failed to partition root partition as ext4"); + .expect("Failed to format root partition as ext4"); +} + +fn mount_partitions(drive_name: &str) { + let efi_path = format!("{}p1", drive_name); + let root_path = format!("{}p2", drive_name); + + let root_source = Some(Path::new(&root_path)); + let root_target = Path::new("/mnt"); + + mount( + root_source, + root_target, + Some("ext4"), + MsFlags::empty(), + None::<&[u8]>, + ) + .expect("Failed to mount root partition"); + + // 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(&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"); } fn grab_flake() { @@ -167,52 +207,22 @@ fn main() { let drive_name = drive_name.trim(); - // Partitioning the selected drive - let _ = format_drive(drive_name); - - // Formatting the partitions - format_partitions(); - // Download nix files grab_flake(); grab_config(); grab_home(); grab_gnome(); + // Partitioning the selected drive + let _ = format_drive(drive_name); + + // Formatting the partitions + format_partitions(drive_name); + // 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"); - - // 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"); + mount_partitions(drive_name); + // Creates the init nix config in /mnt/etc/nixos let _nixos_gen_config = Command::new("nixos-generate-config") .arg("--root") .arg("/mnt") From 784a9df0ca831222997b34e3d8d4e43a70c12e96 Mon Sep 17 00:00:00 2001 From: "aaron.honeycutt" Date: Tue, 15 Apr 2025 08:09:23 -0600 Subject: [PATCH 39/48] add nix flake --- flake.nix | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..60a3ffd --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Nyxi Installer flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11"; + }; + + outputs = { nixpkgs, ... } @ inputs: + + let + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system; + }; + in + { + checks.x86_64-linux.unitTests = (with pkgs; stdenv.mkDerivation { + pname = "nyxi-installer"; + version = "2.0.0"; + src = builtins.fetchGit { + url = "https://gitlab.com/ahoneybun/nyxi-installer.git"; + ref = "rust-rewrite"; + rev = "a0c8dafe6186de0c6eebc68d413d08bccd4e2405"; + }; + + buildInputs = with pkgs; [ cargo rustc ]; + + buildPhase = '' + cargo test + ''; + + }); + + devShells.x86_64-linux.default = pkgs.mkShell { + buildInputs = with pkgs; [ + cargo + rustc + gnumake + clang + llvmPackages.libclang + llvmPackages.clang + + # System + btrfs-progs + e2fsprogs + openssl + pkg-config + util-linux + ]; + shellHook = '' + export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" + export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" + export RUST_BACKTRACE=1 + echo "Ready to make some Rust!" + ''; + }; + }; +} From 22a35cae0ce487245b0a068d6977bc0c58fc59c1 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 16 Apr 2025 06:34:16 -0600 Subject: [PATCH 40/48] Work on docs for development and splitting the README up --- README.md | 40 +++++++++++----------------------------- docs/development.md | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 docs/development.md diff --git a/README.md b/README.md index 04c0632..a664e69 100644 --- a/README.md +++ b/README.md @@ -16,34 +16,16 @@ This sets the hashedPassword to my own so you will need to update it to match yo mkpasswd -m sha-512 ``` +# Usage + +1. Boot from a live disk of NixOS (ideally the minimal image) +2. Connect to network +3. Download from the releases page using curl + +```bash +curl $PATH +``` + # Development -## Clone the repository - -```bash -git clone https://gitlab.com/ahoneybun/nyxi-installer.git -``` - -## Enter the repository that you just cloned - -```bash -cd nyxi-installer -``` - -## Enter nix-shell - -This is if you are already running NixOS on your system where development will take place. This will install the needed system packages, set environment variables and such for development. - -```bash -nix-shell -``` - -## Building and testing - -You can use normal `cargo` commands like: - -- `cargo test` -- `cargo build` -- `cargo run` - -**NOTE:** you will need to build the program and run it with `sudo` currently so `cargo run` is not the best for testing. +![docs/development](https://gitlab.com/ahoneybun/nyxi-installer/-/blob/rust-rewrite/docs/development.md) diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..68d2d5a --- /dev/null +++ b/docs/development.md @@ -0,0 +1,37 @@ +# Development + +## Clone the repository + +```bash +git clone https://gitlab.com/ahoneybun/nyxi-installer.git +``` + +## Enter the repository that you just cloned + +```bash +cd nyxi-installer +``` + +## Enter nix-shell + +This is if you are already running NixOS on your system where development will take place. This will install the needed system packages, set environment variables and such for development. + +```bash +nix-shell +``` + +## For distros like Ubuntu install these packages + +```bash +sudo apt install build-essential pkg-config libcurl4-openssl-dev libfdisk-dev +``` + +## Building and testing + +You can use normal `cargo` commands like: + +- `cargo test` +- `cargo build` +- `cargo run` + +**NOTE:** you will need to build the program and run it with `sudo` currently so `cargo run` is not the best for testing. From 7a28998b82bdac8659564e357f29e8e68107bcdf Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 16 Apr 2025 07:04:11 -0600 Subject: [PATCH 41/48] update docs/development --- docs/development.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/development.md b/docs/development.md index 68d2d5a..3bc6b7f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -14,13 +14,15 @@ cd nyxi-installer ## Enter nix-shell -This is if you are already running NixOS on your system where development will take place. This will install the needed system packages, set environment variables and such for development. +This is if you are already running NixOS or using the `nix` packagemanager on your system where development will take place. This will install the needed system packages, set environment variables and such for development. ```bash nix-shell ``` -## For distros like Ubuntu install these packages +## Ubuntu + +Install these packages for developing using `apt`. ```bash sudo apt install build-essential pkg-config libcurl4-openssl-dev libfdisk-dev From f134004ddbc51008976b2cf6a28acf368f39fdea Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Wed, 16 Apr 2025 20:39:37 -0600 Subject: [PATCH 42/48] remove unused variables --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 33c52a8..2bb35d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,8 +55,6 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { } fn format_partitions(drive_name: &str) { - let efi_number = "p1"; - let root_number = "p2"; let efi_path = format!("{}p1", drive_name); let root_path = format!("{}p2", drive_name); From fb3e99f8e45c2c68fac690c7433f36d9048b72c8 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 17 Apr 2025 12:49:52 -0600 Subject: [PATCH 43/48] better flake? --- .gitignore | 6 ++++ flake.lock | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 75 +++++++++++++++--------------------------- 3 files changed, 128 insertions(+), 49 deletions(-) create mode 100644 flake.lock diff --git a/.gitignore b/.gitignore index 34537f4..94eb0df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,14 @@ +# Rust/Carge /target + +# Nix +result + # Main nix files flake.nix configuration.nix home.nix + # Extra nix files garrus.nix gnome.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1d51da6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1743800763, + "narHash": "sha256-YFKV+fxEpMgP5VsUcM6Il28lI0NlpM7+oB1XxbBAYCw=", + "owner": "nix-community", + "repo": "naersk", + "rev": "ed0232117731a4c19d3ee93aa0c382a8fe754b01", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 60a3ffd..c4579d1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,58 +1,35 @@ { - description = "Nyxi Installer flake"; + description = "Flake to build and develop Nyxi"; inputs = { - nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.11"; + flake-utils.url = "github:numtide/flake-utils"; + naersk.url = "github:nix-community/naersk"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; - outputs = { nixpkgs, ... } @ inputs: - - let - system = "x86_64-linux"; - pkgs = import nixpkgs { - inherit system; - }; - in - { - checks.x86_64-linux.unitTests = (with pkgs; stdenv.mkDerivation { - pname = "nyxi-installer"; - version = "2.0.0"; - src = builtins.fetchGit { - url = "https://gitlab.com/ahoneybun/nyxi-installer.git"; - ref = "rust-rewrite"; - rev = "a0c8dafe6186de0c6eebc68d413d08bccd4e2405"; - }; + outputs = { self, flake-utils, naersk, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = (import nixpkgs) { + inherit system; + }; - buildInputs = with pkgs; [ cargo rustc ]; + naersk' = pkgs.callPackage naersk {}; - buildPhase = '' - cargo test - ''; + in rec { + # For `nix build` & `nix run`: + defaultPackage = naersk'.buildPackage { + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + buildInputs = with pkgs; [ pkg-config openssl ]; + nativeBuildInputs = with pkgs; [ util-linux.dev ]; + src = ./.; + }; - }); - - devShells.x86_64-linux.default = pkgs.mkShell { - buildInputs = with pkgs; [ - cargo - rustc - gnumake - clang - llvmPackages.libclang - llvmPackages.clang - - # System - btrfs-progs - e2fsprogs - openssl - pkg-config - util-linux - ]; - shellHook = '' - export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib" - export CLANG_PATH="${pkgs.llvmPackages.clang}/bin/clang" - export RUST_BACKTRACE=1 - echo "Ready to make some Rust!" - ''; - }; - }; + # For `nix develop` (optional, can be skipped): + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ rustc cargo ]; + }; + } + ); } From daa701753d8f0648b359b18e584968d367e91559 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 17 Apr 2025 12:57:41 -0600 Subject: [PATCH 44/48] nix develop works --- flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c4579d1..c6b4877 100644 --- a/flake.nix +++ b/flake.nix @@ -28,7 +28,10 @@ # For `nix develop` (optional, can be skipped): devShell = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ rustc cargo ]; + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + buildInputs = with pkgs; [ pkg-config openssl ]; + nativeBuildInputs = with pkgs; [ rustc cargo util-linux.dev ]; }; } ); From e2450857bed3bd001565edc4c14ba6fd0c7e5766 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Thu, 17 Apr 2025 13:04:57 -0600 Subject: [PATCH 45/48] clean up the flake a bit --- flake.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index c6b4877..b73e439 100644 --- a/flake.nix +++ b/flake.nix @@ -16,11 +16,14 @@ naersk' = pkgs.callPackage naersk {}; + # Setting variables that everything uses + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + in rec { # For `nix build` & `nix run`: defaultPackage = naersk'.buildPackage { - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + inherit LIBCLANG_PATH CLANG_PATH; buildInputs = with pkgs; [ pkg-config openssl ]; nativeBuildInputs = with pkgs; [ util-linux.dev ]; src = ./.; @@ -28,8 +31,7 @@ # For `nix develop` (optional, can be skipped): devShell = pkgs.mkShell { - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang"; + inherit LIBCLANG_PATH CLANG_PATH; buildInputs = with pkgs; [ pkg-config openssl ]; nativeBuildInputs = with pkgs; [ rustc cargo util-linux.dev ]; }; From 4dccfd16b14956b8af0f8945330e2b7bf9b1eda8 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sat, 19 Apr 2025 17:01:22 -0600 Subject: [PATCH 46/48] remove size_in_sectors for root partition as it completely fills the drive for the root partition --- src/main.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2bb35d6..c1b5ffc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,11 +40,6 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> { let root = Partition::builder() .partition_type(partition_type) .name("Root") - // Flash drive testing - //.size_in_sectors(121_634_816) - // Internal drive testing - .size_in_sectors(499_033_071_61) - // replace static int with a variable .build()?; let _ = disk.partition_add(root)?; From 0cd5007ae7e29e6c560bfdd92da56c5c4a8aaa6c Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sat, 19 Apr 2025 17:25:52 -0600 Subject: [PATCH 47/48] add boot permission fix --- src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main.rs b/src/main.rs index c1b5ffc..b51cf5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -228,6 +228,17 @@ fn main() { .output() .expect("Failed to move nix files over"); + // Fixes a security issue with boot + let _boot_fix = Command::new("sed") + .arg("-i") + .arg(r#"/fsType = "vfat"/ { + n + s/\(options = \[.*\)\]/\1"umask=0077 "]/ + }"#) + .arg("/mnt/etc/nixos/hardware-configuration.nix") + .output() + .expect("Failed to apply boot fix"); + // Host selection loop { println!(""); From c070fcac90f1bb8db33a5dba1d3942912672c686 Mon Sep 17 00:00:00 2001 From: Aaron Honeycutt Date: Sat, 19 Apr 2025 22:38:12 -0600 Subject: [PATCH 48/48] remove quit as it is after the formatting so pointless --- src/main.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index b51cf5c..16020b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -233,12 +233,12 @@ fn main() { .arg("-i") .arg(r#"/fsType = "vfat"/ { n - s/\(options = \[.*\)\]/\1"umask=0077 "]/ + s/\(options = \[.*\)\]/\1"umask=0077 "]/ }"#) .arg("/mnt/etc/nixos/hardware-configuration.nix") .output() .expect("Failed to apply boot fix"); - + // Host selection loop { println!(""); @@ -246,8 +246,7 @@ fn main() { println!("---------------"); println!(""); println!("1. Lemur Pro 13 (Garrus)"); - println!("2. Device 2"); - println!("3. Quit"); + println!("2. Generic"); println!(""); println!("Enter your host for installation:"); @@ -292,12 +291,20 @@ fn main() { break } "2" => { - println!("Nix the world!"); - }, - "3" => { - println!("Goodbye!"); + let mut nixos_install = Command::new("nixos-install") + .arg("--flake") + .arg("/mnt/etc/nixos#nixos") + .arg("--no-root-passwd") + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn() + .unwrap(); + + let install_status = nixos_install.wait(); + println!("Exited with status {:?}", install_status); + break; - }, + }, _ => println!("Invalid choice, try again."), } }