summaryrefslogtreecommitdiffstats
path: root/pkgs/tools/X11/sct
diff options
context:
space:
mode:
authorYegor Timoshenko <yegortimoshenko@gmail.com>2017-09-26 11:04:27 +0000
committerYegor Timoshenko <yegortimoshenko@gmail.com>2017-09-26 13:15:55 +0000
commit44beb565409b496fa6763a246e15edf5d0155ea0 (patch)
tree558f5921aecef6b751a20e7ac7de80eeaedef372 /pkgs/tools/X11/sct
parentcee657f9a338cb9fa7505fd02fb69e46449da16d (diff)
sct: fix segfault when DISPLAY is empty, clean up derivation
Diffstat (limited to 'pkgs/tools/X11/sct')
-rw-r--r--pkgs/tools/X11/sct/DISPLAY-segfault.patch10
-rw-r--r--pkgs/tools/X11/sct/default.nix41
2 files changed, 28 insertions, 23 deletions
diff --git a/pkgs/tools/X11/sct/DISPLAY-segfault.patch b/pkgs/tools/X11/sct/DISPLAY-segfault.patch
new file mode 100644
index 000000000000..6b83afa332ba
--- /dev/null
+++ b/pkgs/tools/X11/sct/DISPLAY-segfault.patch
@@ -0,0 +1,10 @@
+--- a/sct.c 2017-09-22 00:44:20.270421881 +0000
++++ b/sct.c 2017-09-26 10:50:38.964562740 +0000
+@@ -36,6 +36,7 @@
+ main(int argc, char **argv)
+ {
+ Display *dpy = XOpenDisplay(NULL);
++ if (!dpy) exit(1);
+ int screen = DefaultScreen(dpy);
+ Window root = RootWindow(dpy, screen);
+
diff --git a/pkgs/tools/X11/sct/default.nix b/pkgs/tools/X11/sct/default.nix
index 1890e9c5266b..9f45bbe30871 100644
--- a/pkgs/tools/X11/sct/default.nix
+++ b/pkgs/tools/X11/sct/default.nix
@@ -1,31 +1,26 @@
-{stdenv, fetchurl, libX11, libXrandr}:
+{ stdenv, fetchurl, libX11, libXrandr }:
+
stdenv.mkDerivation rec {
name = "sct";
- buildInputs = [libX11 libXrandr];
+
src = fetchurl {
url = http://www.tedunangst.com/flak/files/sct.c;
sha256 = "01f3ndx3s6d2qh2xmbpmhd4962dyh8yp95l87xwrs4plqdz6knhd";
-
- # Discussion regarding the checksum and the source code can be found in issue #17163
- # The code seems unmaintained, yet an unknown (probably small change) in the code caused
- # failed builds as the checksum had changed.
- # The checksum is updated for now, however, this is unpractical and potentially unsafe
- # so any future changes might warrant a fork of the (feature complete) project.
- # The code is under public domain.
-
};
- phases = ["patchPhase" "buildPhase" "installPhase"];
- patchPhase = ''
- sed -re "/Xlibint/d" ${src} > sct.c
- '';
- buildPhase = "gcc -std=c99 sct.c -o sct -lX11 -lXrandr -lm";
- installPhase = ''
- mkdir -p "$out/bin"
- cp sct "$out/bin"
- '';
- meta = {
- description = ''A minimal utility to set display colour temperature'';
- maintainers = [stdenv.lib.maintainers.raskin];
- platforms = with stdenv.lib.platforms; linux ++ freebsd ++ openbsd;
+
+ unpackPhase = "cat ${src} > sct.c";
+ patches = [ ./DISPLAY-segfault.patch ];
+
+ buildInputs = [ libX11 libXrandr ];
+ buildPhase = "cc sct.c -o sct -lm -lX11 -lXrandr";
+
+ installPhase = "install -Dt $out/bin sct";
+
+ meta = with stdenv.lib; {
+ homepage = https://www.tedunangst.com/flak/post/sct-set-color-temperature;
+ description = "A minimal utility to set display colour temperature";
+ maintainers = [ maintainers.raskin ];
+ license = licenses.publicDomain;
+ platforms = with platforms; linux ++ freebsd ++ openbsd;
};
}