-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdefault.nix
68 lines (66 loc) · 2.12 KB
/
default.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
{ sources ? import ./nix/sources.nix # managed by https://github.com/nmattia/niv
, nixpkgs ? sources.nixpkgs
, pkgs ? import nixpkgs {}
, cargo ? import ./Cargo.nix {
inherit nixpkgs pkgs; release = false;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
# FIXME: Remove when https://github.com/NixOS/nixpkgs/pull/266787 is merged.
# See https://github.com/stackabletech/operator-templating/pull/289 for details.
ring = attrs: {
CARGO_MANIFEST_LINKS = attrs.links;
};
# Specific to trino-lb
pyo3-build-config = attrs: {
buildInputs = [ pkgs.python3 ];
};
};
}
, meta ? pkgs.lib.importJSON ./nix/meta.json
, dockerName ? "docker.stackable.tech/sandbox/${meta.operator.name}"
, dockerTag ? null
}:
rec {
build = cargo.allWorkspaceMembers;
entrypoint = build+"/bin/${meta.operator.name}";
dockerImage = pkgs.dockerTools.streamLayeredImage {
name = dockerName;
tag = dockerTag;
contents = [
# Common debugging tools
pkgs.bashInteractive pkgs.coreutils pkgs.util-linuxMinimal
# Make the whole cargo workspace available on $PATH
build
];
config = {
Env =
let
fileRefVars = {
PRODUCT_CONFIG = deploy/config-spec/properties.yaml;
};
in pkgs.lib.concatLists (pkgs.lib.mapAttrsToList (env: path: pkgs.lib.optional (pkgs.lib.pathExists path) "${env}=${path}") fileRefVars);
Entrypoint = [ entrypoint ];
Cmd = [ "run" ];
};
};
docker = pkgs.linkFarm "listener-operator-docker" [
{
name = "load-image";
path = dockerImage;
}
{
name = "ref";
path = pkgs.writeText "${dockerImage.name}-image-tag" "${dockerImage.imageName}:${dockerImage.imageTag}";
}
{
name = "image-repo";
path = pkgs.writeText "${dockerImage.name}-repo" dockerImage.imageName;
}
{
name = "image-tag";
path = pkgs.writeText "${dockerImage.name}-tag" dockerImage.imageTag;
}
];
# need to use vendored crate2nix because of https://github.com/kolloch/crate2nix/issues/264
crate2nix = import sources.crate2nix;
tilt = pkgs.tilt;
}