forked from stackabletech/secret-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
89 lines (87 loc) · 2.86 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ 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 // {
prost-build = attrs: {
buildInputs = [ pkgs.protobuf ];
};
tonic-reflection = attrs: {
buildInputs = [ pkgs.rustfmt ];
};
stackable-secret-operator = attrs: {
buildInputs = [ pkgs.protobuf pkgs.rustfmt ];
};
krb5-sys = attrs: {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.krb5 ];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.glibc.dev}/include -I${pkgs.clang.cc.lib}/lib/clang/${pkgs.lib.getVersion pkgs.clang.cc}/include";
};
libgssapi-sys = attrs: {
buildInputs = [ pkgs.krb5 ];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.glibc.dev}/include -I${pkgs.clang.cc.lib}/lib/clang/${pkgs.lib.getVersion pkgs.clang.cc}/include";
};
};
}
, meta ? pkgs.lib.importJSON ./nix/meta.json
, dockerName ? "docker.stackable.tech/sandbox/${meta.operator.name}"
, dockerTag ? null
}:
rec {
build = cargo.allWorkspaceMembers;
entrypoint = build+"/bin/stackable-${meta.operator.name}";
crds = pkgs.runCommand "${meta.operator.name}-crds.yaml" {}
''
${entrypoint} crd > $out
'';
dockerImage = pkgs.dockerTools.streamLayeredImage {
name = dockerName;
tag = dockerTag;
contents = [
# Common debugging tools
pkgs.bashInteractive pkgs.coreutils pkgs.util-linuxMinimal
# Kerberos 5 must be installed globally to load plugins correctly
pkgs.krb5
# 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;
}
{
name = "crds.yaml";
path = crds;
}
];
# need to use vendored crate2nix because of https://github.com/kolloch/crate2nix/issues/264
crate2nix = import sources.crate2nix {};
tilt = pkgs.tilt;
}