]> Untitled Git - monorepo.git/commitdiff
fix installer to be more flexible to adding new systems
authorPreston Pan <ret2pop@gmail.com>
Fri, 5 Sep 2025 00:09:52 +0000 (17:09 -0700)
committerPreston Pan <ret2pop@gmail.com>
Fri, 5 Sep 2025 00:09:52 +0000 (17:09 -0700)
README.org
config/nix.org
nix/flake.nix
nix/systems/installer/default.nix

index b35246701e0186b05620447bcf3133aa41ec2d48..b71c14094e58194a95308e4ebf7264cde103d859 100644 (file)
@@ -18,15 +18,14 @@ https://ret2pop.nullring.xyz, it is the road to enlightenment.
 * Wait, so where are your dotfiles?
 To use my dotfiles, download the ISO image for the installer, log in, and run:
 #+begin_src bash
-  nmtui
-  git clone https://git.nullring.xyz/monorepo.git
-  # use vim to change whatever nix files you want
-  nix_installer
+  SYSTEM=continuity DRIVE=sda-simple nix_installer
 #+end_src
-That's it! If you want to install with all the default settings (look at them first), just run:
+then reboot, and run:
 #+begin_src bash
-  nix_installer
+  cd $HOME/monorepo && git pull
 #+end_src
-and it will work for you.
+** Post-setup
+In emacs, run ~M-x all-the-icons-install-fonts, ~~M-x nerd-icons-install-fonts~, and ~M-x org-roam-db-sync~. Install your music to ~$HOME/music~ for
+emms.
 * License
 See the [[file:LICENSE.org][license]]. The style.css has its own license.
