diff options
| author | Preston Pan <ret2pop@gmail.com> | 2025-09-07 20:48:46 -0700 |
|---|---|---|
| committer | Preston Pan <ret2pop@gmail.com> | 2025-09-07 20:48:46 -0700 |
| commit | 5b8d09f2d7ebb7a1670c695af5761353d5b76d7e (patch) | |
| tree | 7cd2d1d4a30012e325c38d5bda65e83e6a48b5d6 /nix/systems | |
| parent | 5146b2fa654b469eaf425345797d58f0126de4b9 (diff) | |
create drive abstractions and entry points for disko
Diffstat (limited to 'nix/systems')
| -rw-r--r-- | nix/systems/affinity/default.nix | 6 | ||||
| -rw-r--r-- | nix/systems/continuity/default.nix | 9 | ||||
| -rw-r--r-- | nix/systems/includes.nix | 7 | ||||
| -rw-r--r-- | nix/systems/installer/commits.nix | 2 | ||||
| -rw-r--r-- | nix/systems/installer/default.nix | 41 | ||||
| -rw-r--r-- | nix/systems/spontaneity/default.nix | 6 |
6 files changed, 42 insertions, 29 deletions
diff --git a/nix/systems/affinity/default.nix b/nix/systems/affinity/default.nix index 7f1f29d..17f140a 100644 --- a/nix/systems/affinity/default.nix +++ b/nix/systems/affinity/default.nix @@ -1,12 +1,12 @@ { config, lib, home-manager, ... }: { imports = [ - ../../modules/default.nix - ../../disko/nvme-simple.nix - ../home.nix + ../includes.nix + ../../disko/drive-simple.nix ]; config = { monorepo = { + vars.device = "/dev/nvme0n1"; profiles = { server.enable = false; cuda.enable = true; diff --git a/nix/systems/continuity/default.nix b/nix/systems/continuity/default.nix index 4899804..5bd6517 100644 --- a/nix/systems/continuity/default.nix +++ b/nix/systems/continuity/default.nix @@ -1,8 +1,11 @@ { ... }: { imports = [ - ../../modules/default.nix - ../../disko/sda-simple.nix - ../home.nix + ../../disko/drive-simple.nix + ../includes.nix ]; + config = { + # drive to install to + monorepo.vars.device = "/dev/sda"; + }; } diff --git a/nix/systems/includes.nix b/nix/systems/includes.nix new file mode 100644 index 0000000..5122fb2 --- /dev/null +++ b/nix/systems/includes.nix @@ -0,0 +1,7 @@ +{ config, lib, ... }: +{ + imports = [ + ./home.nix + ../modules/default.nix + ]; +} diff --git a/nix/systems/installer/commits.nix b/nix/systems/installer/commits.nix index bf865a3..cce0b46 100644 --- a/nix/systems/installer/commits.nix +++ b/nix/systems/installer/commits.nix @@ -1,5 +1,5 @@ { diskoCommitHash = "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1"; - monorepoCommitHash = "af3c15c43c65fd77aab441f4c657aeaa74cc67d5"; + monorepoCommitHash = "8f4f46e59ad0b7c5662a417d10f3074f17c962c3"; monorepoUrl = "https://github.com/ret2pop/monorepo"; } diff --git a/nix/systems/installer/default.nix b/nix/systems/installer/default.nix index 75f0b81..a22b126 100644 --- a/nix/systems/installer/default.nix +++ b/nix/systems/installer/default.nix @@ -50,27 +50,27 @@ if [ "$(id -u)" -eq 0 ]; then exit 1 fi +cd "$HOME" + +ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui + gum style --border normal --margin "1" --padding "1 2" "Choose a system to install or select `new` in order to create a new system." -SYSTEM="$(gum choose "$(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New")")" +SYSTEM="$(gum choose $(find "$HOME/monorepo/nix/systems" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | grep -v -E 'installer'; printf "New"))" if [[ "$SYSTEM" == "New" ]]; then gum style --border normal --margin "1" --padding "1 2" "Choose a system name" SYSTEM="$(gum input --placeholder "system name")" -fi -gum style --border normal --margin "1" --padding "1 2" "Select a drive file or create a new drive file." -DRIVE="$(gum choose "$(find "$HOME/monorepo/nix/disko" -mindepth 1 -maxdepth 1 -type d -printf "%f\n" | printf "New")")" + gum style --border normal --margin "1" --padding "1 2" "Select a drive file or create a new drive file." + DRIVE="$(gum choose $(find "$HOME/monorepo/nix/disko" -mindepth 1 -maxdepth 1 -type f -printf "%f\n"; printf "New"))" -if [[ "$DRIVE" == "New" ]]; then - gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file." - SYSTEM="$(gum input --placeholder "drive file name (ex: my_sda.nix)")" + if [[ "$DRIVE" == "New" ]]; then + gum style --border normal --margin "1" --padding "1 2" "Choose a name to call your drive file." + DRIVE="$(gum input --placeholder "drive file name (ex: partition_scheme.nix)")" + fi fi -ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui - -cd "$HOME" - if [ ! -d "$HOME/monorepo/" ]; then git clone ${commits.monorepoUrl} cd "$HOME/monorepo" @@ -86,10 +86,11 @@ if [ ! -d "$HOME/monorepo/nix/systems/$SYSTEM" ]; then { ... }: { imports = [ - ../../modules/default.nix + ../includes.nix ../../disko/$DRIVE - ../home.nix ]; + # CHANGEME + config.monorepo.vars.drive = "/dev/sda"; } EOF @@ -97,10 +98,14 @@ EOF gum input --placeholder "Press Enter to continue" >/dev/null vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix" + gum style --border normal --margin "1" --padding "1 2" "Edit the home default.nix with options." + gum input --placeholder "Press Enter to continue" >/dev/null + vim "$HOME/monorepo/nix/systems/$SYSTEM/home.nix" + sed -i "/hostnames = \[/,/];/ { /];/i \ \"your-hostname-$SYSTEM\" }" "$HOME/monorepo/nix/flake.nix" if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then - cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE" + cp "$HOME/monorepo/nix/disko/drive-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE" gum style --border normal --margin "1" --padding "1 2" "Edit the drive file with your preferred partitioning scheme." gum input --placeholder "Press Enter to continue" >/dev/null vim "$HOME/monorepo/nix/disko/$DRIVE" @@ -108,10 +113,7 @@ EOF cd "$HOME/monorepo" && git add . && cd "$HOME" fi -if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE" ]; then - echo "error: you should create a new system if you use a drive file that is not in the repo." - exit 1 -fi +nix --extra-experimental-features 'nix-command flakes' eval "$HOME/monorepo/nix#evalDisko.$SYSTEM" > "$HOME/drive.nix" gum style --border normal --margin "1" --padding "1 2" "Formatting the drive is destructive!" if gum confirm "Are you sure you want to continue?"; then @@ -121,7 +123,8 @@ else exit 1 fi -sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE" +sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/drive.nix" + cd /mnt sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM" diff --git a/nix/systems/spontaneity/default.nix b/nix/systems/spontaneity/default.nix index 3aa0a39..5460428 100644 --- a/nix/systems/spontaneity/default.nix +++ b/nix/systems/spontaneity/default.nix @@ -1,14 +1,14 @@ { config, lib, ... }: { imports = [ + ../includes.nix # nixos-anywhere generates this file ./hardware-configuration.nix - ../../disko/vda-simple.nix - ../../modules/default.nix - ../home.nix + ../../disko/drive-bios.nix ]; config = { monorepo = { + vars.device = "/dev/vda"; profiles = { server.enable = true; ttyonly.enable = true; |
