about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/nanodbc/default.nix
blob: 64f362e3520260b958c2b5a1495dd7fd0529eba2 (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
{ lib, stdenv, fetchFromGitHub, cmake, unixODBC }:

stdenv.mkDerivation rec {
  pname = "nanodbc";
  version = "2.13.0";

  src = fetchFromGitHub {
    owner = "nanodbc";
    repo = "nanodbc";
    rev = "v${version}";
    sha256 = "1q80p7yv9mcl4hyvnvcjdr70y8nc940ypf368lp97vpqn5yckkgm";
  };

  nativeBuildInputs = [ cmake ];

  buildInputs = [ unixODBC ];

  cmakeFlags = if (stdenv.hostPlatform.isStatic) then
    [ "-DBUILD_STATIC_LIBS=ON" ]
  else
    [ "-DBUILD_SHARED_LIBS=ON" ];

  # fix compilation on macOS
  # https://github.com/nanodbc/nanodbc/issues/274
  # remove after the next version update
  postUnpack = if stdenv.isDarwin then ''
    mv $sourceRoot/VERSION $sourceRoot/VERSION.txt
    substituteInPlace $sourceRoot/CMakeLists.txt \
       --replace 'file(STRINGS VERSION' 'file(STRINGS VERSION.txt'
  '' else "";

  meta = with lib; {
    homepage = "https://github.com/nanodbc/nanodbc";
    changelog = "https://github.com/nanodbc/nanodbc/raw/v${version}/CHANGELOG.md";
    description = "Small C++ wrapper for the native C ODBC API";
    license = licenses.mit;
    maintainers = [ maintainers.bzizou ];
  };
}