From 74addf188bbcd129ea66b262219bf1e5b09aa8ae Mon Sep 17 00:00:00 2001 From: "Ngo Iok Ui (Wu Yu Wei)" Date: Tue, 30 Jul 2024 18:01:37 +0900 Subject: [PATCH] Add nix support (#94) * Add nix support * Update shell.nix * Add nixGL * Format shell.nix * Update README * build(nix): add mako python package --------- Co-authored-by: Wu Yuwei Co-authored-by: Jason Tsai --- README.md | 51 ++++++++++++++++++++++++++++++---------------- shell.nix | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 shell.nix diff --git a/README.md b/README.md index 95fbd7a8..7fc76821 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,7 @@ But if you are interested, feel free to help test it. # Usage -The current demo works best on macOS at the moment, since it tries to customize its traffic light buttons to be seamless in the window. - -However, We plan to focus on Windows as main target support. - -## Prerequisites +## Getting Started ### Windows @@ -26,6 +22,14 @@ scoop install git python llvm cmake curl pip install mako ``` +> You can also use chocolatey to install if you prefer it. + +- Build & run: + +```sh +cargo run +``` + ### MacOS - Install [Xcode](https://developer.apple.com/xcode/) @@ -36,8 +40,29 @@ brew install cmake pkg-config harfbuzz pip install mako ``` +- Build & run: + +```sh +cargo run +``` + ### Linux + +#### Nix + +- For NixOS: + +```sh +nix-shell shell.nix --run 'cargo r' +``` + +- For non-NixOS distributions: + +```sh +nix-shell shell.nix --run 'nixGL cargo r' +``` + #### Debian-based Distributions ```sh @@ -57,21 +82,13 @@ python3-mako For others, please follow the instructions in [Servo book](https://book.servo.org/hacking/setting-up-your-environment.html#tools-for-linux) to bootstrap first. -## Build - -- Run demo - -```sh -cargo run -``` - ## Nightly Release Nightly releases built with CrabNebula Cloud can be found at [releases](https://web.crabnebula.cloud/verso/verso-nightly/releases). ## Future Work -- Add more window and servo features to make it feel more like a general web browser. -- Improve development experience. -- Multi webviews and multi browsing contexts in the same window. -- Enable `Gstreamer` feature and remove `brew install harfbuzz` in README. \ No newline at end of file +- Multiwindow support. +- Enable multiprocess mode. +- Enable sandobx in all platforms. +- Enable `Gstreamer` feature and remove `brew install harfbuzz` in README. diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..39ff225d --- /dev/null +++ b/shell.nix @@ -0,0 +1,60 @@ +with import { }; +let + nixgl = import (fetchTarball "https://github.com/nix-community/nixGL/archive/489d6b095ab9d289fe11af0219a9ff00fe87c7c5.tar.gz") { enable32bits = false; }; + pkgs_gnumake_4_3 = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/6adf48f53d819a7b6e15672817fa1e78e5f4e84f.tar.gz") { }; + llvmPackages = llvmPackages_14; # servo/servo#31059 + stdenv = stdenvAdapters.useMoldLinker llvmPackages.stdenv; +in +stdenv.mkDerivation { + name = "verso-env"; + + buildInputs = [ + fontconfig + freetype + libunwind + xorg.libxcb + xorg.libX11 + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-bad + gst_all_1.gst-plugins-ugly + rustup + taplo + llvmPackages.bintools + llvmPackages.llvm + llvmPackages.libclang + udev + cmake + dbus + gcc + git + pkg-config + which + llvm + perl + yasm + m4 + pkgs_gnumake_4_3.gnumake # servo/mozjs#375 + libGL + mold + wayland + nixgl.auto.nixGLDefault + (python3.withPackages (ps: with ps; [pip dbus mako])) + ]; + LD_LIBRARY_PATH = lib.makeLibraryPath [ + zlib + xorg.libXcursor + xorg.libXrandr + xorg.libXi + libxkbcommon + vulkan-loader + wayland + libGL + nixgl.auto.nixGLDefault + ]; + LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; + # Allow cargo to download crates + SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; + # Enable colored cargo and rustc output + TERMINFO = "${ncurses.out}/share/terminfo"; +}