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

lomiri.morph-browser: init at 1.1.0 #262433

Merged
merged 4 commits into from
Feb 22, 2024
Merged
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
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ in {
mongodb = handleTest ./mongodb.nix {};
moodle = handleTest ./moodle.nix {};
moonraker = handleTest ./moonraker.nix {};
morph-browser = handleTest ./morph-browser.nix { };
morty = handleTest ./morty.nix {};
mosquitto = handleTest ./mosquitto.nix {};
moosefs = handleTest ./moosefs.nix {};
Expand Down
53 changes: 53 additions & 0 deletions nixos/tests/morph-browser.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "morph-browser-standalone";
meta.maintainers = lib.teams.lomiri.members;

nodes.machine = { config, pkgs, ... }: {
imports = [
./common/x11.nix
];

services.xserver.enable = true;

environment = {
systemPackages = with pkgs.lomiri; [
suru-icon-theme
morph-browser
];
variables = {
UITK_ICON_THEME = "suru";
};
};

i18n.supportedLocales = [ "all" ];

fonts.packages = with pkgs; [
# Intended font & helps with OCR
ubuntu_font_family
];
};

enableOCR = true;

testScript =
''
machine.wait_for_x()
with subtest("morph browser launches"):
machine.execute("morph-browser >&2 &")
machine.wait_for_text(r"Web Browser|New|sites|Bookmarks")
machine.screenshot("morph_open")
with subtest("morph browser displays HTML"):
machine.send_chars("file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html\n")
machine.wait_for_text("Valgrind Documentation")
machine.screenshot("morph_htmlcontent")
machine.succeed("pkill -f morph-browser")
with subtest("morph browser localisation works"):
machine.execute("env LANG=de_DE.UTF-8 morph-browser >&2 &")
machine.wait_for_text(r"Web-Browser|Neuer|Seiten|Lesezeichen")
machine.screenshot("morph_localised")
'';
})
139 changes: 139 additions & 0 deletions pkgs/desktops/lomiri/applications/morph-browser/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{ stdenv
, lib
, fetchFromGitLab
, fetchpatch
, gitUpdater
, nixosTests
, cmake
, content-hub
, gettext
, libapparmor
, lomiri-action-api
, lomiri-ui-extras
, lomiri-ui-toolkit
, pkg-config
, qqc2-suru-style
, qtbase
, qtdeclarative
, qtquickcontrols2
, qtsystems
, qtwebengine
, wrapQtAppsHook
, xvfb-run
}:

