-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
70 lines (60 loc) · 2.44 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
{
description = "SyntaxDot REST server images for WebLicht";
inputs = rec {
nixpkgs.follows = "syntaxdot-rest/nixpkgs";
syntaxdot-models.url = "github:tensordot/syntaxdot-models";
syntaxdot-rest.url = "github:tensordot/syntaxdot-rest";
utils.follows = "syntaxdot-rest/utils";
};
outputs = { self, nixpkgs, syntaxdot-models, syntaxdot-rest, utils }:
utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
};
in {
defaultPackage = self.packages.${system}.server;
packages =
let
# Shorthand for the syntaxdot-rest package.
syntaxdotRest = syntaxdot-rest.defaultPackage.${system};
# Arguments for docker image builders.
dockerImageArgs = {
name = "danieldk/syntaxdot-rest-server";
tag = syntaxdotRest.version;
config.Entrypoint = [ "${self.packages.${system}.server}/bin/syntaxdot-rest" ];
maxLayers = 100;
};
# Function to combine multiple pipelines into a syntaxdot-rest configuration.
mkPipelineSet = pkgs.callPackage ./pipeline-set.nix {};
# Alpino tokenizer protobuf.
alpinoTokenizerProtobuf = pkgs.fetchurl {
name = "alpino-tokenizer.proto";
url = "https://github.com/danieldk/alpino-tokenizer/releases/download/0.3.0/alpino-tokenizer-20200315.proto.gz";
hash = "sha256-mB+BvjKV9jXbqzj2L1uRWGIhyiT7Y5BLVQmJPtxExL4=";
downloadToTemp = true;
postFetch = ''
gunzip -c $downloadedFile > $out
'';
};
# Weblicht pipelines
weblichtPipelines = import ./weblicht-pipelines.nix {
inherit alpinoTokenizerProtobuf;
syntaxdotModels = syntaxdot-models.packages.${system};
};
in {
pipelines = mkPipelineSet weblichtPipelines;
server = with pkgs; runCommand "syntaxdot-rest-with-pipelines" { nativeBuildInputs = [ makeWrapper ]; } ''
makeWrapper \
${syntaxdotRest}/bin/syntaxdot-rest \
$out/bin/syntaxdot-rest \
--add-flags "${self.packages.${system}.pipelines}"
'';
dockerImage = pkgs.dockerTools.buildLayeredImage dockerImageArgs;
streamDockerImage = pkgs.dockerTools.streamLayeredImage dockerImageArgs;
};
});
}