mirror of
https://gitlab.com/ahoneybun/nyxi-installer.git
synced 2025-05-12 11:04:02 -06:00
Merge branch 'feat-encrypt' into 'main'
Draft: Feat encrypt See merge request ahoneybun/nyxi-installer!26
This commit is contained in:
commit
d1c99583ca
5 changed files with 168 additions and 10 deletions
|
@ -25,7 +25,7 @@ test-job:
|
|||
script:
|
||||
- echo "======== TESTS JOB ========"
|
||||
- apt update -m
|
||||
- apt install -y libfdisk-dev libclang-19-dev
|
||||
- apt install -y libfdisk-dev libcryptsetup-dev libclang-19-dev
|
||||
- cargo test --verbose
|
||||
|
||||
build-job:
|
||||
|
@ -34,7 +34,7 @@ build-job:
|
|||
script:
|
||||
- echo "======== BUILD JOB ========"
|
||||
- apt update -m
|
||||
- apt install -y libfdisk-dev libclang-19-dev
|
||||
- apt install -y libfdisk-dev libcryptsetup-dev libclang-19-dev
|
||||
- cargo build --release
|
||||
- mkdir bin
|
||||
- mv /builds/ahoneybun/nyxi-installer/target/release/nyxi-installer bin/nyxi-installer-v${PKG_VERSION}
|
||||
|
|
141
Cargo.lock
generated
141
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
|
@ -40,6 +40,26 @@ dependencies = [
|
|||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.69.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.0"
|
||||
|
@ -177,6 +197,18 @@ dependencies = [
|
|||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.2"
|
||||
|
@ -218,6 +250,21 @@ dependencies = [
|
|||
"mach2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
|
@ -236,6 +283,36 @@ version = "0.2.171"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
||||
|
||||
[[package]]
|
||||
name = "libcryptsetup-rs"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "186b5b6114517ab1d6e25741c6fb21060aae750e70868842efc9dd1efd08baa1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"either",
|
||||
"libc",
|
||||
"libcryptsetup-rs-sys",
|
||||
"log",
|
||||
"once_cell",
|
||||
"pkg-config",
|
||||
"semver",
|
||||
"serde_json",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libcryptsetup-rs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9a8d4249cffb7f410f5e32852c44a233b4d5a3815de0ec4833baab9e3edcc83"
|
||||
dependencies = [
|
||||
"bindgen 0.69.5",
|
||||
"cc",
|
||||
"pkg-config",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.6"
|
||||
|
@ -345,9 +422,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nyxi-installer"
|
||||
version = "2.0.0"
|
||||
version = "2.1.0"
|
||||
dependencies = [
|
||||
"curl",
|
||||
"libcryptsetup-rs",
|
||||
"nix",
|
||||
"rsfdisk",
|
||||
"sys_metrics",
|
||||
|
@ -426,6 +504,12 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
|
@ -479,7 +563,7 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39b186475d9df76290bba3de5196eeed64b95e77861095ea8b244f962f47575"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bindgen 0.66.1",
|
||||
"cc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
@ -503,6 +587,12 @@ dependencies = [
|
|||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.27"
|
||||
|
@ -512,6 +602,12 @@ dependencies = [
|
|||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.219"
|
||||
|
@ -532,6 +628,18 @@ dependencies = [
|
|||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
|
@ -648,12 +756,30 @@ version = "1.0.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.2+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
|
@ -756,3 +882,12 @@ checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36"
|
|||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
[package]
|
||||
name = "nyxi-installer"
|
||||
version = "2.0.2"
|
||||
version = "2.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
curl = "0.4.47"
|
||||
libcryptsetup-rs = "0.12.0"
|
||||
nix = { version = "0.29.0", features = ["mount"] }
|
||||
rsfdisk = "0.1.0"
|
||||
sys_metrics = "0.2.7"
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
# Setting variables that everything uses
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
CLANG_PATH = "${pkgs.llvmPackages.clang}/bin/clang";
|
||||
CRYPTSETUP_PATH = "${pkgs.cryptsetup.dev}/lib/pkgconfig";
|
||||
|
||||
in rec {
|
||||
|
||||
# For `nix build` & `nix run`:
|
||||
defaultPackage = naersk'.buildPackage {
|
||||
inherit LIBCLANG_PATH CLANG_PATH;
|
||||
|
@ -32,8 +34,8 @@
|
|||
# For `nix develop` (optional, can be skipped):
|
||||
devShell = pkgs.mkShell {
|
||||
inherit LIBCLANG_PATH CLANG_PATH;
|
||||
buildInputs = with pkgs; [ pkg-config openssl ];
|
||||
nativeBuildInputs = with pkgs; [ rustc cargo util-linux.dev ];
|
||||
buildInputs = with pkgs; [ openssl cryptsetup.dev ];
|
||||
nativeBuildInputs = with pkgs; [ rustc cargo pkg-config util-linux.dev ];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -47,10 +47,21 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn format_partitions(drive_name: &str) {
|
||||
fn encrypt(drive_name: &str) {
|
||||
let efi_path = format!("{}p1", drive_name);
|
||||
let root_path = format!("{}p2", drive_name);
|
||||
|
||||
//sudo cryptsetup luksFormat -v -s 512 -h sha512 $rootName
|
||||
let _luks_format = Command::new("cryptsetup")
|
||||
.args(["luksFormat", "-v", "-s", "512", "-h", "sha512"])
|
||||
.arg(&root_path)
|
||||
.output()
|
||||
.expect("Failed to run luksFomat");
|
||||
}
|
||||
|
||||
fn format_boot(drive_name: &str) {
|
||||
let efi_path = format!("{}p1", drive_name);
|
||||
|
||||
let _efi_partition = Command::new("mkfs.fat")
|
||||
.arg("-F32")
|
||||
.arg("-n")
|
||||
|
@ -58,6 +69,10 @@ fn format_partitions(drive_name: &str) {
|
|||
.arg(&efi_path)
|
||||
.output()
|
||||
.expect("Failed to format boot partition as FAT32");
|
||||
}
|
||||
|
||||
fn format_root(drive_name: &str) {
|
||||
let root_path = format!("{}p2", drive_name);
|
||||
|
||||
let _root_partition = Command::new("mkfs.ext4")
|
||||
.arg(&root_path)
|
||||
|
@ -228,10 +243,15 @@ fn main() {
|
|||
grab_gnome();
|
||||
|
||||
// Partitioning the selected drive
|
||||
//let _ = format_drive(drive_name);
|
||||
|
||||
let _ = format_drive(drive_name);
|
||||
|
||||
// Formatting the partitions
|
||||
format_partitions(drive_name);
|
||||
format_boot(drive_name);
|
||||
//format_root(drive_name);
|
||||
|
||||
encrypt(drive_name);
|
||||
|
||||
// Mounting the partitions
|
||||
mount_partitions(drive_name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue