diff --git a/pkgs/by-name/brython/package.nix b/pkgs/by-name/brython/package.nix new file mode 100644 index 00000000..0bc552d4 --- /dev/null +++ b/pkgs/by-name/brython/package.nix @@ -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 = []; + }; +} diff --git a/pkgs/by-name/libervia-web/package.nix b/pkgs/by-name/libervia-web/package.nix new file mode 100644 index 00000000..62f719b5 --- /dev/null +++ b/pkgs/by-name/libervia-web/package.nix @@ -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 = []; + }; +} diff --git a/projects/Libervia/default.nix b/projects/Libervia/default.nix index 7684c9a0..bc489749 100644 --- a/projects/Libervia/default.nix +++ b/projects/Libervia/default.nix @@ -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; }; }; diff --git a/projects/Libervia/module.nix b/projects/Libervia/module.nix index 3ceeecaf..3f91eb12 100644 --- a/projects/Libervia/module.nix +++ b/projects/Libervia/module.nix @@ -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]; + }; } diff --git a/projects/Libervia/test.nix b/projects/Libervia/test.nix index 3294b0ba..082ace8b 100644 --- a/projects/Libervia/test.nix +++ b/projects/Libervia/test.nix @@ -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} < ${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") ''; }