mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
build(nixos): build the workspace once with Servo embedded for the VM
The shells were packaged without servo-embed, so the VM's system shell had no rendering engine, and each package compiled the workspace on its own. One cargo build now produces every binary with Servo enabled, links the prebuilt SpiderMonkey archive instead of compiling it, fills in the Servo source hash, installs the UI kit the shells inject, and adds the libraries Servo and winit open at run time to the shells' rpath. Not yet validated: the Nix build is still running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QS8QcxvhVJwU3X2qhPamUW
This commit is contained in:
parent
2418cb636a
commit
19798976c6
3 changed files with 85 additions and 64 deletions
|
|
@ -27,7 +27,7 @@
|
|||
in
|
||||
{
|
||||
packages = weftPkgs // {
|
||||
default = weftPkgs.weft-appd;
|
||||
default = weftPkgs.weft;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@
|
|||
wantedBy = [ "weft-session.target" ];
|
||||
environment = {
|
||||
WEFT_SYSTEM_UI_HTML = "${pkgs.weft.weft-servo-shell}/share/weft/shell/system-ui.html";
|
||||
WEFT_UI_KIT_JS = "${pkgs.weft.weft-servo-shell}/share/weft/system/weft-ui-kit.js";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
|
|
@ -149,6 +150,7 @@
|
|||
"WEFT_APP_SHELL_BIN=${pkgs.weft.weft-app-shell}/bin/weft-app-shell"
|
||||
"WEFT_FILE_PORTAL_BIN=${pkgs.weft.weft-file-portal}/bin/weft-file-portal"
|
||||
"WEFT_MOUNT_HELPER=/run/wrappers/bin/weft-mount-helper"
|
||||
"WEFT_UI_KIT_JS=${pkgs.weft.weft-app-shell}/share/weft/system/weft-ui-kit.js"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, rust193, ... }:
|
||||
{ pkgs, lib, rust193, ... }:
|
||||
|
||||
let
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
|
|
@ -6,85 +6,104 @@ let
|
|||
rustc = rust193;
|
||||
};
|
||||
|
||||
src = ../..;
|
||||
# The workspace without build outputs, so a local `target/` never enters
|
||||
# the store.
|
||||
src = lib.cleanSourceWith {
|
||||
src = lib.cleanSource ../..;
|
||||
filter = path: _type:
|
||||
let rel = lib.removePrefix (toString ../.. + "/") (toString path);
|
||||
in !(lib.hasPrefix "target" rel || lib.hasSuffix "-result" rel);
|
||||
};
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../../Cargo.lock;
|
||||
# One hash per git source in Cargo.lock: the Servo fork and the Stylo fork
|
||||
# (keyed by its `selectors` crate). Every package vendors both, so both must
|
||||
# match the pinned revisions. Recompute them whenever a revision changes.
|
||||
# The Servo hash is not yet known for e5d9a51; a Nix build reports it.
|
||||
# (keyed by its `selectors` crate). Recompute them whenever a revision
|
||||
# changes; a build with a stale hash reports the right one.
|
||||
outputHashes = {
|
||||
"servo-0.0.1" = pkgs.lib.fakeHash;
|
||||
"servo-0.0.1" = "sha256-L5XlHf5GOoPtyitRsbb+keXSkTMSJWmYCrWCHzGFI5M=";
|
||||
"selectors-0.36.0" = "13y6pa19j4w2zsxfhv6mrl03wsa0frazlsssbqkzpwci8k9gzl4i";
|
||||
};
|
||||
};
|
||||
|
||||
commonArgs = {
|
||||
inherit src cargoLock;
|
||||
version = "0.0.1-alpha.0";
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||
# SpiderMonkey, prebuilt by the mozjs project for the mozjs_sys version in
|
||||
# Cargo.lock. The build has no network, and compiling SpiderMonkey from
|
||||
# source would add hours and gigabytes to every build.
|
||||
mozjsArchive = pkgs.fetchurl {
|
||||
url = "https://github.com/servo/mozjs/releases/download/mozjs-sys-v0.140.8-0/libmozjs-x86_64-unknown-linux-gnu.tar.gz";
|
||||
hash = "sha256-wEDh2VCawPLc7AOlaitkT5yN9pv16oX7UoeHMg+4Aeg=";
|
||||
};
|
||||
|
||||
mkWeftPkg = { pname, extraBuildInputs ? [], extraNativeBuildInputs ? [], cargoFlags ? [], extraEnv ? {}, preBuild ? "", postInstall ? "" }: rustPlatform.buildRustPackage (commonArgs // {
|
||||
inherit pname preBuild postInstall;
|
||||
cargoBuildFlags = [ "--package" pname ] ++ cargoFlags;
|
||||
cargoTestFlags = [ "--package" pname ];
|
||||
buildInputs = extraBuildInputs;
|
||||
nativeBuildInputs = commonArgs.nativeBuildInputs ++ extraNativeBuildInputs;
|
||||
env = extraEnv;
|
||||
doCheck = false;
|
||||
});
|
||||
# Libraries Servo and winit open at run time rather than link against.
|
||||
runtimeLibs = with pkgs; [ libGL wayland libxkbcommon vulkan-loader ];
|
||||
|
||||
in {
|
||||
weft-compositor = mkWeftPkg {
|
||||
pname = "weft-compositor";
|
||||
extraBuildInputs = with pkgs; [
|
||||
libdrm mesa libgbm wayland libxkbcommon seatd udev dbus libGL libdisplay-info libinput
|
||||
packages = [
|
||||
"weft-compositor"
|
||||
"weft-servo-shell"
|
||||
"weft-app-shell"
|
||||
"weft-appd"
|
||||
"weft-runtime"
|
||||
"weft-pack"
|
||||
"weft-file-portal"
|
||||
"weft-mount-helper"
|
||||
];
|
||||
extraNativeBuildInputs = with pkgs; [ wayland-scanner ];
|
||||
extraEnv = {
|
||||
|
||||
features = [
|
||||
"weft-servo-shell/servo-embed"
|
||||
"weft-app-shell/servo-embed"
|
||||
"weft-runtime/wasmtime-runtime"
|
||||
"weft-runtime/net-fetch"
|
||||
];
|
||||
|
||||
# Every binary comes from one cargo build, so the dependencies the
|
||||
# programs share, Servo above all, compile once.
|
||||
workspace = rustPlatform.buildRustPackage {
|
||||
pname = "weft";
|
||||
version = "0.0.1-alpha.0";
|
||||
inherit src cargoLock;
|
||||
|
||||
cargoBuildFlags = lib.concatMap (p: [ "--package" p ]) packages
|
||||
++ [ "--features" (lib.concatStringsSep "," features) ];
|
||||
doCheck = false;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
wayland-scanner
|
||||
cmake
|
||||
python3
|
||||
perl
|
||||
m4
|
||||
rustPlatform.bindgenHook
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
libdrm mesa libgbm wayland libxkbcommon seatd udev dbus libGL
|
||||
libdisplay-info libinput
|
||||
openssl cryptsetup
|
||||
fontconfig freetype libunwind
|
||||
];
|
||||
|
||||
env = {
|
||||
MOZJS_ARCHIVE = "${mozjsArchive}";
|
||||
RUSTFLAGS = "-L${pkgs.libgbm}/lib -L${pkgs.libinput}/lib";
|
||||
};
|
||||
# The helper runs setuid and takes no program from its caller's PATH.
|
||||
WEFT_VERITYSETUP = "${pkgs.cryptsetup}/bin/veritysetup";
|
||||
};
|
||||
|
||||
weft-servo-shell = mkWeftPkg {
|
||||
pname = "weft-servo-shell";
|
||||
# The system UI page, at the path the shell's units name.
|
||||
# The system UI page and the UI kit both shells inject, at the paths the
|
||||
# session's units name.
|
||||
postInstall = ''
|
||||
install -Dm644 infra/shell/system-ui.html $out/share/weft/shell/system-ui.html
|
||||
install -Dm644 infra/shell/weft-ui-kit.js $out/share/weft/system/weft-ui-kit.js
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
for bin in weft-servo-shell weft-app-shell weft-compositor; do
|
||||
patchelf --add-rpath ${lib.makeLibraryPath runtimeLibs} $out/bin/$bin
|
||||
done
|
||||
'';
|
||||
};
|
||||
|
||||
weft-app-shell = mkWeftPkg {
|
||||
pname = "weft-app-shell";
|
||||
};
|
||||
|
||||
weft-appd = mkWeftPkg {
|
||||
pname = "weft-appd";
|
||||
extraBuildInputs = with pkgs; [ openssl ];
|
||||
};
|
||||
|
||||
weft-runtime = mkWeftPkg {
|
||||
pname = "weft-runtime";
|
||||
extraBuildInputs = with pkgs; [ openssl ];
|
||||
cargoFlags = [ "--features" "wasmtime-runtime,net-fetch" ];
|
||||
};
|
||||
|
||||
weft-pack = mkWeftPkg {
|
||||
pname = "weft-pack";
|
||||
};
|
||||
|
||||
weft-file-portal = mkWeftPkg {
|
||||
pname = "weft-file-portal";
|
||||
};
|
||||
|
||||
weft-mount-helper = mkWeftPkg {
|
||||
pname = "weft-mount-helper";
|
||||
extraBuildInputs = with pkgs; [ cryptsetup ];
|
||||
# The helper runs setuid and takes no program from its caller's PATH.
|
||||
extraEnv = {
|
||||
WEFT_VERITYSETUP = "${pkgs.cryptsetup}/bin/veritysetup";
|
||||
};
|
||||
};
|
||||
}
|
||||
in
|
||||
# Each program keeps its own attribute for the units that name it.
|
||||
lib.genAttrs packages (_: workspace) // { weft = workspace; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue