-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
143 lines (126 loc) · 4.09 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
{
description = "fabric";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flakeutils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk";
};
outputs = { self, nixpkgs, flakeutils, naersk }:
flakeutils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
naersk-lib = naersk.lib."${system}";
pypkgs = pkgs.python38Packages;
cliVersion = "0.2.0";
in
rec {
# Operator (server)
packages.kube-workspace-operator = naersk-lib.buildPackage {
pname = "kube-workspace-operator";
src = builtins.filterSource
# Filter out directories unrelated to the Rust crate.
# This avoids rebuilds when unrelated things change.
(path: type:
let
filename = (baseNameOf path);
# TODO: only filter main path, not nested paths too
included = !(builtins.elem filename
[
".git"
".github"
".mypy_cache"
"cli"
"deploy"
"result"
"tests"
"xtask"
".gitignore"
"flake.lock"
"flake.nix"
".git"
]);
in
included
)
./.
;
root = ./.;
buildInputs = with pkgs; [
pkgconfig
openssl
];
};
# Operator Docker image.
# To build, run `nix build .#docker-image-operator`.
# This will put the image into `./result`, which can then be
# loaded into the Docker daemon with `docker load < ./result`.
packages.docker-image-operator = pkgs.dockerTools.buildImage {
name = "refaktory/kube-workspace-operator";
tag = "${packages.kube-workspace-operator.version}";
config = {
Cmd = [ "${packages.kube-workspace-operator}/bin/kube-workspace-operator" ];
ExposedPorts = {
"8080/tcp" = { };
};
Volumes = {
"/config" = { };
};
};
};
# CLI
packages.kube-workspace-cli = pypkgs.buildPythonPackage {
pname = "kworkspace";
version = cliVersion;
src = ./cli;
postShellHook = ''
mv $out/bin/kworkspace.py $out/bin/kworkspace
'';
meta = {
homepage = "https://github.com/theduke/kube-workspaces";
description = "CLI for kube-workspaces";
};
};
packages.docker-image-cli = pkgs.dockerTools.buildImage {
name = "refaktory/kube-workspace-cli";
tag = cliVersion;
config = {
Cmd = [ "${packages.kube-workspace-cli}/bin/kworkspace" ];
};
};
apps.kube-workspace-operator = flakeutils.lib.mkApp {
drv = packages.kube-workspace-operator;
};
apps.cli = flakeutils.lib.mkApp {
drv = packages.kube-workspace-cli;
};
defaultApp = apps.kube-workspace-operator;
devShell = pkgs.stdenv.mkDerivation {
name = "kube-workspace-operator";
src = self;
buildInputs = with pkgs; [
pkgconfig
# Python formatter.
black
# Python type checker.
mypy
# Python linter.
pypkgs.pylint
# Python LSP
pyright
# kind (Kubernetes in Docker) for integration tests.
kind
];
propagatedBuildInputs = with pkgs; [
openssl
];
buildPhase = "";
installPhase = "";
# Allow `cargo run` etc to find ssl lib.
LD_LIBRARY_PATH = "${pkgs.openssl.out}/lib";
RUST_BACKTRACE = "1";
RUST_LOG = "kube_workspace_operator=trace";
KUBE_WORKSPACE_OPERATOR_CONFIG = "./deploy/config.json";
};
}
);
}