about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/sqitch/default.nix
blob: 32235e85c48d21aeb5994dd9142b0a6a0c122c12 (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
{ stdenv
, lib
, perlPackages
, makeWrapper
, shortenPerlShebang
, mysqlSupport ? false
, postgresqlSupport ? false
, templateToolkitSupport ? false
}:

let
  sqitch = perlPackages.AppSqitch;
  modules = with perlPackages; [ AlgorithmBackoff ]
    ++ lib.optional mysqlSupport DBDmysql
    ++ lib.optional postgresqlSupport DBDPg
    ++ lib.optional templateToolkitSupport TemplateToolkit;
in

stdenv.mkDerivation {
  pname = "sqitch";
  version = sqitch.version;

  nativeBuildInputs = [ makeWrapper ] ++ lib.optional stdenv.isDarwin shortenPerlShebang;

  src = sqitch;
  dontBuild = true;

  installPhase = ''
    mkdir -p $out/bin
    for d in bin/sqitch etc lib share ; do
      # make sure dest alreay exists before symlink
      # this prevents installing a broken link into the path
      if [ -e ${sqitch}/$d ]; then
        ln -s ${sqitch}/$d $out/$d
      fi
    done
  '' + lib.optionalString stdenv.isDarwin ''
    shortenPerlShebang $out/bin/sqitch
  '';
  dontStrip = true;
  postFixup = ''
    wrapProgram $out/bin/sqitch --prefix PERL5LIB : ${lib.escapeShellArg (perlPackages.makeFullPerlPath modules)}
  '';

  meta = {
    inherit (sqitch.meta) description homepage license platforms;
  };
}