Update versions and add all changed modules
diff --git a/flake.lock b/flake.lock
index 7b92f77..e754c4c 100644
--- a/flake.lock
+++ b/flake.lock
@@ -7,11 +7,11 @@
         "utils": "utils"
       },
       "locked": {
-        "lastModified": 1674127017,
-        "narHash": "sha256-QO1xF7stu5ZMDLbHN30LFolMAwY6TVlzYvQoUs1RD68=",
+        "lastModified": 1682063650,
+        "narHash": "sha256-VaDHh2z6xlnTHaONlNVHP7qEMcK5rZ8Js3sT6mKb2XY=",
         "owner": "serokell",
         "repo": "deploy-rs",
-        "rev": "8c9ea9605eed20528bf60fae35a2b613b901fd77",
+        "rev": "c2ea4e642dc50fd44b537e9860ec95867af30d39",
         "type": "github"
       },
       "original": {
@@ -36,6 +36,26 @@
         "type": "github"
       }
     },
+    "home-manager": {
+      "inputs": {
+        "nixpkgs": "nixpkgs_2",
+        "utils": "utils_2"
+      },
+      "locked": {
+        "lastModified": 1681092193,
+        "narHash": "sha256-JerCqqOqbT2tBnXQW4EqwFl0hHnuZp21rIQ6lu/N4rI=",
+        "owner": "nix-community",
+        "repo": "home-manager",
+        "rev": "f9edbedaf015013eb35f8caacbe0c9666bbc16af",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "ref": "release-22.11",
+        "repo": "home-manager",
+        "type": "github"
+      }
+    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1671417167,
@@ -54,22 +74,41 @@
     },
     "nixpkgs_2": {
       "locked": {
-        "lastModified": 1677655566,
-        "narHash": "sha256-I8G8Lmpp3YduYl4+pkiIJFGT1WKw+8ZMH2QwANkTu2U=",
-        "owner": "NixOS",
+        "lastModified": 1667629849,
+        "narHash": "sha256-P+v+nDOFWicM4wziFK9S/ajF2lc0N2Rg9p6Y35uMoZI=",
+        "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "ae8bdd2de4c23b239b5a771501641d2ef5e027d0",
+        "rev": "3bacde6273b09a21a8ccfba15586fb165078fb62",
         "type": "github"
       },
       "original": {
-        "id": "nixpkgs",
-        "type": "indirect"
+        "owner": "nixos",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs_3": {
+      "locked": {
+        "lastModified": 1682173319,
+        "narHash": "sha256-tPhOpJJ+wrWIusvGgIB2+x6ILfDkEgQMX0BTtM5vd/4=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "ee7ec1c71adc47d2e3c2d5eb0d6b8fbbd42a8d1c",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "nixos-22.11",
+        "repo": "nixpkgs",
+        "type": "github"
       }
     },
     "root": {
       "inputs": {
         "deploy-rs": "deploy-rs",
-        "nixpkgs": "nixpkgs_2"
+        "home-manager": "home-manager",
+        "nixpkgs": "nixpkgs_3"
       }
     },
     "utils": {
@@ -86,6 +125,21 @@
         "repo": "flake-utils",
         "type": "github"
       }
+    },
+    "utils_2": {
+      "locked": {
+        "lastModified": 1667395993,
+        "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
     }
   },
   "root": "root",
diff --git a/flake.nix b/flake.nix
index 16ab9b1..1ce4f73 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,51 +1,93 @@
 {
   description = "A flake to deploy and configure Clicks' NixOS server";
 
+  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
   inputs.deploy-rs.url = "github:serokell/deploy-rs";
+  inputs.home-manager.url = "github:nix-community/home-manager/release-22.11";
 
-  outputs = { self, nixpkgs, deploy-rs, ... }@inputs: {
-    nixosConfigurations.clicks =
-      let
-        system = "x86_64-linux";
-        pkgs = import nixpkgs {
-          inherit system;
-          config.allowUnfree = true;
+  outputs = { self, nixpkgs, deploy-rs, home-manager, ... }@inputs:
+    let
+      system = "x86_64-linux";
+      pkgs = import nixpkgs {
+        inherit system;
+        config.allowUnfree = true;
+      };
+    in
+    {
+      nixosConfigurations.clicks =
+        nixpkgs.lib.nixosSystem {
+          inherit system pkgs;
+          modules = [
+            ./default/configuration.nix
+            ./default/hardware-configuration.nix
+            ./modules/caddy.nix
+            ./modules/clamav.nix
+            ./modules/code-server.nix
+            ./modules/dnsmasq.nix
+            ./modules/doas.nix
+            ./modules/docker.nix
+            ./modules/ecryptfs.nix
+            ./modules/fail2ban.nix
+            ./modules/fuck.nix
+            ./modules/git.nix
+            ./modules/home-manager-users.nix
+            ./modules/kitty.nix
+            ./modules/mongodb.nix
+            ./modules/node.nix
+            ./modules/samba.nix
+            ./modules/tesseract.nix
+            {
+              users.mutableUsers = false;
+            }
+          ];
         };
-      in
-      nixpkgs.lib.nixosSystem {
-        inherit system pkgs;
-        modules = [
-          ./default/configuration.nix
-          ./default/hardware-configuration.nix
-          ./modules/mongodb.nix
-          ./modules/git.nix
-          ./modules/caddy.nix
-          ./modules/fuck.nix
-          ./modules/node.nix
-          ./modules/kitty.nix
-          ./modules/tesseract.nix
-          ./modules/doas.nix
-          ./modules/code-server.nix
-          ./modules/ecryptfs.nix
-          ./modules/clamav.nix
-          {
-            users.mutableUsers = false;
-          }
-        ];
+
+      deploy.nodes.clicks = {
+        sudo = "doas -u";
+        profiles = {
+          system = {
+            remoteBuild = true;
+            user = "root";
+            path = deploy-rs.lib.x86_64-linux.activate.nixos
+              self.nixosConfigurations.clicks;
+          };
+        } // (
+          let
+            mkServiceConfig = service: {
+              remoteBuild = true;
+              user = service;
+
+              profilePath = "/nix/var/nix/profiles/per-user/${service}/home-manager";
+              path =
+                deploy-rs.lib.x86_64-linux.activate.home-manager (home-manager.lib.homeManagerConfiguration
+                  {
+                    inherit pkgs;
+                    modules = [
+                      {
+                        home.homeDirectory = "/services/${service}";
+                        home.username = service;
+                        home.stateVersion = "22.11";
+                        programs.home-manager.enable = true;
+                      }
+                      "${./services}/${service}"
+                    ];
+                  });
+            };
+          in
+          nixpkgs.lib.pipe ./services [
+            builtins.readDir
+            (nixpkgs.lib.filterAttrs (_name: value: value == "directory"))
+            builtins.attrNames
+            (map (name: {
+              inherit name; value = mkServiceConfig name;
+            }))
+            builtins.listToAttrs
+          ]
+        );
+        hostname = "clicks";
+        profilesOrder = [ "system" ];
       };
 
-    deploy.nodes.clicks = {
-      sudo = "doas -u";
-      profiles.system = {
-        remoteBuild = true;
-        user = "root";
-        path = deploy-rs.lib.x86_64-linux.activate.nixos
-          self.nixosConfigurations.clicks;
-      };
-      hostname = "192.168.89.74";
-      profilesOrder = [ "system" ];
+      formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
     };
-
-    formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
-  };
 }