@@ -0,0 +1,64 @@
1+{ stdenv, lib, fetchFromGitHub, python2, python2Packages, file, makeWrapper, cups }:
2+
3+# Setup instructions can be found at https://github.com/simoncadman/CUPS-Cloud-Print#configuration
4+# So the nix version is something like:
5+# nix run nixpkgs.cups-googlecloudprint -c sudo setupcloudprint
6+# nix run nixpkgs.cups-googlecloudprint -c sudo listcloudprinters
7+
8+let pythonEnv = python2.buildEnv.override {
9+ extraLibs = with python2Packages; [
10+ six
11+ httplib2
12+ pycups
13+ ];
14+};
15+
16+in stdenv.mkDerivation rec {
17+ name = "cups-googlecloudprint-${version}";
18+ version = "20160502";
19+
20+ src = fetchFromGitHub {
21+ owner = "simoncadman";
22+ repo = "CUPS-Cloud-Print";
23+ rev = version;
24+ sha256 = "0760i12w7jrhq7fsgyz3yqla5cvpjb45n6m2jz96wsy3p3xf6dzz";
25+ };
26+
27+ buildInputs = [ cups makeWrapper ];
28+
29+ cupsgroup = "nonexistantgroup";
30+ NOPERMS = 1;
31+
32+ postConfigure = ''
33+ substituteInPlace Makefile --replace "${cups}" "$out"
34+ '';
35+
36+ postInstall = ''
37+ pushd "$out"
38+ for s in lib/cups/backend/gcp lib/cups/driver/cupscloudprint
39+ do
40+ echo "Wrapping $s..."
41+ wrapProgram "$out/$s" --set PATH "${lib.makeBinPath [pythonEnv file]}" --prefix PYTHONPATH : "$out/share/cloudprint-cups"
42+ done
43+
44+ mkdir bin
45+
46+ for s in share/cloudprint-cups/*.py
47+ do
48+ if [ -x "$s" ] # Only wrapping those Python scripts marked as executable
49+ then
50+ o="bin/$(echo $s | sed 's,share/cloudprint-cups/\(.*\).py,\1,')"
51+ echo "Wrapping $o -> $s..."
52+ makeWrapper "$out/$s" "$o" --set PATH "${lib.makeBinPath [pythonEnv file]}" --prefix PYTHONPATH : "$out/share/cloudprint-cups"
53+ fi
54+ done
55+ popd
56+ '';
57+
58+ meta = with stdenv.lib; {
59+ description = "Google Cloud Print driver for CUPS, allows printing to printers hosted on Google Cloud Print";
60+ homepage = http://ccp.niftiestsoftware.com;
61+ platforms = platforms.linux;
62+ license = licenses.gpl3;
63+ };
64+}