From 06ac4b21dad17dd78a33daa3f3b70e40733aba5f Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Thu, 9 May 2024 10:17:52 +0200
Subject: [PATCH] Include `xone` patches directly

---
 flake.nix            | 14 ++++++++++++--
 lib/modules/xone.nix | 15 +--------------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/flake.nix b/flake.nix
index ecb27cd..1f33579 100644
--- a/flake.nix
+++ b/flake.nix
@@ -133,6 +133,14 @@
               });
           }
       ) // {
+        overlays.default =
+          final: prev: {
+            linuxPackages_latest.xone = xonePatcher {
+              inherit (final) fetchFromGitHub;
+              inherit (final.linuxPackages_latest) xone;
+            };
+          };
+
         nixosConfigurations =
             builtins.mapAttrs (
               hostname: { system, config, modules }@machine: nixpkgs.lib.nixosSystem {
@@ -143,14 +151,16 @@
                     { pkgs, ... }: {
                       config = {
                         _module.args = {
-                          inherit xonePatcher;
-
                           machine = machine // {
                             name = hostname;
                             config = (pkgs.callPackage config { });
                           };
                         };
 
+                        nixpkgs.overlays = [
+                          self.overlays.default
+                        ];
+
                         home-manager.sharedModules = [
                           sops-nix.homeManagerModules.sops
                         ];
diff --git a/lib/modules/xone.nix b/lib/modules/xone.nix
index 46c1823..c07f59e 100644
--- a/lib/modules/xone.nix
+++ b/lib/modules/xone.nix
@@ -1,22 +1,9 @@
-{ lib, pkgs, xonePatcher, ... }: {
+{ lib, ... }: {
   config = {
     nixpkgs = {
       config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
         "xow_dongle-firmware"
       ];
-      
-      overlays = [
-        (final: prev: {
-          linuxPackages = prev.linuxPackages.extend (
-            final: prev: {
-              xone = xonePatcher {
-                inherit (pkgs) fetchFromGitHub;
-                inherit (prev) xone;
-              };
-            }
-          );
-      })
-    ];
     };
   };
 }