]> Untitled Git - monorepo.git/commitdiff
create drive abstractions and entry points for disko
authorPreston Pan <ret2pop@gmail.com>
Mon, 8 Sep 2025 03:48:46 +0000 (20:48 -0700)
committerPreston Pan <ret2pop@gmail.com>
Mon, 8 Sep 2025 03:48:46 +0000 (20:48 -0700)
18 files changed:
config/nix.org
nix/disko/drive-bios.nix [new file with mode: 0644]
nix/disko/drive-simple.nix [new file with mode: 0644]
nix/disko/nvme-simple.nix [deleted file]
nix/disko/sda-simple.nix [deleted file]
nix/disko/vda-simple.nix [deleted file]
nix/flake.lock
nix/flake.nix
nix/modules/home/default.nix
nix/modules/home/user.nix
nix/modules/home/zsh.nix
nix/modules/vars.nix
nix/systems/affinity/default.nix
nix/systems/continuity/default.nix
nix/systems/includes.nix [new file with mode: 0644]
nix/systems/installer/commits.nix
nix/systems/installer/default.nix
nix/systems/spontaneity/default.nix

index f9997013d4adecf90b1fe995645bed61cb85dcac..f9247e98194f5f7f567b1ee87310f8aac1d6ac8d 100644 (file)
@@ -5,7 +5,7 @@
 
 * Introduction
 This is my NixOS configuration. It is a part of my monorepo, and this file automatically tangles
