1{ lib, stdenv, fetchurl, unzip, makeWrapper, perlPackages
2, coreutils, zip, imagemagick, pngcrush, lcms2
3, facedetect, fbida }:
4
5# TODO: add optional dependencies (snippet from fgallery source):
6#
7# if(system("jpegoptim -V >/dev/null 2>&1")) {
8# $jpegoptim = 0;
9# }
10
11stdenv.mkDerivation rec {
12 pname = "fgallery";
13 version = "1.8.2";
14
15 src = fetchurl {
16 url = "https://www.thregr.org/~wavexx/software/fgallery/releases/fgallery-${version}.zip";
17 sha256 = "18wlvqbxcng8pawimbc8f2422s8fnk840hfr6946lzsxr0ijakvf";
18 };
19
20 nativeBuildInputs = [ makeWrapper unzip ];
21 buildInputs = (with perlPackages; [ perl ImageExifTool CpanelJSONXS ]);
22
23 installPhase = ''
24 mkdir -p "$out/bin"
25 mkdir -p "$out/share/fgallery"
26
27 cp -r * "$out/share/fgallery"
28 ln -s -r "$out/share/fgallery/fgallery" "$out/bin/fgallery"
29
30 # Don't preserve file attributes when copying files to output directories.
31 # (fgallery copies parts of itself to each output directory, and without
32 # this change the read-only nix store causes some bumps in the workflow.)
33 sed -i -e "s|'cp'|'cp', '--no-preserve=all'|g" "$out/share/fgallery/fgallery"
34
35 wrapProgram "$out/share/fgallery/fgallery" \
36 --set PERL5LIB "$PERL5LIB" \
37 --set PATH "${lib.makeBinPath
38 [ coreutils zip imagemagick pngcrush lcms2 facedetect fbida ]}"
39 '';
40
41 meta = with lib; {
42 description = "Static photo gallery generator";
43 homepage = "https://www.thregr.org/~wavexx/software/fgallery/";
44 license = licenses.gpl2;
45 platforms = platforms.all;
46 maintainers = [ maintainers.bjornfor ];
47 };
48}