mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
chore: rewrite devshell, remove checks
This commit is contained in:
-105
@@ -1,105 +0,0 @@
|
|||||||
{ inputs, ... }:
|
|
||||||
{
|
|
||||||
perSystem =
|
|
||||||
{
|
|
||||||
self',
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
uwulib = inputs.self.uwulib.init pkgs;
|
|
||||||
|
|
||||||
rocksdb = self'.packages.rocksdb;
|
|
||||||
|
|
||||||
commonAttrs = (uwulib.build.commonAttrs { }) // {
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.liburing
|
|
||||||
pkgs.rust-jemalloc-sys-unprefixed
|
|
||||||
rocksdb
|
|
||||||
];
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.pkg-config
|
|
||||||
# bindgen needs the build platform's libclang. Apparently due to "splicing
|
|
||||||
# weirdness", pkgs.rustPlatform.bindgenHook on its own doesn't quite do the
|
|
||||||
# right thing here.
|
|
||||||
pkgs.rustPlatform.bindgenHook
|
|
||||||
];
|
|
||||||
env = {
|
|
||||||
LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
|
||||||
LD_LIBRARY_PATH = lib.makeLibraryPath [
|
|
||||||
pkgs.liburing
|
|
||||||
pkgs.rust-jemalloc-sys-unprefixed
|
|
||||||
rocksdb
|
|
||||||
];
|
|
||||||
}
|
|
||||||
// uwulib.environment.buildPackageEnv
|
|
||||||
// {
|
|
||||||
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
|
|
||||||
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
cargoArtifacts = self'.packages.continuwuity-all-features-deps;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# taken from
|
|
||||||
#
|
|
||||||
# https://crane.dev/examples/quick-start.html
|
|
||||||
checks = {
|
|
||||||
continuwuity-all-features-build = self'.packages.continuwuity-all-features-bin;
|
|
||||||
|
|
||||||
continuwuity-all-features-clippy = uwulib.build.craneLibForChecks.cargoClippy (
|
|
||||||
commonAttrs
|
|
||||||
// {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
cargoClippyExtraArgs = "-- --deny warnings";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
continuwuity-all-features-docs = uwulib.build.craneLibForChecks.cargoDoc (
|
|
||||||
commonAttrs
|
|
||||||
// {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
# This can be commented out or tweaked as necessary, e.g. set to
|
|
||||||
# `--deny rustdoc::broken-intra-doc-links` to only enforce that lint
|
|
||||||
env.RUSTDOCFLAGS = "--deny warnings";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Check formatting
|
|
||||||
continuwuity-all-features-fmt = uwulib.build.craneLibForChecks.cargoFmt {
|
|
||||||
src = uwulib.build.src;
|
|
||||||
};
|
|
||||||
|
|
||||||
continuwuity-all-features-toml-fmt = uwulib.build.craneLibForChecks.taploFmt {
|
|
||||||
src = pkgs.lib.sources.sourceFilesBySuffices uwulib.build.src [ ".toml" ];
|
|
||||||
# taplo arguments can be further customized below as needed
|
|
||||||
taploExtraArgs = "--config ${inputs.self}/taplo.toml";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Audit dependencies
|
|
||||||
continuwuity-all-features-audit = uwulib.build.craneLibForChecks.cargoAudit {
|
|
||||||
inherit (inputs) advisory-db;
|
|
||||||
src = uwulib.build.src;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Audit licenses
|
|
||||||
continuwuity-all-features-deny = uwulib.build.craneLibForChecks.cargoDeny {
|
|
||||||
src = uwulib.build.src;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Run tests with cargo-nextest
|
|
||||||
# Consider setting `doCheck = false` on `continuwuity-all-features` if you do not want
|
|
||||||
# the tests to run twice
|
|
||||||
continuwuity-all-features-nextest = uwulib.build.craneLibForChecks.cargoNextest (
|
|
||||||
commonAttrs
|
|
||||||
// {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
partitions = 1;
|
|
||||||
partitionType = "count";
|
|
||||||
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{ inputs, ... }:
|
||||||
|
{
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
self',
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
_module.args.craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (
|
||||||
|
pkgs: self'.packages.stable-toolchain
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
+4
-5
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./packages
|
|
||||||
./checks.nix
|
|
||||||
./devshell.nix
|
|
||||||
./tests.nix
|
|
||||||
./fmt.nix
|
|
||||||
./rust.nix
|
./rust.nix
|
||||||
|
./crane.nix
|
||||||
|
./packages
|
||||||
|
./devshell.nix
|
||||||
|
./fmt.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-9
@@ -1,27 +1,21 @@
|
|||||||
{ inputs, ... }:
|
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
|
craneLib,
|
||||||
self',
|
self',
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
uwulib = inputs.self.uwulib.init pkgs;
|
|
||||||
rocksdbAllFeatures = self'.packages.rocksdb.override {
|
|
||||||
enableJemalloc = true;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
# basic nix shell containing all things necessary to build continuwuity in all flavors manually (on x86_64-linux)
|
# basic nix shell containing all things necessary to build continuwuity in all flavors manually (on x86_64-linux)
|
||||||
devShells.default = uwulib.build.craneLib.devShell {
|
devShells.default = craneLib.devShell {
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.nodejs
|
pkgs.nodejs
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
pkgs.liburing
|
pkgs.liburing
|
||||||
pkgs.rust-jemalloc-sys-unprefixed
|
pkgs.rust-jemalloc-sys-unprefixed
|
||||||
rocksdbAllFeatures
|
self'.packages.rocksdb
|
||||||
];
|
];
|
||||||
env.LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
env.LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -36,18 +36,22 @@
|
|||||||
|
|
||||||
cargoArtifacts = crane.buildDepsOnly common;
|
cargoArtifacts = crane.buildDepsOnly common;
|
||||||
|
|
||||||
|
rocksdb = pkgs.callPackage ./rocksdb.nix { };
|
||||||
|
|
||||||
continuwuity = crane.buildPackage (
|
continuwuity = crane.buildPackage (
|
||||||
common
|
common
|
||||||
// {
|
// {
|
||||||
inherit cargoArtifacts;
|
inherit cargoArtifacts;
|
||||||
doCheck = false;
|
env = {
|
||||||
env.LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ];
|
ROCKSDB_INCLUDE_DIR = "${rocksdb}/include";
|
||||||
|
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
default = continuwuity;
|
default = continuwuity;
|
||||||
rocksdb = pkgs.callPackage ./rocksdb.nix { };
|
inherit rocksdb;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
owner = "continuwuation";
|
owner = "continuwuation";
|
||||||
repo = "rocksdb";
|
repo = "rocksdb";
|
||||||
rev = version;
|
rev = version;
|
||||||
sha256 = "";
|
sha256 = "sha256-X4ApGLkHF9ceBtBg77dimEpu720I79ffLoyPa8JMHaU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
# We have this already at https://forgejo.ellis.link/continuwuation/rocksdb/commit/a935c0273e1ba44eacf88ce3685a9b9831486155
|
||||||
|
|||||||
+5
-5
@@ -4,6 +4,7 @@
|
|||||||
{
|
{
|
||||||
system,
|
system,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
let
|
let
|
||||||
fnx = inputs.fenix.packages.${system};
|
fnx = inputs.fenix.packages.${system};
|
||||||
|
|
||||||
stable = fnx.fromToolchainFile {
|
stable-toolchain = fnx.fromToolchainFile {
|
||||||
file = inputs.self + "/rust-toolchain.toml";
|
file = inputs.self + "/rust-toolchain.toml";
|
||||||
|
|
||||||
# See also `rust-toolchain.toml`
|
# See also `rust-toolchain.toml`
|
||||||
@@ -19,11 +20,10 @@
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# used for building nix stuff (doesn't include rustfmt overhead)
|
inherit stable-toolchain;
|
||||||
build-toolchain = stable;
|
|
||||||
# used for dev shells
|
|
||||||
dev-toolchain = fnx.combine [
|
dev-toolchain = fnx.combine [
|
||||||
stable
|
stable-toolchain
|
||||||
# use the nightly rustfmt because we use nightly features
|
# use the nightly rustfmt because we use nightly features
|
||||||
fnx.complete.rustfmt
|
fnx.complete.rustfmt
|
||||||
];
|
];
|
||||||
|
|||||||
-150
@@ -1,150 +0,0 @@
|
|||||||
{
|
|
||||||
perSystem =
|
|
||||||
{
|
|
||||||
self',
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
baseTestScript =
|
|
||||||
pkgs.writers.writePython3Bin "do_test" { libraries = [ pkgs.python3Packages.matrix-nio ]; }
|
|
||||||
''
|
|
||||||
import asyncio
|
|
||||||
import nio
|
|
||||||
|
|
||||||
|
|
||||||
async def main() -> None:
|
|
||||||
# Connect to continuwuity
|
|
||||||
client = nio.AsyncClient("http://continuwuity:6167", "alice")
|
|
||||||
|
|
||||||
# Register as user alice
|
|
||||||
response = await client.register("alice", "my-secret-password")
|
|
||||||
|
|
||||||
# Log in as user alice
|
|
||||||
response = await client.login("my-secret-password")
|
|
||||||
|
|
||||||
# Create a new room
|
|
||||||
response = await client.room_create(federate=False)
|
|
||||||
print("Matrix room create response:", response)
|
|
||||||
assert isinstance(response, nio.RoomCreateResponse)
|
|
||||||
room_id = response.room_id
|
|
||||||
|
|
||||||
# Join the room
|
|
||||||
response = await client.join(room_id)
|
|
||||||
print("Matrix join response:", response)
|
|
||||||
assert isinstance(response, nio.JoinResponse)
|
|
||||||
|
|
||||||
# Send a message to the room
|
|
||||||
response = await client.room_send(
|
|
||||||
room_id=room_id,
|
|
||||||
message_type="m.room.message",
|
|
||||||
content={
|
|
||||||
"msgtype": "m.text",
|
|
||||||
"body": "Hello continuwuity!"
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print("Matrix room send response:", response)
|
|
||||||
assert isinstance(response, nio.RoomSendResponse)
|
|
||||||
|
|
||||||
# Sync responses
|
|
||||||
response = await client.sync(timeout=30000)
|
|
||||||
print("Matrix sync response:", response)
|
|
||||||
assert isinstance(response, nio.SyncResponse)
|
|
||||||
|
|
||||||
# Check the message was received by continuwuity
|
|
||||||
last_message = response.rooms.join[room_id].timeline.events[-1].body
|
|
||||||
assert last_message == "Hello continuwuity!"
|
|
||||||
|
|
||||||
# Leave the room
|
|
||||||
response = await client.room_leave(room_id)
|
|
||||||
print("Matrix room leave response:", response)
|
|
||||||
assert isinstance(response, nio.RoomLeaveResponse)
|
|
||||||
|
|
||||||
# Close the client
|
|
||||||
await client.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
asyncio.run(main())
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
# run some nixos tests as checks
|
|
||||||
checks = lib.pipe self'.packages [
|
|
||||||
# we take all packages (names)
|
|
||||||
builtins.attrNames
|
|
||||||
# we filter out all packages that end with `-bin` (which we are interested in for testing)
|
|
||||||
(builtins.filter (lib.hasSuffix "-bin"))
|
|
||||||
# for each of these binaries we built the basic nixos test
|
|
||||||
#
|
|
||||||
# this test was initially yoinked from
|
|
||||||
#
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/960ce26339661b1b69c6f12b9063ca51b688615f/nixos/tests/matrix/continuwuity.nix
|
|
||||||
(builtins.concatMap (
|
|
||||||
name:
|
|
||||||
builtins.map
|
|
||||||
(
|
|
||||||
{ config, suffix }:
|
|
||||||
{
|
|
||||||
name = "test-${name}-${suffix}";
|
|
||||||
value = pkgs.testers.runNixOSTest {
|
|
||||||
inherit name;
|
|
||||||
|
|
||||||
nodes = {
|
|
||||||
continuwuity = {
|
|
||||||
services.matrix-continuwuity = {
|
|
||||||
enable = true;
|
|
||||||
package = self'.packages.${name};
|
|
||||||
settings = config;
|
|
||||||
extraEnvironment.RUST_BACKTRACE = "yes";
|
|
||||||
};
|
|
||||||
networking.firewall.allowedTCPPorts = [ 6167 ];
|
|
||||||
};
|
|
||||||
client.environment.systemPackages = [ baseTestScript ];
|
|
||||||
};
|
|
||||||
|
|
||||||
testScript = ''
|
|
||||||
start_all()
|
|
||||||
|
|
||||||
with subtest("start continuwuity"):
|
|
||||||
continuwuity.wait_for_unit("continuwuity.service")
|
|
||||||
continuwuity.wait_for_open_port(6167)
|
|
||||||
|
|
||||||
with subtest("ensure messages can be exchanged"):
|
|
||||||
client.succeed("${lib.getExe baseTestScript} >&2")
|
|
||||||
'';
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
[
|
|
||||||
{
|
|
||||||
suffix = "base";
|
|
||||||
config = {
|
|
||||||
global = {
|
|
||||||
server_name = name;
|
|
||||||
address = [ "0.0.0.0" ];
|
|
||||||
allow_registration = true;
|
|
||||||
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
suffix = "with-room-version";
|
|
||||||
config = {
|
|
||||||
global = {
|
|
||||||
server_name = name;
|
|
||||||
address = [ "0.0.0.0" ];
|
|
||||||
allow_registration = true;
|
|
||||||
yes_i_am_very_very_sure_i_want_an_open_registration_server_prone_to_abuse = true;
|
|
||||||
default_room_version = "12";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
]
|
|
||||||
))
|
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user