Compare commits

..

No commits in common. "main" and "v1.2.0" have entirely different histories.
main ... v1.2.0

16 changed files with 198 additions and 1522 deletions

8
.gitignore vendored
View file

@ -1,8 +0,0 @@
# Rust/Carge
/target
# Nix
result
# Main nix files
/data

View file

@ -1,81 +1,12 @@
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- prepare
- test
- build
- release
prepare-job:
stage: prepare
image: rust
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- echo "======== PREPARE JOB ========"
- echo "PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml)" >> variables.env
- echo "PKG_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic" >> variables.env
- echo $PKG_VERSION
artifacts:
reports:
dotenv: variables.env
test-job:
- test
sast:
stage: test
image: rust:latest
script:
- echo "======== TESTS JOB ========"
- apt update -m
- apt install -y libfdisk-dev libclang-19-dev
- cargo test --verbose
build-job:
stage: build
image: rust:latest
script:
- echo "======== BUILD JOB ========"
- apt update -m
- apt install -y libfdisk-dev libclang-19-dev
- cargo build --release
- mkdir bin
- mv /builds/ahoneybun/nyxi-installer/target/release/nyxi-installer bin/nyxi-installer-v${PKG_VERSION}
artifacts:
paths:
- bin/
release-job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prepare-job
artifacts: true
- job: build-job
script:
- echo "======== RELEASE JOB ========"
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
release:
tag_name: "v$PKG_VERSION"
description: "NixOS installer in Rust : v$PKG_VERSION"
ref: "$CI_COMMIT_SHA" # The tag is created from the pipeline SHA.
assets:
links:
- name: "v$PKG_VERSION"
url: "${PKG_REGISTRY_URL}/x86_64-unknown-linux-gnu/v${PKG_VERSION}/nyxi-installer"
upload-job:
stage: release
image: curlimages/curl:latest
needs:
- job: prepare-job
artifacts: true
- job: build-job
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- echo "======== UPLOAD JOB ========"
- ls -la bin/
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/nyxi-installer-v${PKG_VERSION} ${PKG_REGISTRY_URL}/x86_64-unknown-linux-gnu/v${PKG_VERSION}/nyxi-installer'
include:
- template: Security/SAST.gitlab-ci.yml

758
Cargo.lock generated
View file

@ -1,758 +0,0 @@
# This file is automatically @generated by Cargo.
# 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 = "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"
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 0.59.0",
]
[[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 0.59.0",
]
[[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"
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 = "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 = "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"
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"
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 = "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 = [
"curl",
"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 = "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"
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"
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 = "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 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]]
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 2.0.100",
]
[[package]]
name = "shlex"
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"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[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 = "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 = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[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.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"
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",
]

View file

@ -1,10 +0,0 @@
[package]
name = "nyxi-installer"
version = "2.0.2"
edition = "2021"
[dependencies]
curl = "0.4.47"
nix = { version = "0.29.0", features = ["mount"] }
rsfdisk = "0.1.0"
sys_metrics = "0.2.7"

View file

@ -4,34 +4,55 @@ This installer is named after my doggo Onyxia.
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
- Partition the drive of your choice
- Installs a base of NixOS (`configuration.nix`)
- Installs Plasma (`plasma.nix`)
- Installs needed packages (`programs.nix`)
nix files are from [this repo](https://gitlab.com/ahoneybun/nix-configs/) but that can be changed as needed.
Tested on the following drives:
- SATA
- NVMe
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
```
sudo mkpasswd -m sha-512
```
# Usage
## Get Started
1. Boot from a live disk of NixOS (ideally the minimal image)
2. Connect to network
3. Download from the releases page using curl
Prerequisites:
```bash
curl $PATH
- Prepare an installation medium.
- Boot the live environment.
- Connect to internet.
## Connect to internet
https://nixos.org/manual/nixos/stable/index.html#sec-installation-booting-networking
## Start the installer
```
curl https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh > install.sh; sh install.sh
```
## Older Bash installer
The following will happen:
```bash
sh <(curl -L https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh)
```
- Clear partition table for `/dev/***`.
- Creates a GPT partition table for `/dev/***`.
- Create a +512M EFI partiton at `/dev/***1`.
- Create a encrypted LVM at `/dev/***2`.
- Create a swap partition in the LVM and sets it as the same size as the RAM for hibernation if requested.
- Create a root partition in the LVM.
- Install systemd-boot.
# Development
## Roadmap
![docs/development](https://gitlab.com/ahoneybun/nyxi-installer/-/blob/rust-rewrite/docs/development.md)
- [ ]
# Possible Ideas
- [ ]

View file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

View file

@ -1,47 +0,0 @@
# 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 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
```
## Flakes
If you have flakes enabled you can use `nix develop` instead.
```bash
nix develop
```
## Ubuntu
Install these packages for developing using `apt`.
```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.

96
flake.lock generated
View file

@ -1,96 +0,0 @@
{
"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
}

View file

@ -1,40 +0,0 @@
{
description = "Flake to build and develop Nyxi";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, flake-utils, naersk, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
};
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 {
inherit LIBCLANG_PATH CLANG_PATH;
buildInputs = with pkgs; [ pkg-config openssl ];
nativeBuildInputs = with pkgs; [ util-linux.dev ];
src = ./.;
};
# 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 ];
};
}
);
}

View file

@ -1,80 +1,155 @@
# Step 1: Choosing the drive for the installation
# Figure out how much RAM the system has an set a variable
ramTotal=$(free -h | awk '/^Mem:/{print $2}'| awk -FG {'print$1'})
## Detect and list the drives.
# Detect and list the drives.
lsblk -f
## Choice the drive to use :
# Choice the drive to use :
# 1.
echo "----------"
echo ""
echo "Which drive do we want to use for this installation?"
echo "For example /dev/sda or /dev/nvme0n1"
read driveName
(
echo g # Create new GPT partition table
echo n # Create new partition (for EFI).
echo # Set default partition number.
echo # Set default first sector.
echo +512M # Set +512M as last sector.
echo n # Create new partition (for root).
echo # Set default partition number.
echo # Set default first sector.
echo n # Create new partition (for swap).
echo # Set default partition number.
echo # Set default first sector.
echo # Set default last sector (rest of the disk).
echo t # Change partition type.
echo 1 # Pick first partition.
echo 1 # Change first partition to EFI system.
echo w # write changes.
) | sudo fdisk $driveName -w always -W always
# List the new partitions.
lsblk -f
# Format the partitions :
echo "----------"
echo ""
echo "Which is the EFI partition?"
read efiName
echo ""
read -p "Enter your drive choice: " driveName
echo ""
## Download Disko file
cd /tmp
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/partitions/luks-btrfs-subvolumes.nix -o /tmp/disko-config.nix
## Replace drive in Disko file
sudo sed -i "s#/dev/sda#$driveName#g" /tmp/disko-config.nix
# Step 2: Partitioning the drive used for the installation
## Run Disko to partition the disk
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount /tmp/disko-config.nix --yes-wipe-all-disks
## Generate Nix configuration
sudo nixos-generate-config --no-filesystems --root /mnt
## Copies over the disko file for running `nixos-install`
sudo mv /tmp/disko-config.nix /mnt/etc/nixos
## Downloads and places the predefinded generic flake to use
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix > flake.nix; sudo mv -f flake.nix /mnt/etc/nixos/
## Downloads and places the predefinded generic configuration and home files to use
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix > configuration.nix; sudo mv -f configuration.nix /mnt/etc/nixos/
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix > home.nix; sudo mv -f home.nix /mnt/etc/nixos/
# Step 3: Choosing a predefined system flake file to use
cat << EOF
Which device are you installing to?
1) Virtual Machine
2) Lemur Pro 13 (Garrus)
3) Pixel Slate
4) nebula49 (Shepard)
0) Generic
EOF
echo "Which is the root partition?"
read rootName
echo ""
read -p "Enter your device choice: " hostChoice
echo ""
echo "Do you want Hibernation?"
echo "1) Yes"
echo "2) No"
read hibState
if [ $hostChoice = 1 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/vm/configuration.nix > vm.nix; sudo mv -f vm.nix /mnt/etc/nixos/
sudo nixos-install --flake /mnt/etc/nixos#vm
# Create EFI partition
sudo mkfs.fat -F32 -n EFI $efiName
elif [ $hostChoice = 2 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix > garrus.nix; sudo mv -f garrus.nix /mnt/etc/nixos/
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix > gnome.nix; sudo mv -f gnome.nix /mnt/etc/nixos/
sudo nixos-install --flake /mnt/etc/nixos#garrus
# Encrypt the root partition
sudo cryptsetup luksFormat -v -s 512 -h sha512 $rootName
elif [ $hostChoice = 3 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/pixel-slate.nix > pixel-slate.nix; sudo mv -f pixel-slate.nix /mnt/etc/nixos/
#curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/lomiri.nix > gnome.nix; sudo mv -f gnome.nix /mnt/etc/nixos/
sudo nixos-install --flake /mnt/etc/nixos#pixel-slate
# Open the encrypted root partition
sudo cryptsetup luksOpen $rootName crypt-root
elif [ $hostChoice = 4 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/shepard/configuration.nix > shepard.nix; sudo mv -f shepard.nix /mnt/etc/nixos/
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix > gnome.nix; sudo mv -f gnome.nix /mnt/etc/nixos/
sudo nixos-install --flake /mnt/etc/nixos#shepard
sudo pvcreate /dev/mapper/crypt-root
sudo vgcreate lvm /dev/mapper/crypt-root
elif [ $hostChoice = 0 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix > flake.nix; sudo mv -f flake.nix /mnt/etc/nixos/
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix > gnome.nix; sudo mv -f gnome.nix /mnt/etc/nixos/
sudo nixos-install --flake /mnt/etc/nixos#nixos
if [ $hibState = 1 ]; then
sudo lvcreate -L "$ramTotal"G -n swap lvm
else
if [ $hibState = 2 ]; then
sudo lvcreate -L 4G -n swap lvm
fi
fi
sudo lvcreate -l '100%FREE' -n root lvm
# sudo btrfs filesystem label $rootName luks
# sudo cryptsetup config $rootName --label luks
sudo mkswap /dev/lvm/swap # swap partition
sudo mkfs.btrfs -L root /dev/lvm/root # /root partition
# 0. Mount the filesystems.
sudo swapon /dev/lvm/swap
sudo mount /dev/lvm/root /mnt
# Create Subvolumes
sudo btrfs subvolume create /mnt/@
sudo btrfs subvolume create /mnt/@home
# Unmount root
sudo umount /mnt
# Mount the subvolumes.
sudo mount -o noatime,commit=120,compress=zstd:10,subvol=@ /dev/lvm/root /mnt
sudo mkdir /mnt/home/
sudo mount -o noatime,commit=120,compress=zstd:10,subvol=@home /dev/lvm/root /mnt/home
# Mount the EFI partition.
sudo mkdir /mnt/boot/
sudo mount $efiName /mnt/boot
# Generate Nix configuration
sudo nixos-generate-config --root /mnt
# Copy my nix configs over
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix > configuration.nix; sudo mv -f configuration.nix /mnt/etc/nixos/
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/programs.nix > programs.nix; sudo mv -f programs.nix /mnt/etc/nixos/
echo ""
echo "Which Desktop Environment do you want?"
echo "1) Plasma"
echo "2) GNOME"
read desktopChoice
if [ $desktopChoice = 1 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/plasma.nix > plasma.nix; sudo mv -f plasma.nix /mnt/etc/nixos/
sudo sed -i "10 i \ ./plasma.nix" /mnt/etc/nixos/configuration.nix
else
if [ $desktopChoice = 2 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/gnome.nix > gnome.nix; sudo mv -f gnome.nix /mnt/etc/nixos/
sudo sed -i "10 i \ ./gnome.nix" /mnt/etc/nixos/configuration.nix
fi
fi
echo ""
echo "Which device are you installing to?"
echo "1) Oryx Pro (oryp6)"
echo "2) HP Omen (15-dh0015nr)"
read device
if [ $device = 1 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/systems/oryp6.nix > oryp6.nix; sudo mv -f oryp6.nix /mnt/etc/nixos/
sudo sed -i "10 i \ ./oryp6.nix" /mnt/etc/nixos/configuration.nix
else
if [ $device = 2 ]; then
curl https://gitlab.com/ahoneybun/nix-configs/-/raw/main/systems/hp-omen.nix > hp-omen.nix; sudo mv -f hp-omen.nix /mnt/etc/nixos/
sudo sed -i "11 i \ ./hp-omen.nix" /mnt/etc/nixos/configuration.nix
fi
fi
# Replace LUKS device with correct partition
sudo sed -i "s|/dev/disk/by-label/luks|$rootName|g" /mnt/etc/nixos/configuration.nix
# Install
sudo nixos-install
# Removed install script.
rm install.sh

12
setup.sh Normal file
View file

@ -0,0 +1,12 @@
# Set user password
echo "----------"
echo ""
echo "Which is the username?"
read userName
sudo passwd $userName
# Create Directories
mkdir /home/$userName/Projects
exit

View file

@ -1,29 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
# Rust
cargo
rustc
# Compiler
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 "We're ready to make some Rust!"
'';
}

View file

@ -1,375 +0,0 @@
use rsfdisk::core::partition::{Guid, Partition, PartitionKind};
use rsfdisk::core::partition_table::PartitionTableKind;
use rsfdisk::fdisk::Fdisk;
use std::fs::File;
use std::io;
use std::io::Write;
use std::path::Path;
use std::process::{Command, Stdio};
use sys_metrics::disks;
use curl::easy::Easy;
use nix::mount::{mount, MsFlags};
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::EfiSystem).build()?;
let boot = Partition::builder()
.partition_type(partition_type)
.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 partition_type = PartitionKind::builder()
.guid(Guid::LinuxRootx86_64)
.build()?;
let root = Partition::builder()
.partition_type(partition_type)
.name("Root")
.build()?;
let _ = disk.partition_add(root)?;
disk.partition_table_write_to_disk()?;
Ok(())
}
fn format_partitions(drive_name: &str) {
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")
.arg(&efi_path)
.output()
.expect("Failed to format boot partition as FAT32");
let _root_partition = Command::new("mkfs.ext4")
.arg(&root_path)
.output()
.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");
//let boot_source = Some(Path::new(&efi_path));
//let boot_target = Path::new("/mnt/boot");
let _mount_boot = Command::new("mount")
.args(["-t", "vfat"])
.args(["-o", "umask=0077"])
.arg(&efi_path)
.arg("/mnt/boot")
.output()
.expect("Failed to mount boot partition");
// mount(
// boot_source,
// boot_target,
// Some("vfat"),
// MsFlags::empty(),
// None::<&[u8]>,
// )
// .expect("Failed to mount boot partition");
}
fn grab_flake() {
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 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! |");
println!("--------------------------------------");
println!("");
println!("Availble disks for installation:");
println!("---------------------------------");
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!("Use the full drive path such as /dev/nvme0n1 or /dev/sda");
println!("");
println!(
"Which drive do we want to use for this installation?: {}",
drive_name
);
io::stdin()
.read_line(&mut drive_name)
.expect("Failed to read line");
let drive_name = drive_name.trim();
// 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
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")
.output()
.expect("Failed to execute command");
// Copies the nix files to /mnt/etc/nixos/
let _nix_move = Command::new("mv")
.args(["-f", "flake.nix", "configuration.nix", "home.nix"])
.arg("/mnt/etc/nixos")
.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!("");
println!("Host selection:");
println!("---------------");
println!("");
println!("1. Lemur Pro 13 (Garrus)");
println!("2. Virtual Machine");
println!("3. Generic");
println!("");
println!("Enter your host for installation:");
let mut choice = String::new();
io::stdin().read_line(&mut choice).unwrap();
match choice.trim() {
"1" => {
let mut garrus_config = Easy::new();
garrus_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix").unwrap();
let mut config_file = File::create("garrus.nix").unwrap();
{
let mut transfer = garrus_config.transfer();
transfer
.write_function(|data| {
config_file.write_all(data).unwrap();
Ok(data.len())
})
.unwrap();
transfer.perform().unwrap();
}
// Copies the system nix files to /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()
.unwrap();
let install_status = nixos_install.wait();
println!("Exited with status {:?}", install_status);
break;
}
"2" => {
let mut vm_config = Easy::new();
vm_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/vm/configuration.nix").unwrap();
let mut config_file = File::create("vm.nix").unwrap();
{
let mut transfer = vm_config.transfer();
transfer
.write_function(|data| {
config_file.write_all(data).unwrap();
Ok(data.len())
})
.unwrap();
transfer.perform().unwrap();
}
// Copies the system nix files to /mnt/etc/nixos/
let _garrus_nix_copy = Command::new("mv")
.args(["vm.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#vm")
.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;
}
"3" => {
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."),
}
}
}