Move to new module system, allows for multiple computers

Change-Id: I9a76346b05dfff6157813c50f89d1254130fc26c
diff --git a/flake.nix b/flake.nix
index da68f66..99c098e 100755
--- a/flake.nix
+++ b/flake.nix
@@ -3,7 +3,11 @@
 
   inputs = {
     nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
+
     nix-vscode-extensions.url = "github:nix-community/nix-vscode-extensions";
+    nix-vscode-extensions.inputs.nixpkgs.follows = "nixpkgs";
+    nix-vscode-extensions.inputs.flake-compat.follows = "lanzaboote/flake-compat";
+    nix-vscode-extensions.inputs.flake-utils.follows = "lanzaboote/flake-utils";
 
     alacritty-themes.url = "github:rajasegar/alacritty-themes";
     alacritty-themes.flake = false;
@@ -11,30 +15,48 @@
     home-manager.url = "github:nix-community/home-manager";
     home-manager.inputs.nixpkgs.follows = "nixpkgs";
 
+    deploy-rs.url = "github:serokell/deploy-rs";
+
     lanzaboote.url = "github:nix-community/lanzaboote";
+    lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
   };
 
-  outputs = { self, nixpkgs, home-manager, ... }@inputs: {
-    nixosConfigurations."codedPC" = nixpkgs.lib.nixosSystem {
+  outputs = { self, nixpkgs, home-manager, deploy-rs, ... }@inputs: let
+    stateVersion = "23.11";  # Only change this number on a full config rewrite.
+    modulesFor = x: (nixpkgs.lib.pipe ./modules/${x} [
+        (import ./utils/nixFilesIn.nix nixpkgs.lib)
+        (map import)
+      ]);
+  in {
+    nixosConfigurations.codedPC = nixpkgs.lib.nixosSystem {
       system = "x86_64-linux";
       modules = [
         home-manager.nixosModules.home-manager
         inputs.lanzaboote.nixosModules.lanzaboote
         {
           nix.settings.experimental-features = [ "nix-command" "flakes" ];
-          system.stateVersion = "23.11";
-          nixpkgs.config.permittedInsecurePackages = [
-            "mailspring-1.12.0"
-          ];
+          system = { inherit stateVersion; };
         }
-      ] ++ (nixpkgs.lib.pipe ./modules [
-        (import ./utils/nixFilesIn.nix nixpkgs.lib)
-        (map import)
-      ]) ++ (nixpkgs.lib.pipe ./homes [
-        (import ./utils/nixFilesIn.nix nixpkgs.lib)
-        (map import)
-      ]);
-      specialArgs = { inherit inputs; };
+      ] ++ modulesFor "common" ++ modulesFor "codedPC";
+      specialArgs = { inherit inputs; flakeRoot = ./.; };
+    };
+
+    nixosConfigurations.codedPI = nixpkgs.lib.nixosSystem {
+      system = "amd64-linux";
+      modules = [
+        home-manager.nixosModules.home-manager
+        inputs.lanzaboote.nixosModules.lanzaboote
+        {
+          nix.settings.experimental-features = [ "nix-command" "flakes" ];
+          system = { inherit stateVersion; };
+        }
+      ] ++ modulesFor "common" ++ modulesFor "codedPI";
+      specialArgs = { inherit inputs; flakeRoot = ./.; };
+    };
+
+    deploy.nodes.codedPI.profiles.system = {
+        user = "coded";
+        path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.codedPI;
     };
   };
 }