index ef9574035f5f3fcd566e6bba7a12d7e00dc2bb4f..5fe96f17c22838d55d2a2e72b6ae3ccb020766cd 100644 (file)
@@ -93,6 +93,7 @@ so that adding new configurations that add modifications is made simple.
           };
         });
       in {
+        # add new systems here
         nixosConfigurations = builtins.listToAttrs (mkConfigs [
           "affinity"
           "continuity"
@@ -3276,26 +3277,81 @@ This contains the installation script I use to install my systems.
             ''
   #!/usr/bin/env bash
 
-  SYSTEM=continuity
-  DRIVE=sda
-
   set -euo pipefail
+
   if [ "$(id -u)" -eq 0 ]; then
     echo "ERROR! $(basename "$0") should be run as a regular user"
     exit 1
   fi
+
+  if [ -z "$SYSTEM" ]; then
+      SYSTEM=continuity
+  fi
+
+  if [ -z "$DRIVE" ]; then
+      DRIVE=sda-simple
+  fi
+
   ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
-  cd
+
+  cd "$HOME"
+
   if [ ! -d "$HOME/monorepo/" ]; then
     git clone https://git.nullring.xyz/monorepo.git
     cd monorepo
     git checkout "${commits.monorepoCommitHash}"
   fi
-  vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
-  sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE-simple.nix"
+
+
+  if [ ! -d "$HOME/monorepo/nix/systems/$SYSTEM" ]; then
+    mkdir -p "$HOME/monorepo/nix/systems/$SYSTEM"
+    cp "$HOME/monorepo/nix/systems/continuity/home.nix" "$HOME/monorepo/nix/systems/$SYSTEM/home.nix"
+    cat > "$HOME/monorepo/nix/systems/$SYSTEM/default.nix" <<EOF
+  { ... }:
+  {
+    imports = [
+      ../../modules/default.nix
+      ../../disko/$DRIVE.nix
+      ../home.nix
+    ];
+  }
+  EOF
+
+    gum style --border normal --margin "1" --padding "1 2" "Edit the system default.nix with options."
+    gum input --placeholder "Press Enter to continue" >/dev/null
+    vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
+
+    sed -i "/mkConfigs \[/,/\]/ s/^\(\s*\)\]/\1  \"$SYSTEM\"\n\1]/" "$HOME/monorepo/nix/flake.nix"
+  fi
+
+  if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE.nix" ]; then
+    cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE.nix"
+    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.nix"
+  fi
+
+  cd "$HOME/monorepo" && git add . && cd "$HOME"
+
+  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
+      echo "Proceeding..."
+  else
+      echo "Aborting."
+      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.nix"
   cd /mnt
   sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM"
-  sudo cp -r $HOME/monorepo "/mnt/home/$(ls /mnt/home/)/"
+
+  target_user="$(ls /mnt/home | head -n1)"
+  if [ -z "$target_user" ]; then
+      echo "No user directories found in /mnt/home"
+      exit 1
+  fi
+  sudo cp -r "$HOME/monorepo" "/mnt/home/$target_user/"
+
   echo "rebooting..."; sleep 3; reboot
   '')
         ];
index be9089f06918497ffe8c9a7045c387cce45cfbb7..4b08aa98a633ac56c102476d7907031623fd2004 100644 (file)
@@ -73,6 +73,7 @@
         };
       });
     in {
+      # add new systems here
       nixosConfigurations = builtins.listToAttrs (mkConfigs [
         "affinity"
         "continuity"
index 90a58db2ae5490ef4fed6d1d24078b3baf7c68d4..5541ecb62ddab5749bc0a69b0d561f0577e5f1e4 100644 (file)
@@ -43,26 +43,81 @@ in
           ''
 #!/usr/bin/env bash
 
-SYSTEM=continuity
-DRIVE=sda
-
 set -euo pipefail
+
 if [ "$(id -u)" -eq 0 ]; then
   echo "ERROR! $(basename "$0") should be run as a regular user"
   exit 1
 fi
+
+if [ -z "$SYSTEM" ]; then
+    SYSTEM=continuity
+fi
+
+if [ -z "$DRIVE" ]; then
+    DRIVE=sda-simple
+fi
+
 ping -q -c1 google.com &>/dev/null && echo "online! Proceeding with the installation..." || nmtui
-cd
+
+cd "$HOME"
+
 if [ ! -d "$HOME/monorepo/" ]; then
   git clone https://git.nullring.xyz/monorepo.git
   cd monorepo
   git checkout "${commits.monorepoCommitHash}"
 fi
-vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
-sudo nix --experimental-features "nix-command flakes" run "github:nix-community/disko/${commits.diskoCommitHash}" -- --mode destroy,format,mount "$HOME/monorepo/nix/disko/$DRIVE-simple.nix"
+
+
+if [ ! -d "$HOME/monorepo/nix/systems/$SYSTEM" ]; then
+  mkdir -p "$HOME/monorepo/nix/systems/$SYSTEM"
+  cp "$HOME/monorepo/nix/systems/continuity/home.nix" "$HOME/monorepo/nix/systems/$SYSTEM/home.nix"
+  cat > "$HOME/monorepo/nix/systems/$SYSTEM/default.nix" <<EOF
+{ ... }:
+{
+  imports = [
+    ../../modules/default.nix
+    ../../disko/$DRIVE.nix
+    ../home.nix
+  ];
+}
+EOF
+
+  gum style --border normal --margin "1" --padding "1 2" "Edit the system default.nix with options."
+  gum input --placeholder "Press Enter to continue" >/dev/null
+  vim "$HOME/monorepo/nix/systems/$SYSTEM/default.nix"
+
+  sed -i "/mkConfigs \[/,/\]/ s/^\(\s*\)\]/\1  \"$SYSTEM\"\n\1]/" "$HOME/monorepo/nix/flake.nix"
+fi
+
+if [ ! -f "$HOME/monorepo/nix/disko/$DRIVE.nix" ]; then
+  cp "$HOME/monorepo/nix/disko/sda-simple.nix" "$HOME/monorepo/nix/disko/$DRIVE.nix"
+  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.nix"
+fi
+
+cd "$HOME/monorepo" && git add . && cd "$HOME"
+
+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
+    echo "Proceeding..."
+else
+    echo "Aborting."
+    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.nix"
 cd /mnt
 sudo nixos-install --flake "$HOME/monorepo/nix#$SYSTEM"
-sudo cp -r $HOME/monorepo "/mnt/home/$(ls /mnt/home/)/"
+
+target_user="$(ls /mnt/home | head -n1)"
+if [ -z "$target_user" ]; then
+    echo "No user directories found in /mnt/home"
+    exit 1
+fi
+sudo cp -r "$HOME/monorepo" "/mnt/home/$target_user/"
+
 echo "rebooting..."; sleep 3; reboot
 '')
       ];