{
  config,
  lib,
  modulesPath,
  pkgs,
  ...
}:

{
  # NIXPKGS-PR: 394300
  disabledModules = [
    "${modulesPath}/hardware/openrazer.nix"
  ];
  imports = [
    (builtins.fetchurl {
      url = "https://raw.githubusercontent.com/NixOS/nixpkgs/4a11562c20fbe7af7d5ac139dbf0f8d50ce276f6/nixos/modules/hardware/openrazer.nix";
      sha256 = "0n6kzrcwlmxgws4pmffyqagp2rxpfxmfjl11vgvlkjcbglg6fs7y";
    })
  ];

  hardware.openrazer = {
    enable = true;
    users = [
      "emenel"
    ];
    # NIXPKGS-PR: 384992
    packages = let
      oldVersion = pkgs.python3Packages.openrazer-daemon.version;
      version = "3.10.1";
    in lib.mapAttrs (_: package: package.overrideAttrs (oldAttrs: {
      version = lib.replaceStrings [ oldVersion ] [ version ] oldAttrs.version;
      src = pkgs.fetchFromGitHub {
        owner = "openrazer";
        repo = "openrazer";
        tag = "v${version}";
        hash = "sha256-igrGx7Y6ENtZatJCTAW43/0q6ZjljJ9/kU3QFli4yIU=";
      };
    })) {
      kernel = config.boot.kernelPackages.openrazer;
      daemon = pkgs.python3Packages.openrazer-daemon;
    };
  };

  environment.systemPackages = with pkgs; [
    openrazer-daemon
    polychromatic
  ];
}
