mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-03-26 17:03:09 +00:00
build(nix): add servo-shell/app-shell packages, real git hashes, fix VM configuration
- weft-packages.nix: add weft-servo-shell and weft-app-shell with servo-embed feature; real sha256 hashes for servo (8e7dc40) and stylo (dca3934) git deps computed via nix-prefetch-git; add clang/cmake/python3 as native build inputs for servo packages; set LIBCLANG_PATH; disable doCheck for VM builds - configuration.nix: import virtualisation/qemu-vm.nix for system.build.vm; replace hardware.opengl with hardware.graphics (NixOS 24.11); add weft-servo-shell systemd user service; add servo-shell/app-shell/pack to environment packages - infra/vm/build.sh: switch to system.build.vm target (qcow2 attribute not provided by default NixOS modules) - infra/vm/run.sh: invoke the VM script produced by system.build.vm
This commit is contained in:
parent
2ae05312dc
commit
b0f208eba7
4 changed files with 70 additions and 49 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
"${modulesPath}/profiles/qemu-guest.nix"
|
"${modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
"${modulesPath}/virtualisation/qemu-vm.nix"
|
||||||
];
|
];
|
||||||
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
|
|
@ -24,9 +25,8 @@
|
||||||
diskSize = 20480;
|
diskSize = 20480;
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware.opengl = {
|
hardware.graphics = {
|
||||||
enable = true;
|
enable = true;
|
||||||
driSupport = true;
|
|
||||||
extraPackages = with pkgs; [ mesa.drivers virglrenderer ];
|
extraPackages = with pkgs; [ mesa.drivers virglrenderer ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -60,6 +60,9 @@
|
||||||
coreutils
|
coreutils
|
||||||
curl
|
curl
|
||||||
htop
|
htop
|
||||||
|
pkgs.weft.weft-servo-shell
|
||||||
|
pkgs.weft.weft-app-shell
|
||||||
|
pkgs.weft.weft-pack
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
|
|
@ -82,6 +85,22 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
weft-servo-shell = {
|
||||||
|
description = "WEFT OS System Shell";
|
||||||
|
requires = [ "weft-compositor.service" ];
|
||||||
|
after = [ "weft-compositor.service" ];
|
||||||
|
wantedBy = [ "graphical-session.target" ];
|
||||||
|
environment = {
|
||||||
|
WAYLAND_DISPLAY = "wayland-1";
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${pkgs.weft.weft-servo-shell}/bin/weft-servo-shell";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = "2";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
weft-appd = {
|
weft-appd = {
|
||||||
description = "WEFT Application Daemon";
|
description = "WEFT Application Daemon";
|
||||||
requires = [ "weft-compositor.service" ];
|
requires = [ "weft-compositor.service" ];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ let
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ../../Cargo.lock;
|
lockFile = ../../Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
"servo-0.0.1" = pkgs.lib.fakeSha256;
|
"servo-0.0.1" = "0b803qankr0rs4hi0md26dydf2cvpd6v5x2bxxypzsga0jwfdd26";
|
||||||
|
"selectors-0.36.0" = "1x5g61cadq700yhl1wwrjd043grlpdviqqn4n9cm5k68gbx0if81";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -16,31 +17,53 @@ let
|
||||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkWeftPkg = { pname, extraBuildInputs ? [], extraNativeBuildInputs ? [], cargoFlags ? [] }: pkgs.rustPlatform.buildRustPackage (commonArgs // {
|
mkWeftPkg = { pname, extraBuildInputs ? [], extraNativeBuildInputs ? [], cargoFlags ? [], extraEnv ? {} }: pkgs.rustPlatform.buildRustPackage (commonArgs // {
|
||||||
inherit pname;
|
inherit pname;
|
||||||
cargoBuildFlags = [ "--package" pname ] ++ cargoFlags;
|
cargoBuildFlags = [ "--package" pname ] ++ cargoFlags;
|
||||||
cargoTestFlags = [ "--package" pname ];
|
cargoTestFlags = [ "--package" pname ];
|
||||||
buildInputs = extraBuildInputs;
|
buildInputs = extraBuildInputs;
|
||||||
nativeBuildInputs = commonArgs.nativeBuildInputs ++ extraNativeBuildInputs;
|
nativeBuildInputs = commonArgs.nativeBuildInputs ++ extraNativeBuildInputs;
|
||||||
doCheck = true;
|
env = extraEnv;
|
||||||
|
doCheck = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
in {
|
in {
|
||||||
weft-compositor = mkWeftPkg {
|
weft-compositor = mkWeftPkg {
|
||||||
pname = "weft-compositor";
|
pname = "weft-compositor";
|
||||||
extraBuildInputs = with pkgs; [
|
extraBuildInputs = with pkgs; [
|
||||||
libdrm
|
libdrm mesa wayland libxkbcommon libseat udev dbus libGL
|
||||||
mesa
|
|
||||||
wayland
|
|
||||||
libxkbcommon
|
|
||||||
libseat
|
|
||||||
udev
|
|
||||||
dbus
|
|
||||||
libGL
|
|
||||||
];
|
];
|
||||||
extraNativeBuildInputs = with pkgs; [ wayland-scanner ];
|
extraNativeBuildInputs = with pkgs; [ wayland-scanner ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
weft-servo-shell = mkWeftPkg {
|
||||||
|
pname = "weft-servo-shell";
|
||||||
|
extraBuildInputs = with pkgs; [
|
||||||
|
mesa wayland libxkbcommon openssl dbus udev libGL
|
||||||
|
];
|
||||||
|
extraNativeBuildInputs = with pkgs; [
|
||||||
|
pkgs.llvmPackages.clang cmake python3
|
||||||
|
];
|
||||||
|
cargoFlags = [ "--features" "servo-embed" ];
|
||||||
|
extraEnv = {
|
||||||
|
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
weft-app-shell = mkWeftPkg {
|
||||||
|
pname = "weft-app-shell";
|
||||||
|
extraBuildInputs = with pkgs; [
|
||||||
|
mesa wayland libxkbcommon openssl dbus udev libGL
|
||||||
|
];
|
||||||
|
extraNativeBuildInputs = with pkgs; [
|
||||||
|
pkgs.llvmPackages.clang cmake python3
|
||||||
|
];
|
||||||
|
cargoFlags = [ "--features" "servo-embed" ];
|
||||||
|
extraEnv = {
|
||||||
|
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
weft-appd = mkWeftPkg {
|
weft-appd = mkWeftPkg {
|
||||||
pname = "weft-appd";
|
pname = "weft-appd";
|
||||||
extraBuildInputs = with pkgs; [ openssl ];
|
extraBuildInputs = with pkgs; [ openssl ];
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,18 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
OUT="${1:-"${REPO_ROOT}/infra/vm/weft-vm.qcow2"}"
|
OUT="${1:-"${REPO_ROOT}/infra/vm/weft-vm-result"}"
|
||||||
|
|
||||||
if [ -f "$OUT" ]; then
|
if [ -e "$OUT" ]; then
|
||||||
echo "error: $OUT already exists; remove it before rebuilding" >&2
|
echo "error: $OUT already exists; remove it before rebuilding" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$REPO_ROOT"
|
cd "$REPO_ROOT"
|
||||||
|
|
||||||
echo "building NixOS VM image..."
|
echo "building NixOS VM..."
|
||||||
nix build .#nixosConfigurations.weft-vm.config.system.build.qcow2 \
|
nix build .#nixosConfigurations.weft-vm.config.system.build.vm \
|
||||||
--out-link /tmp/weft-vm-result \
|
--out-link "$OUT" \
|
||||||
--print-build-logs
|
--print-build-logs
|
||||||
|
|
||||||
SOURCE="$(readlink -f /tmp/weft-vm-result)"
|
echo "VM script: $OUT/bin/run-weft-vm-vm"
|
||||||
if [ ! -f "$SOURCE" ]; then
|
|
||||||
SOURCE="$(find /tmp/weft-vm-result -name '*.qcow2' | head -1)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$SOURCE" ]; then
|
|
||||||
echo "error: could not locate .qcow2 in build output" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "$SOURCE" "$OUT"
|
|
||||||
rm -f /tmp/weft-vm-result
|
|
||||||
echo "image: $OUT"
|
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,17 @@
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
IMAGE="${1:-"${REPO_ROOT}/infra/vm/weft-vm.qcow2"}"
|
RESULT="${1:-"${REPO_ROOT}/infra/vm/weft-vm-result"}"
|
||||||
|
|
||||||
if [ ! -f "$IMAGE" ]; then
|
if [ ! -e "$RESULT" ]; then
|
||||||
echo "error: $IMAGE not found; run infra/vm/build.sh first" >&2
|
echo "error: $RESULT not found; run infra/vm/build.sh first" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MEM="${WEFT_VM_MEM:-4096}"
|
VM_SCRIPT="${RESULT}/bin/run-weft-vm-vm"
|
||||||
CPUS="${WEFT_VM_CPUS:-4}"
|
if [ ! -x "$VM_SCRIPT" ]; then
|
||||||
DISPLAY_OPT="${WEFT_VM_DISPLAY:-gtk,gl=on}"
|
echo "error: VM script not found at $VM_SCRIPT" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
exec qemu-system-x86_64 \
|
exec "$VM_SCRIPT" "$@"
|
||||||
-enable-kvm \
|
|
||||||
-m "${MEM}M" \
|
|
||||||
-smp "${CPUS}" \
|
|
||||||
-drive "file=${IMAGE},format=qcow2,if=virtio" \
|
|
||||||
-vga virtio \
|
|
||||||
-display "${DISPLAY_OPT}" \
|
|
||||||
-device virtio-net-pci,netdev=net0 \
|
|
||||||
-netdev user,id=net0 \
|
|
||||||
-device virtio-rng-pci \
|
|
||||||
-serial mon:stdio \
|
|
||||||
"$@"
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue