Compare commits

...

11 commits

Author SHA1 Message Date
Aaron Honeycutt
400b71ecde Merge branch 'rust-rewrite' into 'main'
Draft: First Rust rewrite release! 🎉

See merge request ahoneybun/nyxi-installer!23
2025-04-19 23:35:45 -06:00
Aaron Honeycutt
c070fcac90 remove quit as it is after the formatting so pointless 2025-04-19 22:38:12 -06:00
Aaron Honeycutt
0cd5007ae7 add boot permission fix 2025-04-19 22:12:53 -06:00
Aaron Honeycutt
4dccfd16b1 remove size_in_sectors for root partition as it completely fills the drive for the root partition 2025-04-19 17:01:22 -06:00
Aaron Honeycutt
e2450857be clean up the flake a bit 2025-04-17 13:04:57 -06:00
Aaron Honeycutt
daa701753d nix develop works 2025-04-17 12:57:41 -06:00
Aaron Honeycutt
fb3e99f8e4 better flake? 2025-04-17 12:55:26 -06:00
Aaron Honeycutt
f134004ddb remove unused variables 2025-04-16 20:39:37 -06:00
7a28998b82 update docs/development 2025-04-16 07:04:11 -06:00
22a35cae0c Work on docs for development and splitting the README up 2025-04-16 06:59:57 -06:00
aaron.honeycutt
784a9df0ca add nix flake 2025-04-15 08:09:23 -06:00
6 changed files with 217 additions and 43 deletions

6
.gitignore vendored
View file

@ -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

View file

@ -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)

39
docs/development.md Normal file
View file

@ -0,0 +1,39 @@
# 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
```
## 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 Normal file
View file

@ -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
}

40
flake.nix Normal file
View file

@ -0,0 +1,40 @@
{
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

@ -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)?;
@ -55,8 +50,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);
@ -235,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!("");
@ -242,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:");
@ -288,10 +291,18 @@ 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."),