-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
90 lines (73 loc) · 2.47 KB
/
flake.nix
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "SyntaxDot FFI";
inputs = {
crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, crate2nix, nixpkgs, utils }:
utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [
"libtorch"
];
};
};
in {
devShell = with pkgs; mkShell {
nativeBuildInputs = [ cmake pkg-config rustup ];
buildInputs = [ openssl ];
LIBTORCH = symlinkJoin {
name = "torch-join";
paths = [ libtorch-bin.dev libtorch-bin.out ];
};
PROTOC = "${protobuf}/bin/protoc";
DUTCH_UD_MEDIUM = fetchTarball {
url = "https://s3.tensordot.com/syntaxdot/models/nl-ud-medium-20210312.tar.gz";
sha256 = "0fysnjb62l55hi1xsdlgrxdwrg8c0wc6jl0w29y60jmmgfydqwl2";
};
};
defaultPackage = let
crateOverrides = pkgs.callPackage build-support/crate-overrides.nix {};
crateTools = pkgs.callPackage "${crate2nix}/tools.nix" {};
buildRustCrate = pkgs.buildRustCrate.override {
defaultCrateOverrides = crateOverrides;
};
cargoNix = pkgs.callPackage (crateTools.generatedCargoNix {
name = "syntaxdot";
src = ./.;
}) {
inherit buildRustCrate;
};
crate = cargoNix.rootCrate.build;
in with pkgs; stdenv.mkDerivation {
pname = "libsyntaxdot-ffi";
version = crate.version;
src = ./.;
outputs = [ "out" "dev" ];
nativeBuildInputs = [ removeReferencesTo ];
dontConfigure = true;
installPhase = ''
runHook preInstall
install -Dm 0644 -t $dev/include include/syntaxdot.h
install -Dm 0755 -t $out/lib ${crate.lib}/lib/libsyntaxdot_ffi.so
remove-references-to -t ${libtorch-bin.dev} \
$out/lib/libsyntaxdot_ffi.so
runHook postinstall
'';
disallowedReferences = [ libtorch-bin.dev ];
meta = with lib; {
description = "C FFI for the SyntaxDot neural syntax annotator";
license = licenses.agpl3Only;
maintainers = with maintainers; [ danieldk ];
platforms = platforms.linux;
};
};
});
}