summaryrefslogtreecommitdiff
path: root/pkgs/mssql-tools.nix
blob: ecf2b378734f68b358fc0c0c1dc819f56696f9f4 (plain)
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
49
50
51
52
53
54
55
# Basado en derivación para skypeforlinux en nixpkgs
# Ver environment.unixODBCDrivers
{
  lib,
  stdenv,
  fetchurl,
  dpkg,
  glibc,
  unixODBC,
}: let
  version = "17.9.1.1-1";
  ubuntuRelease = "21.10";
in
  stdenv.mkDerivation {
    pname = "mssql-tools";
    inherit version;

    system = "x86_64-linux";

    src =
      if stdenv.hostPlatform.system == "x86_64-linux"
      then
        fetchurl
        {
          url = "https://packages.microsoft.com/ubuntu/${ubuntuRelease}/prod/pool/main/m/mssql-tools/mssql-tools_${version}_amd64.deb";
          sha256 = "0ya9643assr80yh6g0nd3i6iw819frhbb1m421khwplk9iq793kk";
        }
      else throw "mssql-tools is not supported on ${stdenv.hostPlatform.system}";

    buildInputs = [dpkg];
    dontUnpack = true;
    outputs = ["out" "doc"];

    installPhase = ''
      mkdir -p $out
      dpkg -x $src $out
      mv $out/opt/mssql-tools/{bin,share} $out
      mv $out/usr/share/doc/mssql-tools $doc
      rm -r $out/opt $out/usr
    '';

    postFixup = let
      rpath = lib.makeLibraryPath [glibc stdenv.cc.cc unixODBC];
    in ''
      for file in $(find $out/bin -type f); do
        patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file"
        patchelf --set-rpath ${rpath} $file
      done
    '';

    meta = with lib; {
      license = licenses.unfree;
      platforms = ["x86_64-linux"];
    };
  }