about summary refs log tree commit diff
path: root/pkgs/by-name/gr/graphicsmagick/imagemagick-compat.nix
blob: 9e278da037bc859440bc0fd548f28555d57876fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{ lib
, graphicsmagick
, stdenvNoCC
}:

stdenvNoCC.mkDerivation {
  pname = "graphicsmagick-imagemagick-compat";
  inherit (graphicsmagick) version;

  outputs = [ "out" "man" ];

  dontUnpack = true;
  dontBuild = true;

  # TODO: symlink libraries?
  installPhase = let
    utilities = [
      "animate"
      "composite"
      "conjure"
      "convert"
      "display"
      "identify"
      "import"
      "mogrify"
      "montage"
    ];
    linkUtilityBin = utility: ''
      ln -s ${lib.getExe graphicsmagick} "$out/bin/${utility}"
    '';
    linkUtilityMan = utility: ''
      ln -s ${lib.getMan graphicsmagick}/share/man/man1/gm.1.gz "$man/share/man/man1/${utility}.1.gz"
    '';
  in ''
    runHook preInstall

    mkdir -p "$out"/bin
    ${lib.concatStringsSep "\n" (map linkUtilityBin utilities)}
    mkdir -p "$man"/share/man/man1
    ${lib.concatStringsSep "\n" (map linkUtilityMan utilities)}

    runHook postInstall
  '';

  meta = graphicsmagick.meta // {
    description = "A repack of GraphicsMagick that provides compatibility with ImageMagick interfaces";
  };
}