diff --git a/devShells/default.nix b/devShells/default.nix index 0798e86..c288f30 100644 --- a/devShells/default.nix +++ b/devShells/default.nix @@ -11,6 +11,7 @@ muvm, sidebus-broker, wl-cross-domain-proxy, + wl-backdrop, pkgs, }: @@ -34,6 +35,7 @@ mkShell { bubblewrap sidebus-broker wl-cross-domain-proxy + wl-backdrop ] ++ (with pkgs; [ meson diff --git a/flake.lock b/flake.lock index 165ec30..234a180 100644 --- a/flake.lock +++ b/flake.lock @@ -76,7 +76,8 @@ "libkrun-src": "libkrun-src", "muvm-src": "muvm-src", "nixpkgs": "nixpkgs", - "sidebus": "sidebus" + "sidebus": "sidebus", + "wl-backdrop": "wl-backdrop" } }, "sidebus": { @@ -103,6 +104,31 @@ "type": "git", "url": "https://git.clan.lol/clan/sidebus" } + }, + "wl-backdrop": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772781884, + "narHash": "sha256-epVLmAHnJi4EoZea5DUmxB3r6SPSMu3Nzki7JzbK0sA=", + "ref": "main", + "rev": "20e3910ef60aa627933a5d750b60cc3dcd0653cf", + "shallow": true, + "type": "git", + "url": "https://git.clan.lol/valpackett/wl-backdrop" + }, + "original": { + "ref": "main", + "shallow": true, + "type": "git", + "url": "https://git.clan.lol/valpackett/wl-backdrop" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index cbc0887..6b9191b 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,10 @@ sidebus.inputs.nixpkgs.follows = "nixpkgs"; sidebus.inputs.flake-parts.follows = "flake-parts"; + wl-backdrop.url = "git+https://git.clan.lol/valpackett/wl-backdrop?shallow=1&ref=main"; + wl-backdrop.inputs.nixpkgs.follows = "nixpkgs"; + wl-backdrop.inputs.flake-parts.follows = "flake-parts"; + # To override with local checkouts during development, use the --override-input CLI flag! muvm-src = { url = "github:valpackett/muvm/c68742bcedb96deb6f23ed5a83188022d1cdf71d"; # v0.5.0+custom-init+dbus @@ -35,6 +39,7 @@ nixpkgs, flake-parts, sidebus, + wl-backdrop, muvm-src, libkrun-src, # libkrunfw-src, @@ -122,6 +127,7 @@ mesa = self'.packages.mesa; muvm = self'.packages.muvm; wl-cross-domain-proxy = self'.packages.wl-cross-domain-proxy; + wl-backdrop = wl-backdrop.packages.${system}.wl-backdrop; sidebus-broker = sidebus.packages.${system}.sidebus-broker; }; @@ -132,6 +138,7 @@ libkrun = self'.packages.libkrun; muvm = self'.packages.muvm; wl-cross-domain-proxy = self'.packages.wl-cross-domain-proxy; + wl-backdrop = wl-backdrop.packages.${system}.wl-backdrop; sidebus-broker = sidebus.packages.${system}.sidebus-broker; }; }; diff --git a/munix b/munix index 7fbd9b0..619a38f 100755 --- a/munix +++ b/munix @@ -3,6 +3,7 @@ SCRIPT_PATH=$(dirname $(realpath -s $0)) MUVM_PATH=$(dirname $(which muvm)) PASST_PATH=$(dirname $(which passt)) WL_PROXY_PATH=$(dirname $(which wl-cross-domain-proxy)) +WL_BACKDROP_PATH=$(dirname $(which wl-backdrop)) HOST_OPENGL_DRIVER=/run/opengl-driver : "${MICROVM_DEFAULT_COMMAND:=bash}" : "${MUNIX_SYSTEMD_UNITS:="${SCRIPT_PATH}/systemd"}" @@ -25,6 +26,22 @@ if [ ! -e "$HOST_OPENGL_DRIVER" ]; then HOST_OPENGL_DRIVER="$FALLBACK_OPENGL_DRIVER" fi +# A little bit cursed: pre-pass to relaunch with new env var.. +BG_COLOR= +pargs=() +while [ "$#" -gt 0 ]; do + case "$1" in + --bg-color) BG_COLOR="$2"; shift 2;; + --wl-backdrop-bin-dir) WL_BACKDROP_PATH="$2"; shift 2;; + *) pargs+=("$1"); shift;; + esac +done +if [ "$BG_COLOR" = "" ]; then + set -- "${pargs[@]}" +else + exec "$WL_BACKDROP_PATH/wl-backdrop" --background "$BG_COLOR" -- "$(readlink -f "$0")" "${pargs[@]}" +fi + while [ "$#" -gt 0 ]; do case "$1" in -u|--uid) MICROVM_UID="$2"; shift 2;; @@ -44,6 +61,7 @@ while [ "$#" -gt 0 ]; do --muvm-bin-dir) MUVM_PATH="$2"; shift 2;; --passt-bin-dir) PASST_PATH="$2"; shift 2;; --wl-proxy-bin-dir) WL_PROXY_PATH="$2"; shift 2;; + --wl-backdrop-bin-dir) shift 2;; --) shift 1; MICROVM_COMMAND+=("$@"); break;; -*) echo "munix: unknown option: $1" >&2; exit 1;; *) @@ -76,6 +94,11 @@ if [ "$WL_PROXY_PATH" = "" ]; then exit 1 fi +if [ "$WL_BACKDROP_PATH" = "" ]; then + echo "munix: wl-backdrop not found, provide a --wl-backdrop-bin-dir or fix \$PATH" >&2 + exit 1 +fi + if [ ! -e "$HOST_OPENGL_DRIVER" ]; then echo "munix: host graphics driver not found, provide a --host-opengl-driver" >&2 exit 1 diff --git a/packages/munix/default.nix b/packages/munix/default.nix index d7ff431..e0b848e 100644 --- a/packages/munix/default.nix +++ b/packages/munix/default.nix @@ -1,4 +1,4 @@ -{ stdenv, writeScriptBin, symlinkJoin, makeWrapper, muvm, passt, bubblewrap, sidebus-broker, wl-cross-domain-proxy, mesa, rustc }: +{ stdenv, writeScriptBin, symlinkJoin, makeWrapper, muvm, passt, bubblewrap, sidebus-broker, wl-cross-domain-proxy, wl-backdrop, mesa, rustc }: let munixScript = (writeScriptBin "munix" (builtins.readFile ../../munix)).overrideAttrs(old: { @@ -28,7 +28,7 @@ let }; in symlinkJoin { name = "munix"; - paths = [ munixScript microActivate muvm passt bubblewrap sidebus-broker wl-cross-domain-proxy ]; + paths = [ munixScript microActivate muvm passt bubblewrap sidebus-broker wl-cross-domain-proxy wl-backdrop ]; buildInputs = [ makeWrapper ]; postBuild = '' wrapProgram $out/bin/munix --prefix PATH : $out/bin --set FALLBACK_OPENGL_DRIVER ${mesa} --set MUNIX_SYSTEMD_UNITS ${munixSystemd}