From 820ef6729def3c80c0f4acf50716abbbe888bc2a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 8 May 2024 09:58:18 +0200 Subject: [PATCH] Add customized `xone` package --- flake.nix | 29 +++++++++++++++++------------ lib/configuration.nix | 4 ++++ lib/modules/xone.nix | 22 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 lib/modules/xone.nix diff --git a/flake.nix b/flake.nix index 2647b13..a8c60e8 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,17 @@ machineDefinitions; tryFiles = import ./lib/utils/try-files.nix { inherit lib; }; + + xonePatcher = { fetchFromGitHub, xone }: + xone.overrideAttrs ( + final: prev: { + src = fetchFromGitHub { + owner = "manuth"; + repo = "xone"; + rev = "954fc823fbaa429ad6e1c1a06a4a006598ef35ae"; + sha256 = "lsfm7WDXTB6t05AI/pp17yZvkNvnM2WBMUHL1eVO6qw="; + }; + }); in flake-utils.lib.eachDefaultSystem ( system: @@ -73,17 +84,6 @@ sops-nix.overlays.default ]; }; - - xonePatcher = - xone: (xone.overrideAttrs ( - final: prev: { - src = pkgs.fetchFromGitHub { - owner = "manuth"; - repo = "xone"; - rev = "954fc823fbaa429ad6e1c1a06a4a006598ef35ae"; - sha256 = "lsfm7WDXTB6t05AI/pp17yZvkNvnM2WBMUHL1eVO6qw="; - }; - })); in { packages = { rcloneDocs = @@ -103,7 +103,10 @@ pkgs.runCommand "options-doc.md" {} '' cat ${optionsDoc.optionsCommonMark} >> $out ''; - xone = xonePatcher pkgs.linuxPackages_latest.xone; + xone = xonePatcher { + inherit (pkgs) fetchFromGitHub; + inherit (pkgs.linuxPackages_latest) xone; + }; }; devShells.default = pkgs.mkShellNoCC ( @@ -139,6 +142,8 @@ { pkgs, ... }: { config = { _module.args = { + inherit xonePatcher; + machine = machine // { name = hostname; config = (pkgs.callPackage config { }); diff --git a/lib/configuration.nix b/lib/configuration.nix index 25397da..ffd4caf 100644 --- a/lib/configuration.nix +++ b/lib/configuration.nix @@ -5,6 +5,7 @@ ./modules/my-users.nix ./modules/sddm.nix ./modules/unfree.nix + ./modules/xone.nix ]; config = { @@ -102,6 +103,9 @@ package = config.boot.kernelPackages.nvidiaPackages.stable; }; + # Drivers + hardware.xone.enable = (lib.mkIf machine.config.xone true); + # Enable KDE Plasma services.displayManager.sddm = { enable = true; diff --git a/lib/modules/xone.nix b/lib/modules/xone.nix new file mode 100644 index 0000000..46c1823 --- /dev/null +++ b/lib/modules/xone.nix @@ -0,0 +1,22 @@ +{ lib, pkgs, xonePatcher, ... }: { + 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; + }; + } + ); + }) + ]; + }; + }; +}