let
listToQtVar = suffix: lib.makeSearchPathOutput "bin" suffix;
in
stdenv.mkDerivation (finalAttrs: {
pname = "morph-browser";
version = "1.1.0";

src = fetchFromGitLab {
owner = "ubports";
repo = "development/core/morph-browser";
rev = finalAttrs.version;
hash = "sha256-C5iXv8VS8Mm1ryxK7Vi5tVmiM01OSIFiTyH0vP9B/xA=";
};

patches = [
# Remove when https://gitlab.com/ubports/development/core/morph-browser/-/merge_requests/575 merged & in release
(fetchpatch {
name = "0001-morph-browser-tst_SessionUtilsTests-Set-permissions-on-temporary-xdg-runtime-directory.patch";
url = "https://gitlab.com/ubports/development/core/morph-browser/-/commit/e90206105b8b287fbd6e45ac37ca1cd259981928.patch";
hash = "sha256-5htFn+OGVVBn3mJQaZcF5yt0mT+2QRlKyKFesEhklfA=";
})

# Remove when https://gitlab.com/ubports/development/core/morph-browser/-/merge_requests/576 merged & in release
(fetchpatch {
name = "0002-morph-browser-Call-i18n-bindtextdomain-with-buildtime-determined-locale-path.patch";
url = "https://gitlab.com/ubports/development/core/morph-browser/-/commit/0527a1e01fb27c62f5e0011274f73bad400e9691.patch";
hash = "sha256-zx/pP72uNqAi8TZR4bKeONuqcJyK/vGtPglTA+5R5no=";
})
];

postPatch = ''
substituteInPlace src/{Morph,Ubuntu}/CMakeLists.txt \
--replace '/usr/lib/''${CMAKE_LIBRARY_ARCHITECTURE}/qt5/qml' "\''${CMAKE_INSTALL_PREFIX}/${qtbase.qtQmlPrefix}"

# Don't use absolute paths in desktop file
substituteInPlace src/app/webbrowser/morph-browser.desktop.in.in \
--replace 'Icon=@CMAKE_INSTALL_FULL_DATADIR@/morph-browser/morph-browser.svg' 'Icon=morph-browser' \
--replace 'X-Lomiri-Splash-Image=@CMAKE_INSTALL_FULL_DATADIR@/morph-browser/morph-browser-splash.svg' 'X-Lomiri-Splash-Image=lomiri-app-launch/splash/morph-browser.svg'
'' + lib.optionalString (!finalAttrs.doCheck) ''
substituteInPlace CMakeLists.txt \
--replace 'add_subdirectory(tests)' ""
'';

strictDeps = true;

nativeBuildInputs = [
cmake
gettext
pkg-config
wrapQtAppsHook
];

buildInputs = [
libapparmor
qtbase
qtdeclarative
qtwebengine

# QML
content-hub
lomiri-action-api
lomiri-ui-extras
lomiri-ui-toolkit
qqc2-suru-style
qtquickcontrols2
qtsystems
];

nativeCheckInputs = [
xvfb-run
];

cmakeFlags = [
(lib.cmakeFeature "CMAKE_CTEST_ARGUMENTS" (lib.concatStringsSep ";" [
# Exclude tests
"-E" (lib.strings.escapeShellArg "(${lib.concatStringsSep "|" [
# Don't care about linter failures
"^flake8"

# Runs into ShapeMaterial codepath in lomiri-ui-toolkit which needs OpenGL, see LUITK for details
"^tst_QmlTests"
]})")
]))
];

doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

preCheck = ''
export HOME=$TMPDIR
export QT_PLUGIN_PATH=${listToQtVar qtbase.qtPluginPrefix [ qtbase ]}
export QML2_IMPORT_PATH=${listToQtVar qtbase.qtQmlPrefix ([ lomiri-ui-toolkit qtwebengine qtdeclarative qtquickcontrols2 qtsystems ] ++ lomiri-ui-toolkit.propagatedBuildInputs)}
'';

postInstall = ''
mkdir -p $out/share/{icons/hicolor/scalable/apps,lomiri-app-launch/splash}

ln -s $out/share/{morph-browser,icons/hicolor/scalable/apps}/morph-browser.svg
ln -s $out/share/{morph-browser/morph-browser-splash.svg,lomiri-app-launch/splash/morph-browser.svg}
'';

passthru = {
updateScript = gitUpdater { };
tests.standalone = nixosTests.morph-browser;
};

meta = with lib; {
description = "Lightweight web browser tailored for Ubuntu Touch";
homepage = "https://gitlab.com/ubports/development/core/morph-browser";
changelog = "https://gitlab.com/ubports/development/core/morph-browser/-/blob/${finalAttrs.version}/ChangeLog";
license = with licenses; [ gpl3Only cc-by-sa-30 ];
mainProgram = "morph-browser";
maintainers = teams.lomiri.members;
platforms = platforms.linux;
};
})
1 change: 1 addition & 0 deletions pkgs/desktops/lomiri/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ let
in {
#### Core Apps
lomiri-terminal-app = callPackage ./applications/lomiri-terminal-app { };
morph-browser = callPackage ./applications/morph-browser { };

#### Data
lomiri-schemas = callPackage ./data/lomiri-schemas { };
Expand Down
Loading