Skip to content

Commit 5769312

Browse files
yvan-srakajfroche
authored andcommitted
Install envoy using system manager
1 parent e5e1b82 commit 5769312

File tree

7 files changed

+68
-2
lines changed

7 files changed

+68
-2
lines changed

nix/packages/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
dbmate-tool = pkgs.callPackage ./dbmate-tool.nix { inherit (self.supabase) defaults; };
3737
docker-image-ubuntu = pkgs.callPackage ./docker-ubuntu.nix { };
3838
docs = pkgs.callPackage ./docs.nix { };
39+
envoy-bin = pkgs.callPackage ./envoy-bin.nix { };
3940
supabase-groonga = pkgs.callPackage ./groonga { };
4041
local-infra-bootstrap = pkgs.callPackage ./local-infra-bootstrap.nix { };
4142
migrate-tool = pkgs.callPackage ./migrate-tool.nix { psql_15 = self'.packages."psql_15/bin"; };

nix/packages/docker-ubuntu.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
{ runCommand, dockerTools, xz, buildEnv }:
1+
{
2+
runCommand,
3+
dockerTools,
4+
xz,
5+
buildEnv,
6+
}:
27
let
38
ubuntu-cloudimg =
49
let

nix/packages/envoy-bin.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
envoy-bin,
3+
fetchurl,
4+
stdenv,
5+
...
6+
}:
7+
let
8+
version = "1.28.0";
9+
inherit (stdenv.hostPlatform) system;
10+
throwSystem = throw "envoy-bin is not available for ${system}.";
11+
plat =
12+
{
13+
aarch64-linux = "aarch_64";
14+
x86_64-linux = "x86_64";
15+
}
16+
.${system} or throwSystem;
17+
hash =
18+
{
19+
aarch64-linux = "";
20+
x86_64-linux = "sha256-JjlWPOm8CbHua9RzF2C1lsjtHkdM3YPMnfk2RRbhQ2c=";
21+
}
22+
.${system} or throwSystem;
23+
in
24+
envoy-bin.overrideAttrs {
25+
inherit version;
26+
src = fetchurl {
27+
url = "https://github.com/envoyproxy/envoy/releases/download/v${version}/envoy-${version}-linux-${plat}";
28+
inherit hash;
29+
};
30+
}

nix/systemModules/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
{
55
imports = [ ./tests ];
66
flake = {
7-
systemModules = { };
7+
systemModules = {
8+
envoy = ./envoy.nix;
9+
};
810
};
911
}

nix/systemModules/envoy.nix

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
lib,
3+
nixosModulesPath,
4+
self',
5+
...
6+
}:
7+
{
8+
imports = map (path: nixosModulesPath + path) [
9+
"/services/networking/envoy.nix"
10+
];
11+
config = {
12+
services.envoy = {
13+
enable = true;
14+
package = self'.packages.envoy-bin;
15+
# TODO: settings from postgres/ansible/files/envoy_config/
16+
};
17+
systemd.services.envoy = {
18+
wantedBy = lib.mkForce [
19+
"system-manager.target"
20+
];
21+
};
22+
};
23+
}

nix/systemModules/tests/default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
lib = pkgs.lib;
1515
systemManagerConfig = self.inputs.system-manager.lib.makeSystemConfig {
1616
modules = [
17+
self.systemModules.envoy
1718
({
1819
services.nginx.enable = true;
1920
nixpkgs.hostPlatform = pkgs.system;
2021
})
2122
];
23+
extraSpecialArgs = { inherit self'; };
2224
};
2325

2426
dockerImageUbuntuWithTools =

nix/systemModules/tests/test_envoy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def test_envoy_service(host):
2+
assert host.service("envoy.service").is_valid
3+
assert host.service("envoy.service").is_running

0 commit comments

Comments
 (0)