WIP: create tests

This commit is contained in:
Oystein Kristoffer Tveit 2023-08-01 22:34:55 +02:00
parent f5bb4ac8c2
commit f3fcbc2b40
Signed by untrusted user: oysteikt
GPG Key ID: 9F2F7D8250F35146
5 changed files with 73 additions and 2 deletions

View File

@ -1,5 +1,20 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1690789960,
"narHash": "sha256-3K+2HuyGTiJUSZNJxXXvc0qj4xFx1FHC/ItYtEa7/Xs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fb942492b7accdee4e6d17f5447091c65897dde4",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1673743903,
@ -17,6 +32,7 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"nixpkgs-lib": "nixpkgs-lib"
}
}

View File

@ -2,13 +2,27 @@
description = "NixOS modules for matrix related services";
inputs = {
nixpkgs-lib.url = github:nix-community/nixpkgs.lib;
nixpkgs-lib.url = "github:nix-community/nixpkgs.lib";
nixpkgs.url = "nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs-lib }: {
outputs = { self, nixpkgs, nixpkgs-lib }: {
nixosModules = {
default = import ./module.nix;
};
lib = import ./lib.nix { lib = nixpkgs-lib.lib; };
packages = let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
${system}.tests = import ./tests {
inherit system;
inherit nixpkgs;
inherit pkgs;
nixosModule = self.outputs.nixosModules.synapse;
};
};
};
}

View File

@ -0,0 +1,18 @@
{ pkgs, lib, ... }:
{
services.matrix-synapse-next = {
enable = true;
settings.server_name = "matrix.example.com";
workers = {
enableMetrics = true;
federationSenders = 2;
federationReceivers = 2;
initialSyncers = 2;
normalSyncers = 2;
eventPersisters = 2;
useUserDirectoryWorker = true;
};
};
}

7
tests/base-config.nix Normal file
View File

@ -0,0 +1,7 @@
{ pkgs, lib, ... }:
{
services.matrix-synapse-next = {
enable = true;
settings.server_name = "matrix.example.com";
};
}

16
tests/default.nix Normal file
View File

@ -0,0 +1,16 @@
{ nixpkgs, pkgs, system ? pkgs.system, nixosModule, ... }: let
buildSystemWithConfig = configPath: (nixpkgs.lib.nixosSystem {
inherit system;
modules = [
nixosModule
configPath
{
boot.isContainer = true;
}
];
}).config.system.build.toplevel;
in {
a = pkgs.writeText "hello-world" ''a'';
base-config = buildSystemWithConfig ./base-config.nix;
auto-workers-config = buildSystemWithConfig ./auto-workers-config.nix;
}