From ea7a8bf2d990413685ec9ad2e4c4e24dad7aafa5 Mon Sep 17 00:00:00 2001 From: Kier Davis Date: Thu, 12 Jan 2017 18:25:14 +0000 Subject: [PATCH] ckb: init at 0.2.6 ckb is a driver for Corsair keyboards/mice. It also contains a graphical tool for configuring their LED backlight settings. The driver is implemented as a userland daemon. A NixOS module is included that runs this as a systemd service. --- nixos/modules/hardware/ckb.nix | 40 +++++++++++++++++ .../misc/ckb/ckb-animations-location.patch | 12 ++++++ pkgs/tools/misc/ckb/default.nix | 43 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 97 insertions(+) create mode 100644 nixos/modules/hardware/ckb.nix create mode 100644 pkgs/tools/misc/ckb/ckb-animations-location.patch create mode 100644 pkgs/tools/misc/ckb/default.nix diff --git a/nixos/modules/hardware/ckb.nix b/nixos/modules/hardware/ckb.nix new file mode 100644 index 00000000000..8429572a882 --- /dev/null +++ b/nixos/modules/hardware/ckb.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.hardware.ckb; + +in + { + options.hardware.ckb = { + enable = mkEnableOption "the Corsair keyboard/mouse driver"; + + package = mkOption { + type = types.package; + default = pkgs.ckb; + defaultText = "pkgs.ckb"; + description = '' + The package implementing the Corsair keyboard/mouse driver. + ''; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + systemd.services.ckb = { + description = "Corsair Keyboard Daemon"; + wantedBy = ["multi-user.target"]; + script = "${cfg.package}/bin/ckb-daemon"; + serviceConfig = { + Restart = "always"; + StandardOutput = "syslog"; + }; + }; + }; + + meta = { + maintainers = with lib.maintainers; [ kierdavis ]; + }; + } diff --git a/pkgs/tools/misc/ckb/ckb-animations-location.patch b/pkgs/tools/misc/ckb/ckb-animations-location.patch new file mode 100644 index 00000000000..07dcfab86be --- /dev/null +++ b/pkgs/tools/misc/ckb/ckb-animations-location.patch @@ -0,0 +1,12 @@ +diff --git a/src/ckb/animscript.cpp b/src/ckb/animscript.cpp +index d0b7f46..d7a3459 100644 +--- a/src/ckb/animscript.cpp ++++ b/src/ckb/animscript.cpp +@@ -30,7 +30,7 @@ QString AnimScript::path(){ + #ifdef __APPLE__ + return QDir(QApplication::applicationDirPath() + "/../Resources").absoluteFilePath("ckb-animations"); + #else +- return QDir(QApplication::applicationDirPath()).absoluteFilePath("ckb-animations"); ++ return QDir(QApplication::applicationDirPath() + "/../libexec").absoluteFilePath("ckb-animations"); + #endif + } diff --git a/pkgs/tools/misc/ckb/default.nix b/pkgs/tools/misc/ckb/default.nix new file mode 100644 index 00000000000..f2dc5150bbd --- /dev/null +++ b/pkgs/tools/misc/ckb/default.nix @@ -0,0 +1,43 @@ +{ stdenv, fetchFromGitHub, libudev, pkgconfig, qtbase, qmakeHook, zlib }: + +stdenv.mkDerivation rec { + version = "0.2.6"; + name = "ckb-${version}"; + + src = fetchFromGitHub { + owner = "ccMSC"; + repo = "ckb"; + rev = "v${version}"; + sha256 = "04h50qdzsbi77mj62jghr52i35vxvmhnvsb7pdfdq95ryry8bnwm"; + }; + + buildInputs = [ + libudev + qtbase + zlib + ]; + + nativeBuildInputs = [ + pkgconfig + qmakeHook + ]; + + patches = [ + ./ckb-animations-location.patch + ]; + + doCheck = false; + + installPhase = '' + install -D --mode 0755 --target-directory $out/bin bin/ckb-daemon bin/ckb + install -D --mode 0755 --target-directory $out/libexec/ckb-animations bin/ckb-animations/* + ''; + + meta = with stdenv.lib; { + description = "Driver and configuration tool for Corsair keyboards and mice"; + homepage = https://github.com/ccMSC/ckb; + license = licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ kierdavis ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 679d8037995..3a5143a74da 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1267,6 +1267,8 @@ in cloud-utils = callPackage ../tools/misc/cloud-utils { }; + ckb = qt5.callPackage ../tools/misc/ckb { }; + compass = callPackage ../development/tools/compass { }; convmv = callPackage ../tools/misc/convmv { };