Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libervia-web: init at 0.8.0-unstable-2024-06-17 #394

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions pkgs/by-name/brython/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
lib,
python3Packages,
fetchPypi,
}:
python3Packages.buildPythonPackage rec {
pname = "brython";
version = "3.12.4";
pyproject = true;

# Need sdist for data files, otherwise bound to specific python version
src = fetchPypi {
inherit pname version;
hash = "sha256-UFFLshwQBcb3wvBB06gvhuJK7tRECQyW/irNjwc67+4=";
};

postPatch = ''
rm pyproject.toml
'';

strictDeps = true;

nativeBuildInputs = with python3Packages; [
setuptools
];

pythonImportsCheck = [
"brython"
];

meta = {
description = "Implementation of Python 3 running in the browser";
homepage = "https://brython.info";
license = lib.licenses.bsd3;
maintainers = [];
};
}
64 changes: 64 additions & 0 deletions pkgs/by-name/libervia-web/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
python3Packages,
lib,
fetchhg,
brython,
gobject-introspection,
libervia-backend,
nodejs,
yarn,
wrapGAppsHook3,
}:
python3Packages.buildPythonApplication rec {
pname = "libervia-web";
version = "0.8.0-unstable-2024-06-17";
pyproject = true;

src = fetchhg {
url = "https://repos.goffi.org/libervia-web";
rev = "c4407befc52a57bf12387c337f8030a599f908cb";
hash = "sha256-hhL2TGSq86s7QKWwb8E6Sl3p65R3g5A4/Bah5VF2CFE=";
};

strictDeps = true;

nativeBuildInputs =
[
gobject-introspection
wrapGAppsHook3
]
++ (with python3Packages; [
hatchling
]);

propagatedBuildInputs =
[
brython
libervia-backend
]
++ (with python3Packages; [
autobahn
jinja2
pyopenssl
shortuuid
twisted
zope-interface
]);

dontWrapGApps = true;

preFixup = ''
makeWrapperArgs+=(
"''${gappsWrapperArgs[@]}"
--prefix PATH : "${lib.makeBinPath [nodejs yarn]}"
)
'';

meta = {
description = "Official web frontend of the Libervia project";
homepage = "https://libervia.org/";
changelog = "https://repos.goffi.org/libervia-web/file/${src.rev}/CHANGELOG";
license = lib.licenses.agpl3Plus;
maintainers = [];
};
}
4 changes: 2 additions & 2 deletions projects/Libervia/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
lib,
sources,
} @ args: {
packages = {inherit (pkgs) doubleratchet helium libervia-backend libervia-media libervia-templates libxeddsa oldmemo omemo sat-tmp twomemo urwid-satext wokkel x3dh xeddsa;};
packages = {inherit (pkgs) brython doubleratchet helium libervia-backend libervia-media libervia-templates libervia-web libxeddsa oldmemo omemo sat-tmp twomemo urwid-satext wokkel x3dh xeddsa;};
nixos = {
modules.programs.libervia = ./module.nix;
tests.libervia = import ./test.nix args;
examples = rec {
base = {
description = "Enables the use of Libervia's basic clients: CLI & TUI.";
description = "Enables the use of Libervia.";
path = ./examples/base.nix;
};
};
Expand Down
11 changes: 4 additions & 7 deletions projects/Libervia/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ in {
enable = lib.mkEnableOption "Libervia";
};

config = let
pkg = pkgs.libervia-backend;
in
lib.mkIf cfg.enable {
environment.systemPackages = [pkg];
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [libervia-backend libervia-web];

services.dbus.packages = [pkg];
};
services.dbus.packages = with pkgs; [libervia-backend];
};
}
26 changes: 20 additions & 6 deletions projects/Libervia/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
...
}: let
xmppUser = "alice";
xmppId = "${xmppUser}@example.org";
xmppHost = "example.org";
xmppId = "${xmppUser}@${xmppHost}";
xmppLiberviaId = "libervia@${xmppHost}";
xmppPassword = "foobar";
xmppMessage = "This is a test message.";
setup-initial-libervia-user = pkgs.writeShellApplication {
name = "setup-initial-libervia-user";
setup-initial-libervia-users = pkgs.writeShellApplication {
name = "setup-initial-libervia-users";
runtimeInputs = with pkgs; [prosody];
text = ''
exec prosodyctl adduser ${xmppId} <<EOF
prosodyctl adduser ${xmppId} <<EOF
${xmppPassword}
${xmppPassword}
EOF
prosodyctl adduser ${xmppLiberviaId} <<EOF
${xmppPassword}
${xmppPassword}
EOF
Expand Down Expand Up @@ -135,6 +141,9 @@ in {
hosts_dict = {
"example.org": {"host": "127.0.0.1"}
}

[web]
passphrase = ${xmppPassword}
'';

# Input for message sending command
Expand All @@ -143,7 +152,8 @@ in {

# Small script to register our test user in prosody
systemPackages = [
setup-initial-libervia-user
setup-initial-libervia-users
pkgs.firefox
];
};
};
Expand Down Expand Up @@ -174,7 +184,7 @@ in {

# Setup prosody so we can connect
machine.wait_for_console_text("Started Prosody XMPP server")
machine.succeed("sudo -su prosody ${lib.getExe setup-initial-libervia-user}")
machine.succeed("sudo -su prosody ${lib.getExe setup-initial-libervia-users}")

# We use in-session terminals for running commands, but relying on OCR to view results is slow
# Create some output files for commands to pipe outputs into
Expand Down Expand Up @@ -210,5 +220,9 @@ in {
machine.send_chars("libervia-cli message mam | tee -a ~/frontend.log\n")
machine.wait_for_console_text("${xmppUser}> ${xmppMessage}") # first log, us sending the message to ourself
machine.wait_for_console_text("${xmppUser}> ${xmppMessage}") # second log, us receicing the message from ourself

# Register web profile with setup XMPP account in Libervia
machine.send_chars("libervia-cli profile create -j ${xmppLiberviaId} -p ${xmppPassword} libervia | tee -a ~/frontend.log\n")
machine.wait_for_console_text(r"\[libervia\] Profile session started")
'';
}