nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 dbus,
6 cmake,
7 pkg-config,
8 wayland-scanner,
9 glib,
10 udev,
11 polkit,
12 libusb1,
13 libjpeg,
14 libmodule,
15 libXdmcp,
16 util-linux,
17 libpthreadstubs,
18 enableDdc ? true,
19 ddcutil,
20 enableDpms ? true,
21 libXext,
22 enableGamma ? true,
23 libdrm,
24 libXrandr,
25 libiio,
26 wayland,
27 enableScreen ? true,
28 enableYoctolight ? true,
29}:
30
31stdenv.mkDerivation rec {
32 pname = "clightd";
33 version = "5.9";
34
35 src = fetchFromGitHub {
36 owner = "FedeDP";
37 repo = "Clightd";
38 rev = version;
39 hash = "sha256-LOhBBd7QL5kH4TzMFgrh70C37WsFdsiKArP+tIEiPWo=";
40 };
41
42 # dbus-1.pc has datadir=/etc
43 SYSTEM_BUS_DIR = "${placeholder "out"}/share/dbus-1/system-services";
44 # polkit-gobject-1.pc has prefix=${polkit.out}
45 POLKIT_ACTION_DIR = "${placeholder "out"}/share/polkit-1/actions";
46
47 postPatch = ''
48 sed -i "s@pkg_get_variable(SYSTEM_BUS_DIR.*@set(SYSTEM_BUS_DIR $SYSTEM_BUS_DIR)@" CMakeLists.txt
49 sed -i "s@pkg_get_variable(POLKIT_ACTION_DIR.*@set(POLKIT_ACTION_DIR $POLKIT_ACTION_DIR)@" CMakeLists.txt
50 '';
51
52 cmakeFlags = [
53 "-DSYSTEMD_SERVICE_DIR=${placeholder "out"}/lib/systemd/system"
54 "-DDBUS_CONFIG_DIR=${placeholder "out"}/etc/dbus-1/system.d"
55 # systemd.pc has prefix=${systemd.out}
56 "-DMODULE_LOAD_DIR=${placeholder "out"}/lib/modules-load.d"
57 ]
58 ++ lib.optional enableDdc "-DENABLE_DDC=1"
59 ++ lib.optional enableDpms "-DENABLE_DPMS=1"
60 ++ lib.optional enableGamma "-DENABLE_GAMMA=1"
61 ++ lib.optional enableScreen "-DENABLE_SCREEN=1"
62 ++ lib.optional enableYoctolight "-DENABLE_YOCTOLIGHT=1";
63
64 depsBuildBuild = [
65 pkg-config
66 ];
67
68 nativeBuildInputs = [
69 cmake
70 pkg-config
71 wayland-scanner
72 ];
73
74 buildInputs = [
75 dbus
76 glib
77 udev
78 polkit
79 libusb1
80 libjpeg
81 libmodule
82 libiio
83
84 libXdmcp
85 util-linux
86 libpthreadstubs
87 ]
88 ++ lib.optionals enableDdc [ ddcutil ]
89 ++ lib.optionals enableDpms [ libXext ]
90 ++ lib.optionals enableGamma [ libXrandr ]
91 ++ lib.optionals (enableDpms || enableGamma || enableScreen) [
92 libdrm
93 wayland
94 ];
95
96 postInstall = ''
97 mkdir -p $out/bin
98 ln -svT $out/libexec/clightd $out/bin/clightd
99 '';
100
101 meta = with lib; {
102 description = "Linux bus interface that changes screen brightness/temperature";
103 mainProgram = "clightd";
104 homepage = "https://github.com/FedeDP/Clightd";
105 platforms = platforms.linux;
106 license = licenses.gpl3;
107 maintainers = with maintainers; [
108 eadwu
109 ];
110 };
111}