btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libgphoto2 / package.nix
blob31f4130d663ded03a265fda90dbeb3b25b4e8117
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , buildPackages
5 , autoreconfHook
6 , pkg-config
7 , gettext
8 , libusb1
9 , libtool
10 , libexif
11 , libgphoto2
12 , libjpeg
13 , curl
14 , libxml2
15 , gd
18 stdenv.mkDerivation rec {
19   pname = "libgphoto2";
20   version = "2.5.31";
22   src = fetchFromGitHub {
23     owner = "gphoto";
24     repo = "libgphoto2";
25     rev = "libgphoto2-${builtins.replaceStrings [ "." ] [ "_" ] version}-release";
26     sha256 = "sha256-UmyDKEaPP9VJqi8f+y6JZcTlQomhMTN+/C//ODYx6/w=";
27   };
29   depsBuildBuild = [ pkg-config ];
31   nativeBuildInputs = [
32     autoreconfHook
33     gettext
34     libtool
35     pkg-config
36   ];
38   buildInputs = [
39     libjpeg
40     libtool # for libltdl
41     libusb1
42     curl
43     libxml2
44     gd
45   ];
47   # These are mentioned in the Requires line of libgphoto's pkg-config file.
48   propagatedBuildInputs = [ libexif ];
50   env = lib.optionalAttrs stdenv.cc.isGNU {
51     NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types";
52   };
54   hardeningDisable = [ "format" ];
56   postInstall =
57     let
58       executablePrefix =
59         if stdenv.buildPlatform == stdenv.hostPlatform then
60           "$out"
61         else
62           buildPackages.libgphoto2;
63     in
64     ''
65       mkdir -p $out/lib/udev/{rules.d,hwdb.d}
66       ${executablePrefix}/lib/libgphoto2/print-camera-list \
67           udev-rules version 201 group camera \
68           >$out/lib/udev/rules.d/40-libgphoto2.rules
69       ${executablePrefix}/lib/libgphoto2/print-camera-list \
70           hwdb version 201 group camera \
71           >$out/lib/udev/hwdb.d/20-gphoto.hwdb
72     '';
74   meta = {
75     homepage = "http://www.gphoto.org/proj/libgphoto2/";
76     description = "Library for accessing digital cameras";
77     longDescription = ''
78       This is the library backend for gphoto2. It contains the code for PTP,
79       MTP, and other vendor specific protocols for controlling and transferring data
80       from digital cameras.
81     '';
82     # XXX: the homepage claims LGPL, but several src files are lgpl21Plus
83     license = lib.licenses.lgpl21Plus;
84     platforms = with lib.platforms; unix;
85     maintainers = with lib.maintainers; [ jcumming ];
86   };