about summary refs log tree commit diff
path: root/pkgs/development/tools/database/shmig/default.nix
blob: 3e7e640c88b59956102c87ddd3dd0307fbaa427e (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
{ stdenv, fetchFromGitHub
, withMySQL ? true, withPSQL ? false, withSQLite ? false
, mariadb, postgresql, sqlite, gawk, gnugrep, findutils, gnused
, lib
}:

stdenv.mkDerivation rec {
  pname = "shmig";
  version = "1.0.0";

  src = fetchFromGitHub {
    owner = "mbucc";
    repo = "shmig";
    rev = "v${version}";
    sha256 = "15ry1d51d6dlzzzhck2x57wrq48vs4n9pp20bv2sz6nk92fva5l5";
  };

  makeFlags = [ "PREFIX=$(out)" ];

  postPatch = ''
    patchShebangs .

    substituteInPlace shmig \
      --replace "\`which mysql\`" "${lib.optionalString withMySQL "${mariadb.client}/bin/mysql"}" \
      --replace "\`which psql\`" "${lib.optionalString withPSQL "${postgresql}/bin/psql"}" \
      --replace "\`which sqlite3\`" "${lib.optionalString withSQLite "${sqlite}/bin/sqlite3"}" \
      --replace "awk" "${gawk}/bin/awk" \
      --replace "grep" "${gnugrep}/bin/grep" \
      --replace "find" "${findutils}/bin/find" \
      --replace "sed" "${gnused}/bin/sed"
  '';

  preBuild = ''
    mkdir -p $out/bin
  '';

  meta = with lib; {
    description = "Minimalistic database migration tool with MySQL, PostgreSQL and SQLite support";
    mainProgram = "shmig";
    homepage = "https://github.com/mbucc/shmig";
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}