-to all the under the nix/ directory in my monorepo [[https://git.nullring.xyz/monorepo.git][git repository]]. My monorepo also stores my
+to all the under the nix/ directory in my monorepo [[https://ret2pop.net/gitweb/monorepo.git][git repository]]. My monorepo also stores my
 website, as my website stores my [[file:elfeed.org][elfeed]] and [[file:emacs.org][emacs]] configurations. Additionally, I want to track
 my emacs configuration with my Nix configuration. Having them in one repository means that my
 emacs configuration is pinned to my flake.
@@ -62,13 +62,19 @@ so that adding new configurations that add modifications is made simple.
           "spontaneity"
           # add hostnames here
         ];
+
         system = "x86_64-linux";
+
         pkgs = import nixpkgs { inherit system; };
+
         generate = nixos-dns.utils.generate nixpkgs.legacyPackages."${system}";
+
         dnsConfig = {
           inherit (self) nixosConfigurations;
           extraConfig = import ./dns/default.nix;
         };
+
+        # function that generates all systems from hostnames
         mkConfigs = map (hostname: {name = "${hostname}";
           value = nixpkgs.lib.nixosSystem {
             inherit system;
@@ -98,10 +104,17 @@ so that adding new configurations that add modifications is made simple.
             ];
           };
         });
+
+        mkDiskoFiles = map (hostname: {
+          name = "${hostname}";
+          value = self.nixosConfigurations."${hostname}".config.monorepo.vars.myDiskoSpec;
+        });
+
       in {
-        # add new systems here
         nixosConfigurations = builtins.listToAttrs (mkConfigs hostnames);
 
+        evalDisko = builtins.listToAttrs (mkDiskoFiles (builtins.filter (x: x != "installer") hostnames));
+
         topology."${system}" = import nix-topology {
           pkgs = import nixpkgs {
             inherit system;
@@ -239,6 +252,18 @@ largely self-documenting.
   { lib, ... }:
   {
     options.monorepo.vars = {
+      device = lib.mkOption {
+        type = lib.types.str;
+        default = "/dev/sda";
+        example = "/dev/nvme0n1";
+        description = "device that NixOS is installed to";
+      };
+
+      myDiskoSpec = lib.mkOption {
+        type = lib.types.attrs;
+        description = "retains a copy of the disko spec for reflection";
+      };
+
       userName = lib.mkOption {
         type = lib.types.str;
         default = "preston";
@@ -1242,34 +1267,39 @@ because they enhance security.
 This is the disko configuration for my continuity system. It features a boot and ext4 partition,
 on disk /dev/sda. All my SATA disks have this location by default, but if you want to use nvme,
 you will have to import that configuration in your ~systems/xxx/default.nix~.
-#+begin_src nix :tangle ../nix/disko/sda-simple.nix
-  {
-    disko.devices = {
-      disk = {
-        my-disk = {
-          device = "/dev/sda";
-          type = "disk";
-          content = {
-            type = "gpt";
-            partitions = {
-              ESP = {
-                type = "EF00";
-                size = "500M";
-                priority = 1;
-                content = {
-                  type = "filesystem";
-                  format = "vfat";
-                  mountpoint = "/boot";
-                  mountOptions = [ "umask=0077" ];
+*** NVME
+For my nvme drives.
+#+begin_src nix :tangle ../nix/disko/drive-simple.nix
+  { lib, config, ... }:
+  let
+    spec = {
+      disko.devices = {
+        disk = {
+          my-disk = {
+            device = config.monorepo.vars.device;
+            type = "disk";
+            content = {
+              type = "gpt";
+              partitions = {
+                ESP = {
+                  type = "EF00";
+                  size = "500M";
+                  priority = 1;
+                  content = {
+                    type = "filesystem";
+                    format = "vfat";
+                    mountpoint = "/boot";
+                    mountOptions = [ "umask=0077" ];
+                  };
                 };
-              };
-              root = {
-                size = "100%";
-                priority = 2;
-                content = {
-                  type = "filesystem";
-                  format = "ext4";
-                  mountpoint = "/";
+                root = {
+                  size = "100%";
+                  priority = 2;
+                  content = {
+                    type = "filesystem";
+                    format = "ext4";
+                    mountpoint = "/";
+                  };
                 };
               };
             };
@@ -1277,70 +1307,38 @@ you will have to import that configuration in your ~systems/xxx/default.nix~.
         };
       };
     };
+  in
+  {
+    monorepo.vars.myDiskoSpec = spec;
+    disko.devices = spec.disko.devices;
   }
 #+end_src
-*** NVME
-For my nvme drives.
-#+begin_src nix :tangle ../nix/disko/nvme-simple.nix
-{
-  disko.devices = {
-    disk = {
-      my-disk = {
-        device = "/dev/nvme0n1";
-        type = "disk";
-        content = {
-          type = "gpt";
-          partitions = {
-            ESP = {
-              type = "EF00";
-              size = "500M";
-              priority = 1;
-              content = {
-                type = "filesystem";
-                format = "vfat";
-                mountpoint = "/boot";
-                mountOptions = [ "umask=0077" ];
-              };
-            };
-            root = {
-              size = "100%";
-              priority = 2;
-              content = {
-                type = "filesystem";
-                format = "ext4";
-                mountpoint = "/";
-              };
-            };
-          };
-        };
-      };
-    };
-  };
-}
-#+end_src
 *** VDA
 For my virtual machines.
-#+begin_src nix :tangle ../nix/disko/vda-simple.nix
-  {
-    disko.devices = {
-      disk = {
-        main = {
-          device = "/dev/vda";
-          type = "disk";
-          content = {
-            type = "gpt";
-            partitions = {
-              boot = {
-                size = "1M";
-                type = "EF02";
-              };
-              root = {
-                label = "disk-main-root"; 
-                size = "100%";
-                content = {
-                  type = "filesystem";
-                  format = "ext4";
-                  mountpoint = "/";
+#+begin_src nix :tangle ../nix/disko/drive-bios.nix
+  { config, lib, ... }:
+  let
+    spec = {
+      disko.devices = {
+        disk = {
+          main = {
+            device = config.monorepo.vars.device;
+            type = "disk";
+            content = {
+              type = "gpt";
+              partitions = {
+                boot = {
+                  size = "1M";
+                  type = "EF02";
+                };
+                root = {
+                  label = "disk-main-root"; 
+                  size = "100%";
+                  content = {
+                    type = "filesystem";
+                    format = "ext4";
+                    mountpoint = "/";
+                  };
                 };
               };
             };
@@ -1348,6 +1346,10 @@ For my virtual machines.
         };
       };
     };
+  in
+  {
+    monorepo.vars.myDiskoSpec = spec;
+    disko.devices = spec.disko.devices;
   }
 #+end_src
 ** Home
@@ -1502,7 +1504,7 @@ I have many imports that we'll go through next.
                                                  ++
                                                  (if config.monorepo.profiles.art.enable then (with pkgs; [
                                                          inkscape
-                                                         krita
+                                                         krita
                                                  ]) else [])
                                                  ++
                                                  (if config.monorepo.profiles.music.enable then (with pkgs; [
@@ -1515,7 +1517,7 @@ I have many imports that we'll go through next.
                                        alsa-scarlett-gui
                                              ardour
                                              audacity
-                                                   blender
+                                                   blender
                         foxdot
                                        fluidsynth
                                        qjackctl
@@ -1525,7 +1527,7 @@ I have many imports that we'll go through next.
                         supercollider
                                        inkscape
                                        kdePackages.kdenlive
-                                       kicad
+                                       kicad
                         murmur
                         silver-searcher
                                                  ]) else []);
@@ -2922,7 +2924,7 @@ standard.
         g = "git";
         v = "vim";
         py = "python3";
-        rb = "sudo nixos-rebuild switch --flake .#${systemHostName}";
+        rb = "sudo nixos-rebuild switch --flake $HOME/monorepo/nix#${systemHostName}";
         nfu = "cd ~/monorepo/nix && git add . && git commit -m \"new flake lock\" &&  nix flake update";
         usync =  "rsync -azvP --chmod=\"Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r\" ~/website_html/ root@${config.monorepo.vars.remoteHost}:/var/www/ret2pop-website/";
         usite
@@ -2992,7 +2994,7 @@ for these configurations.
 
       packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [
         # wikipedia
-        kiwix kiwix-tools
+        kiwix kiwix-tools
 
         # passwords
         age sops
@@ -3004,7 +3006,7 @@ for these configurations.
         graphviz jq
 
         # Apps
-        octaveFull
+        octaveFull
         vesktop grim swww vim telegram-desktop
 
         # Sound/media
@@ -3032,14 +3034,13 @@ for these configurations.
         (writeShellScriptBin "remote-build"
           ''
   #!/bin/bash
-  cd ~/monorepo/nix
-  nixos-rebuild --use-remote-sudo --target-host "$1" switch --flake .#spontaneity
+  nixos-rebuild --sudo --ask-sudo-password --target-host "$1" switch --flake $HOME/monorepo/nix#spontaneity
   ''
         )
         (writeShellScriptBin "install-vps"
           ''
   #!/bin/bash
-  nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./systems/spontaneity/hardware-configuration.nix --flake .#spontaneity --target-host "$1"
+  nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config $HOME/monorepo/nix/systems/spontaneity/hardware-configuration.nix --flake $HOME/monorepo/nix#spontaneity --target-host "$1"
           '')
       ] else [
         pfetch
@@ -3090,16 +3091,30 @@ the path.
     };
   }
 #+end_src
+** Includes
+These are the common includes for my systems.
+#+begin_src nix :tangle ../nix/systems/includes.nix
+  { config, lib, ... }:
+  {
+    imports = [
+      ./home.nix
+      ../modules/default.nix
+    ];
+  }
+#+end_src
 ** Continuity
 This is pretty understandable, if you understand all the above.
 #+begin_src nix :tangle ../nix/systems/continuity/default.nix
   { ... }:
   {
     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";
+    };
   }
 #+end_src
 *** Home
@@ -3121,12 +3136,12 @@ as several other useful services.
   { 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;
@@ -3154,14 +3169,14 @@ Spontaneity is my VPS instance.
   { 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;
@@ -3289,6 +3304,10 @@ This contains the installation script I use to install my systems.
     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"))"
@@ -3302,15 +3321,10 @@ This contains the installation script I use to install my systems.
 
     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: my_sda.nix)")"
+      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"
@@ -3326,10 +3340,11 @@ This contains the installation script I use to install my systems.
   { ... }:
   {
     imports = [
-      ../../modules/default.nix
+      ../includes.nix
       ../../disko/$DRIVE
-      ../home.nix
     ];
+    # CHANGEME
+    config.monorepo.vars.drive = "/dev/sda";
   }
   EOF
 
@@ -3337,10 +3352,14 @@ This contains the installation script I use to install my systems.
     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"
@@ -3348,6 +3367,8 @@ This contains the installation script I use to install my systems.
     cd "$HOME/monorepo" && git add . && cd "$HOME"
   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
       echo "Proceeding..."
@@ -3356,7 +3377,8 @@ This contains the installation script I use to install my systems.
       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/disko/drive-bios.nix b/nix/disko/drive-bios.nix
new file mode 100644 (file)
index 0000000..cf0aeba
--- /dev/null
@@ -0,0 +1,35 @@
+{ config, lib, ... }:
+let
+  spec = {
+    disko.devices = {
+      disk = {
+        main = {
+          device = config.monorepo.vars.device;
+          type = "disk";
+          content = {
+            type = "gpt";
+            partitions = {
+              boot = {
+                size = "1M";
+                type = "EF02";
+              };
+              root = {
+                label = "disk-main-root"; 
+                size = "100%";
+                content = {
+                  type = "filesystem";
+                  format = "ext4";
+                  mountpoint = "/";
+                };
+              };
+            };
+          };
+        };
+      };
+    };
+  };
+in
+{
+  monorepo.vars.myDiskoSpec = spec;
+  disko.devices = spec.disko.devices;
+}
diff --git a/nix/disko/drive-simple.nix b/nix/disko/drive-simple.nix
new file mode 100644 (file)
index 0000000..4d229bf
--- /dev/null
@@ -0,0 +1,42 @@
+{ lib, config, ... }:
+let
+  spec = {
+    disko.devices = {
+      disk = {
+        my-disk = {
+          device = config.monorepo.vars.device;
+          type = "disk";
+          content = {
+            type = "gpt";
+            partitions = {
+              ESP = {
+                type = "EF00";
+                size = "500M";
+                priority = 1;
+                content = {
+                  type = "filesystem";
+                  format = "vfat";
+                  mountpoint = "/boot";
+                  mountOptions = [ "umask=0077" ];
+                };
+              };
+              root = {
+                size = "100%";
+                priority = 2;
+                content = {
+                  type = "filesystem";
+                  format = "ext4";
+                  mountpoint = "/";
+                };
+              };
+            };
+          };
+        };
+      };
+    };
+  };
+in
+{
+  monorepo.vars.myDiskoSpec = spec;
+  disko.devices = spec.disko.devices;
+}
diff --git a/nix/disko/nvme-simple.nix b/nix/disko/nvme-simple.nix
deleted file mode 100644 (file)
index 665c17e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-  disko.devices = {
-    disk = {
-      my-disk = {
-        device = "/dev/nvme0n1";
-        type = "disk";
-        content = {
-          type = "gpt";
-          partitions = {
-            ESP = {
-              type = "EF00";
-              size = "500M";
-              priority = 1;
-              content = {
-                type = "filesystem";
-                format = "vfat";
-                mountpoint = "/boot";
-                mountOptions = [ "umask=0077" ];
-              };
-            };
-            root = {
-              size = "100%";
-              priority = 2;
-              content = {
-                type = "filesystem";
-                format = "ext4";
-                mountpoint = "/";
-              };
-            };
-          };
-        };
-      };
-    };
-  };
-}
diff --git a/nix/disko/sda-simple.nix b/nix/disko/sda-simple.nix
deleted file mode 100644 (file)
index fdf6556..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-  disko.devices = {
-    disk = {
-      my-disk = {
-        device = "/dev/sda";
-        type = "disk";
-        content = {
-          type = "gpt";
-          partitions = {
-            ESP = {
-              type = "EF00";
-              size = "500M";
-              priority = 1;
-              content = {
-                type = "filesystem";
-                format = "vfat";
-                mountpoint = "/boot";
-                mountOptions = [ "umask=0077" ];
-              };
-            };
-            root = {
-              size = "100%";
-              priority = 2;
-              content = {
-                type = "filesystem";
-                format = "ext4";
-                mountpoint = "/";
-              };
-            };
-          };
-        };
-      };
-    };
-  };
-}
diff --git a/nix/disko/vda-simple.nix b/nix/disko/vda-simple.nix
deleted file mode 100644 (file)
index 3ae1d34..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  disko.devices = {
-    disk = {
-      main = {
-        device = "/dev/vda";
-        type = "disk";
-        content = {
-          type = "gpt";
-          partitions = {
-            boot = {
-              size = "1M";
-              type = "EF02";
-            };
-            root = {
-              label = "disk-main-root"; 
-              size = "100%";
-              content = {
-                type = "filesystem";
-                format = "ext4";
-                mountpoint = "/";
-              };
-            };
-          };
-        };
-      };
-    };
-  };
-}
index 393915bb53b9d069ffc63196c11f16cea59bb912..0be049f4012fb85f0a66763a1e90ca6b53dae6ea 100644 (file)
         ]
       },
       "locked": {
-        "lastModified": 1755519972,
-        "narHash": "sha256-bU4nqi3IpsUZJeyS8Jk85ytlX61i4b0KCxXX9YcOgVc=",
+        "lastModified": 1756733629,
+        "narHash": "sha256-dwWGlDhcO5SMIvMSTB4mjQ5Pvo2vtxvpIknhVnSz2I8=",
         "owner": "nix-community",
         "repo": "disko",
-        "rev": "4073ff2f481f9ef3501678ff479ed81402caae6d",
+        "rev": "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1",
         "type": "github"
       },
       "original": {
         ]
       },
       "locked": {
-        "lastModified": 1753592768,
-        "narHash": "sha256-oV695RvbAE4+R9pcsT9shmp6zE/+IZe6evHWX63f2Qg=",
+        "lastModified": 1756679287,
+        "narHash": "sha256-Xd1vOeY9ccDf5VtVK12yM0FS6qqvfUop8UQlxEB+gTQ=",
         "owner": "nix-community",
         "repo": "home-manager",
-        "rev": "fc3add429f21450359369af74c2375cb34a2d204",
+        "rev": "07fc025fe10487dd80f2ec694f1cd790e752d0e8",
         "type": "github"
       },
       "original": {
     },
     "nixpkgs_2": {
       "locked": {
-        "lastModified": 1755186698,
-        "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
+        "lastModified": 1757068644,
+        "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
         "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
+        "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
         "type": "github"
       },
       "original": {
     },
     "nixpkgs_3": {
       "locked": {
-        "lastModified": 1755186698,
-        "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
+        "lastModified": 1757068644,
+        "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
         "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
+        "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
         "type": "github"
       },
       "original": {
         "nixpkgs": "nixpkgs_3"
       },
       "locked": {
-        "lastModified": 1755566258,
-        "narHash": "sha256-bLDKNtjyDjMOK6w2dsRRRPKr2GzcKOdIjsiJd2FbZuA=",
+        "lastModified": 1757237279,
+        "narHash": "sha256-u0cJc2Thq0QF8fzTSy3617E83aAPsGKjnIKgaZBXW+I=",
         "owner": "nix-community",
         "repo": "NUR",
-        "rev": "b54ab372b6c2831be68f7302142bdfae08204756",
+        "rev": "4dcb0b2bddd4456fc10d7f29862a1f1b1fd304e9",
         "type": "github"
       },
       "original": {
index 021bcce7ab780372dc967dd4b0d6c9b20e8f310e..cffec9632d5a5c8b6b9159634e1c49a2442f1a96 100644 (file)
         "spontaneity"
         # add hostnames here
       ];
+
       system = "x86_64-linux";
+
       pkgs = import nixpkgs { inherit system; };
+
       generate = nixos-dns.utils.generate nixpkgs.legacyPackages."${system}";
+
       dnsConfig = {
         inherit (self) nixosConfigurations;
         extraConfig = import ./dns/default.nix;
       };
+
+      # function that generates all systems from hostnames
       mkConfigs = map (hostname: {name = "${hostname}";
         value = nixpkgs.lib.nixosSystem {
           inherit system;
           ];
         };
       });
+
+      mkDiskoFiles = map (hostname: {
+        name = "${hostname}";
+        value = self.nixosConfigurations."${hostname}".config.monorepo.vars.myDiskoSpec;
+      });
+
     in {
-      # add new systems here
       nixosConfigurations = builtins.listToAttrs (mkConfigs hostnames);
 
+      evalDisko = builtins.listToAttrs (mkDiskoFiles (builtins.filter (x: x != "installer") hostnames));
+
       topology."${system}" = import nix-topology {
         pkgs = import nixpkgs {
           inherit system;
index 52174a99243ca727df1c5e88f35d0bd4afe48127..7bfee4220d51775032a8122a95b735db9f4b099f 100644 (file)
                                                  ++
                                                  (if config.monorepo.profiles.art.enable then (with pkgs; [
                                                          inkscape
-                                                         krita
+                                                         krita
                                                  ]) else [])
                                                  ++
                                                  (if config.monorepo.profiles.music.enable then (with pkgs; [
                                        alsa-scarlett-gui
                                              ardour
                                              audacity
-                                                   blender
+                                                   blender
                       foxdot
                                        fluidsynth
                                        qjackctl
                       supercollider
                                        inkscape
                                        kdePackages.kdenlive
-                                       kicad
+                                       kicad
                       murmur
                       silver-searcher
                                                  ]) else []);
index 1e88b75484461ebc18493d22b9c2cf5dc3512227..12bba2e055aef1439ae392b42d18955905a7dbd3 100644 (file)
@@ -25,7 +25,7 @@
 
     packages = with pkgs; (if config.monorepo.profiles.graphics.enable then [
       # wikipedia
-      kiwix kiwix-tools
+      kiwix kiwix-tools
 
       # passwords
       age sops
@@ -37,7 +37,7 @@
       graphviz jq
 
       # Apps
-      octaveFull
+      octaveFull
       vesktop grim swww vim telegram-desktop
 
       # Sound/media
       (writeShellScriptBin "remote-build"
         ''
 #!/bin/bash
-cd ~/monorepo/nix
-nixos-rebuild --use-remote-sudo --target-host "$1" switch --flake .#spontaneity
+nixos-rebuild --sudo --ask-sudo-password --target-host "$1" switch --flake $HOME/monorepo/nix#spontaneity
 ''
       )
       (writeShellScriptBin "install-vps"
         ''
 #!/bin/bash
-nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./systems/spontaneity/hardware-configuration.nix --flake .#spontaneity --target-host "$1"
+nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config $HOME/monorepo/nix/systems/spontaneity/hardware-configuration.nix --flake $HOME/monorepo/nix#spontaneity --target-host "$1"
         '')
     ] else [
       pfetch
index 9f848bc1fc2d5e234ef813cc504f02d3b46c1e95..e12a2d80c9f205a6b55d67b179b5b7751ee9531b 100644 (file)
@@ -25,7 +25,7 @@
       g = "git";
       v = "vim";
       py = "python3";
-      rb = "sudo nixos-rebuild switch --flake .#${systemHostName}";
+      rb = "sudo nixos-rebuild switch --flake $HOME/monorepo/nix#${systemHostName}";
       nfu = "cd ~/monorepo/nix && git add . && git commit -m \"new flake lock\" &&  nix flake update";
       usync =  "rsync -azvP --chmod=\"Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r\" ~/website_html/ root@${config.monorepo.vars.remoteHost}:/var/www/ret2pop-website/";
       usite
index 6ee1cc087378a9046fa62b3e39e7784192a53878..48da97113b4e6d584829404edd178b9e494a70a6 100644 (file)
@@ -1,6 +1,18 @@
 { lib, ... }:
 {
   options.monorepo.vars = {
+    device = lib.mkOption {
+      type = lib.types.str;
+      default = "/dev/sda";
+      example = "/dev/nvme0n1";
+      description = "device that NixOS is installed to";
+    };
+
+    myDiskoSpec = lib.mkOption {
+      type = lib.types.attrs;
+      description = "retains a copy of the disko spec for reflection";
+    };
+
     userName = lib.mkOption {
       type = lib.types.str;
       default = "preston";
index 7f1f29de337bffa0423e950fb2221b72a318b1e5..17f140addb087506db95abbb122fc5dd58065436 100644 (file)
@@ -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;
index 4899804528aaee706b65d879469f0dba1dd26493..5bd6517a34ce4c5e62d57c04c5038ca9b08112ed 100644 (file)
@@ -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 (file)
index 0000000..5122fb2
--- /dev/null
@@ -0,0 +1,7 @@
+{ config, lib, ... }:
+{
+  imports = [
+    ./home.nix
+    ../modules/default.nix
+  ];
+}
index bf865a3641236b4e73a6b1e398619c853147fcc3..cce0b4658f7c5db248b28004884b6f9988b56b81 100644 (file)
@@ -1,5 +1,5 @@
 {
   diskoCommitHash = "a5c4f2ab72e3d1ab43e3e65aa421c6f2bd2e12a1";
-  monorepoCommitHash = "af3c15c43c65fd77aab441f4c657aeaa74cc67d5";
+  monorepoCommitHash = "8f4f46e59ad0b7c5662a417d10f3074f17c962c3";
   monorepoUrl = "https://github.com/ret2pop/monorepo";
 }
index 75f0b818a49d3c5f33695a2ba7538e348589dbd2..a22b126dd41b7fd69f284acafcc9237fcaa29450 100644 (file)
@@ -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"
 
index 3aa0a39b9285b16a12a60061272d64613ec38f3e..5460428f1f0a367098e809167036bad1af581c67 100644 (file)
@@ -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;