Compare commits

...

6 commits

Author SHA1 Message Date
Aaron Honeycutt
8ad801669a swap back to main 2025-04-23 18:38:37 -06:00
Aaron Honeycutt
679c998e84 add nix develop to docs 2025-04-22 12:37:14 -06:00
Aaron Honeycutt
125af53329 add steps for using the bash installer 2025-04-22 12:26:22 -06:00
Aaron Honeycutt
7ba1ccb07a use Command for mounting the boot partition due to mount options 2025-04-21 19:09:12 -06:00
Aaron Honeycutt
7408808467 make data dir for the nix files to not overwrite the flake 2025-04-21 18:02:33 -06:00
Aaron Honeycutt
40d030ae75 remove old comment 2025-04-21 12:44:31 -06:00
4 changed files with 122 additions and 81 deletions

8
.gitignore vendored
View file

@ -5,10 +5,4 @@
result
# Main nix files
flake.nix
configuration.nix
home.nix
# Extra nix files
garrus.nix
gnome.nix
/data

View file

@ -26,6 +26,12 @@ mkpasswd -m sha-512
curl $PATH
```
## Older Bash installer
```bash
sh <(curl -L https://gitlab.com/ahoneybun/nyxi-installer/-/raw/main/install.sh)
```
# Development
![docs/development](https://gitlab.com/ahoneybun/nyxi-installer/-/blob/rust-rewrite/docs/development.md)

View file

@ -20,6 +20,14 @@ This is if you are already running NixOS or using the `nix` packagemanager on yo
nix-shell
```
## Flakes
If you have flakes enabled you can use `nix develop` instead.
```bash
nix develop
```
## Ubuntu
Install these packages for developing using `apt`.

View file

@ -1,15 +1,15 @@
use rsfdisk::core::partition::{Guid, Partition, PartitionKind};
use rsfdisk::core::partition_table::PartitionTableKind;
use rsfdisk::fdisk::Fdisk;
use std::fs::File;
use std::io;
use std::io::Write;
use std::fs::File;
use std::process::{Command, Stdio};
use std::path::Path;
use std::process::{Command, Stdio};
use sys_metrics::disks;
use rsfdisk::fdisk::Fdisk;
use rsfdisk::core::partition_table::PartitionTableKind;
use rsfdisk::core::partition::{Guid, Partition, PartitionKind};
use nix::mount::{mount, MsFlags};
use curl::easy::Easy;
use nix::mount::{mount, MsFlags};
fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
let mut disk = Fdisk::builder()
@ -20,9 +20,7 @@ fn format_drive(drive_name: &str) -> rsfdisk::Result<()> {
disk.partition_table_create(PartitionTableKind::GPT)?;
let partition_type = PartitionKind::builder()
.guid(Guid::EfiSystem)
.build()?;
let partition_type = PartitionKind::builder().guid(Guid::EfiSystem).build()?;
let boot = Partition::builder()
.partition_type(partition_type)
@ -90,80 +88,100 @@ fn mount_partitions(drive_name: &str) {
.output()
.expect("Failed to create boot directory");
// replace static path with a variable
let boot_source = Some(Path::new(&efi_path));
let boot_target = Path::new("/mnt/boot");
mount(
boot_source,
boot_target,
Some("vfat"),
MsFlags::empty(),
None::<&[u8]>,
)
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/rust-rewrite/flake.nix").unwrap();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/flake.nix")
.unwrap();
let mut file = File::create("flake.nix").unwrap();
let mut file = File::create("data/flake.nix").unwrap();
{
let mut transfer = easy.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.unwrap();
transfer.perform().unwrap();
}
}
fn grab_config() {
let mut easy = Easy::new();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/configuration.nix").unwrap();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/configuration.nix")
.unwrap();
let mut file = File::create("configuration.nix").unwrap();
let mut file = File::create("data/configuration.nix").unwrap();
{
let mut transfer = easy.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.unwrap();
transfer.perform().unwrap();
}
}
fn grab_home() {
let mut easy = Easy::new();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/rust-rewrite/home.nix").unwrap();
easy.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/home.nix")
.unwrap();
let mut file = File::create("home.nix").unwrap();
let mut file = File::create("data/home.nix").unwrap();
{
let mut transfer = easy.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.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();
gnome_config
.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/desktops/gnome.nix")
.unwrap();
let mut config_file = File::create("gnome.nix").unwrap();
let mut config_file = File::create("data/gnome.nix").unwrap();
{
let mut transfer = gnome_config.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
config_file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.unwrap();
transfer.perform().unwrap();
}
}
@ -192,7 +210,10 @@ fn main() {
println!("");
println!("Use the full drive path such as /dev/nvme0n1 or /dev/sda");
println!("");
println!("Which drive do we want to use for this installation?: {}", drive_name);
println!(
"Which drive do we want to use for this installation?: {}",
drive_name
);
io::stdin()
.read_line(&mut drive_name)
@ -224,17 +245,25 @@ fn main() {
// Copies the nix files to /mnt/etc/nixos/
let _nix_move = Command::new("mv")
.args(["-f", "flake.nix", "configuration.nix", "home.nix", "/mnt/etc/nixos"])
.args([
"-f",
"data/flake.nix",
"data/configuration.nix",
"data/home.nix",
])
.arg("/mnt/etc/nixos")
.output()
.expect("Failed to move nix files over");
// Fixes a security issue with boot
let _boot_fix = Command::new("sed")
.arg("-i")
.arg(r#"/fsType = "vfat"/ {
.arg(
r#"/fsType = "vfat"/ {
n
s/\(options = \[.*\)\]/\1"umask=0077 "]/
}"#)
}"#,
)
.arg("/mnt/etc/nixos/hardware-configuration.nix")
.output()
.expect("Failed to apply boot fix");
@ -260,20 +289,22 @@ fn main() {
let mut garrus_config = Easy::new();
garrus_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/garrus/configuration.nix").unwrap();
let mut config_file = File::create("garrus.nix").unwrap();
let mut config_file = File::create("data/garrus.nix").unwrap();
{
let mut transfer = garrus_config.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
config_file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.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"])
.args(["data/garrus.nix", "data/gnome.nix", "/mnt/etc/nixos"])
.output()
.expect("Failed to copy nix files over");
@ -289,26 +320,28 @@ fn main() {
let install_status = nixos_install.wait();
println!("Exited with status {:?}", install_status);
break
},
break;
}
"2" => {
let mut vm_config = Easy::new();
vm_config.url("https://gitlab.com/ahoneybun/nix-configs/-/raw/main/hosts/x86_64/vm/configuration.nix").unwrap();
let mut config_file = File::create("vm.nix").unwrap();
let mut config_file = File::create("data/vm.nix").unwrap();
{
let mut transfer = vm_config.transfer();
transfer.write_function(|data| {
transfer
.write_function(|data| {
config_file.write_all(data).unwrap();
Ok(data.len())
}).unwrap();
})
.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"])
.args(["data/vm.nix", "/mnt/etc/nixos"])
.output()
.expect("Failed to copy nix files over");
@ -340,7 +373,7 @@ fn main() {
println!("Exited with status {:?}", install_status);
break;
},
}
_ => println!("Invalid choice, try again."),
}
}