nginx-pipeline: add basic test

pull/7/head
Oystein Kristoffer Tveit 2024-01-27 07:39:59 +01:00
parent 18d3b34406
commit 19d50fae63
Signed by untrusted user: oysteikt
GPG Key ID: 9F2F7D8250F35146
5 changed files with 73 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

View File

@ -1,23 +1,23 @@
{
"nodes": {
"nixpkgs-lib": {
"nixpkgs": {
"locked": {
"lastModified": 1673743903,
"narHash": "sha256-sloY6KYyVOozJ1CkbgJPpZ99TKIjIvM+04V48C04sMQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "7555e2dfcbac1533f047021f1744ac8871150f9f",
"lastModified": 1706098335,
"narHash": "sha256-r3dWjT8P9/Ah5m5ul4WqIWD8muj5F+/gbCdjiNVBKmU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a77ab169a83a4175169d78684ddd2e54486ac651",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
"nixpkgs": "nixpkgs"
}
}
},

View File

@ -2,13 +2,29 @@
description = "NixOS modules for matrix related services";
inputs = {
nixpkgs-lib.url = github:nix-community/nixpkgs.lib;
nixpkgs.url = "nixpkgs/nixos-23.11";
};
outputs = { self, nixpkgs-lib }: {
outputs = { self, nixpkgs }: {
nixosModules = {
default = import ./module.nix;
};
lib = import ./lib.nix { lib = nixpkgs-lib.lib; };
lib = import ./lib.nix { lib = nixpkgs.lib; };
packages = let
forAllSystems = f:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (system: f nixpkgs.legacyPackages.${system});
in forAllSystems (pkgs: {
tests = import ./tests {
inherit nixpkgs pkgs;
matrix-lib = self.lib;
};
});
};
}

4
tests/default.nix Normal file
View File

@ -0,0 +1,4 @@
{ nixpkgs, pkgs, matrix-lib, ... }:
{
nginx-pipeline = pkgs.callPackage ./nginx-pipeline { inherit nixpkgs matrix-lib; };
}

View File

@ -0,0 +1,39 @@
{ nixpkgs, lib, matrix-lib, writeText, ... }:
let
nixosConfig = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
../../module.nix
{
system.stateVersion = "23.11";
boot.isContainer = true;
services.matrix-synapse-next = {
enable = true;
enableNginx = true;
workers = {
enableMetrics = true;
federationSenders = 3;
federationReceivers = 3;
initialSyncers = 1;
normalSyncers = 1;
eventPersisters = 1;
useUserDirectoryWorker = true;
};
settings.server_name = "example.com";
};
}
];
};
inherit (nixosConfig.config.services.matrix-synapse-next.workers) instances;
in
writeText "matrix-synapse-next-nginx-pipeline-test.txt" ''
${(lib.generators.toPretty {}) instances}
====================================================
${(lib.generators.toPretty {}) (matrix-lib.mapWorkersToUpstreamsByType instances)}
''