diff --git a/flake.nix b/flake.nix
index 237febd..6999342 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,15 +9,22 @@
   in {
     packages = forAllSystems(system: {
 			pkgs = nixpkgs.legacyPackages.${system};
-			
+			cleanSource = src: with pkgs.lib; cleanSourceWith {
+    		filter = name: type: cleanSourceFilter name type
+      		&& !(hasInfix "/node_modules/" name)
+      		&& !(hasInfix "/nix/" name && hasSuffix ".nix" name);
+
+    		inherit src;
+		  };
+	
 			schildichat-web = import ./nix/schildichat-web.nix {
-				inherit (final.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
-				inherit pkgs;
+				inherit (pkgs.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
+				inherit pkgs cleanSource;
 			};
 
 			schildichat-desktop = import ./nix/schildichat-desktop.nix {
-				inherit (final.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
-				inherit pkgs;
+				inherit (pkgs.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
+				inherit pkgs cleanSource;
 			};
 
 			schildichat-desktop-wayland = self.packages.${system}.schildichat-desktop {
diff --git a/nix/schildichat-desktop.nix b/nix/schildichat-desktop.nix
index f073d97..ae87d62 100644
--- a/nix/schildichat-desktop.nix
+++ b/nix/schildichat-desktop.nix
@@ -1,4 +1,5 @@
 { pkgs
+, cleanSource
 , schildichat-desktop-src ? ../.
 , useWayland ? false
 }:
@@ -7,16 +8,16 @@ let
   inherit (pkgs.nodePackages) mkYarnPackage;
   inherit (pkgs.darwin.apple_sdk.frameworks) Security AppKit CoreServices;
 
-  schildichat-web = pkgs.callPackage ./schildichat-web.nix { inherit pkgs; };
+  schildichat-web = pkgs.callPackage ./schildichat-web.nix { inherit pkgs cleanSource; };
 
   packageJSON = schildichat-desktop-src + "/element-desktop/package.json";
   yarnLock = schildichat-desktop-src + "/element-desktop/yarn.lock";
   version = builtins.fromJSON (builtins.readFile packageJSON).version;
 
   electron_exec = if stdenv.isDarwin then 
-		"${electron}/Applications/Electron.app/Contents/MacOS/Electron"
+		"${pkgs.electron}/Applications/Electron.app/Contents/MacOS/Electron"
 	else 
-		"${electron}/bin/electron";
+		"${pkgs.electron}/bin/electron";
 in mkYarnPackage {
   pname = "schildichat-desktop";
   src = cleanSource (schildichat-desktop-src + "/element-desktop");
diff --git a/nix/schildichat-web.nix b/nix/schildichat-web.nix
index 8d14e11..aea0617 100644
--- a/nix/schildichat-web.nix
+++ b/nix/schildichat-web.nix
@@ -1,13 +1,14 @@
-{ pkgs, schildichat-desktop-src ? ../. }:
+{ pkgs
+, cleanSource
+, schildichat-desktop-src ? ../. }:
 
 let
-  version = lib.importJSON "${schildichat-desktop-src}/element-web/package.json".version;
+  version = pkgs.lib.importJSON "${schildichat-desktop-src}/element-web/package.json".version;
 in pkgs.stdenv.mkDerivation {
   pname = "schildichat-web";
   inherit version;
 
-  src = pkgs.cleanSource schildichat-desktop-src;
-
+  src = cleanSource schildichat-desktop-src;
   nativeBuildInputs = with pkgs; [ nodejs yarn ];
 
   buildPhase = ''