patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Demi Marie Obenour <demiobenour@gmail.com>
To: Alyssa Ross <hi@alyssa.is>, devel@spectrum-os.org
Subject: Re: [PATCH v4 5/5] host/rootfs: add run-flatpak script
Date: Mon, 1 Dec 2025 00:20:07 -0500	[thread overview]
Message-ID: <c1bfafd4-51a6-4b41-8b74-218291954dd3@gmail.com> (raw)
In-Reply-To: <20251201044534.977524-9-hi@alyssa.is>


[-- Attachment #1.1.1: Type: text/plain, Size: 4462 bytes --]

On 11/30/25 23:45, Alyssa Ross wrote:
> This is the entrypoint for running Flatpak applications.
> 
> It would be good to only add mounts for the VM in virtiofsd's mount
> namespace, so we don't need to do lots of manual unmounts, but that's
> a wider change affecting more than just Flatpak.
> 
> I've tested this by copying my host's Flatpak repository into a disk
> image, and attaching that as a drive to the VM.
> 
> Signed-off-by: Alyssa Ross <hi@alyssa.is>
> ---
> v4: use the new VM mount namespace
> v3: https://spectrum-os.org/lists/archives/spectrum-devel/20251127202311.42422-7-hi@alyssa.is/
> 
>  host/rootfs/default.nix               | 12 +++----
>  host/rootfs/file-list.mk              |  1 +
>  host/rootfs/image/usr/bin/run-flatpak | 47 +++++++++++++++++++++++++++
>  3 files changed, 54 insertions(+), 6 deletions(-)
>  create mode 100755 host/rootfs/image/usr/bin/run-flatpak
> 
> diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
> index 57dd7a9..ca2084f 100644
> --- a/host/rootfs/default.nix
> +++ b/host/rootfs/default.nix
> @@ -12,9 +12,9 @@ pkgsMusl.callPackage (
>  , lib, stdenvNoCC, nixos, runCommand, writeClosure, erofs-utils, s6-rc
>  , btrfs-progs, busybox, cloud-hypervisor, cosmic-files, crosvm
>  , cryptsetup, dejavu_fonts, dbus, execline, foot, fuse3, iproute2
> -, inotify-tools, jq, kmod, mdevd, mesa, s6, s6-linux-init, socat
> -, systemd, util-linuxMinimal, virtiofsd, westonLite
> -, xdg-desktop-portal, xdg-desktop-portal-gtk
> +, inotify-tools, jq, kmod, mdevd, mesa, mount-flatpak, s6
> +, s6-linux-init, socat, systemd, util-linuxMinimal, virtiofsd
> +, westonLite, xdg-desktop-portal, xdg-desktop-portal-gtk
>  , xdg-desktop-portal-spectrum-host
>  }:
>  
> @@ -26,9 +26,9 @@ let
>  
>    packages = [
>      btrfs-progs cloud-hypervisor cosmic-files crosvm cryptsetup dbus
> -    execline fuse3 inotify-tools iproute2 jq kmod mdevd s6 s6-linux-init
> -    s6-rc socat spectrum-host-tools spectrum-router util-linuxMinimal virtiofsd
> -    xdg-desktop-portal-spectrum-host
> +    execline fuse3 inotify-tools iproute2 jq kmod mdevd mount-flatpak s6
> +    s6-linux-init s6-rc socat spectrum-host-tools spectrum-router
> +    util-linuxMinimal virtiofsd xdg-desktop-portal-spectrum-host
>  
>      (foot.override { allowPgo = false; })
>  
> diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk
> index bfe3940..df22bce 100644
> --- a/host/rootfs/file-list.mk
> +++ b/host/rootfs/file-list.mk
> @@ -55,6 +55,7 @@ FILES = \
>  	image/usr/bin/assign-devices \
>  	image/usr/bin/create-vm-dependencies \
>  	image/usr/bin/run-appimage \
> +	image/usr/bin/run-flatpak \
>  	image/usr/bin/run-vmm \
>  	image/usr/bin/spectrum-update \
>  	image/usr/bin/vm-console \
> diff --git a/host/rootfs/image/usr/bin/run-flatpak b/host/rootfs/image/usr/bin/run-flatpak
> new file mode 100755
> index 0000000..d7914a7
> --- /dev/null
> +++ b/host/rootfs/image/usr/bin/run-flatpak
> @@ -0,0 +1,47 @@
> +#!/bin/execlineb -W
> +# SPDX-License-Identifier: EUPL-1.2+
> +# SPDX-FileCopyrightText: 2024-2025 Alyssa Ross <hi@alyssa.is>
> +
> +backtick -E dir { mktemp -d /run/vm/by-id/XXXXXX }
> +backtick -E id { basename -- $dir }
> +
> +if {
> +  elgetpositionals

Serial substitution again!  Should not be an issue as $id and $dir
should not contain ‘$’, but nicer to avoid.

You can use ‘elgetpositionals’ with ‘multisubstitute’ instead.
> +  if { mkdir -p /run/configs/${id}/fs }
> +
> +  if {
> +    ln -s /usr/lib/spectrum/img/appvm/blk /usr/lib/spectrum/img/appvm/vmlinux
> +      /run/configs/${id}
> +  }
> +
> +  if { ln -s /run/configs/${id} ${dir}/config }
> +
> +  if { create-vm-dependencies $id }
> +
> +  if {
> +    nsenter --mount=${dir}/mount
> +    cd ${dir}/fs/config
> +    if { redirfd -w 1 type echo flatpak }
> +    mount-flatpak $@
> +  }
> +
> +  piperw 4 3
> +  background {
> +    fdclose 3
> +    fdmove 0 4
> +
> +    # Wait for the VMM to be up, then start the VM.
> +    if { redirfd -w 1 /dev/null head -1 }
> +    vm-start $id
> +  }
> +  fdclose 4
> +
> +  foreground { run-vmm $id }
> +}
> +
> +if { s6-instance-delete -- /run/service/vm-services $id }
> +
> +if { umount ${dir}/mount } # mount namespace
> +if { umount ${dir}/mount } # private bind mount
> +rm -r $dir /run/configs/${id}


-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 7253 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2025-12-01  5:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  4:45 [PATCH 1/5] img/app: install fuse3 globally Alyssa Ross
2025-12-01  4:45 ` [PATCH 2/5] host/rootfs: create a per-VM mount namespace Alyssa Ross
2025-12-01  4:52   ` Demi Marie Obenour
2025-12-01 14:33     ` Alyssa Ross
2025-12-01  4:45 ` [PATCH v4 3/5] tools/mount-flatpak: init Alyssa Ross
2025-12-01  5:14   ` Demi Marie Obenour
2025-12-01 11:49     ` Alyssa Ross
2025-12-01  4:45 ` [PATCH v4 4/5] img/app: run Flatpak applications Alyssa Ross
2025-12-01  4:45 ` [PATCH v4 5/5] host/rootfs: add run-flatpak script Alyssa Ross
2025-12-01  5:20   ` Demi Marie Obenour [this message]
2025-12-01 11:17     ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1bfafd4-51a6-4b41-8b74-218291954dd3@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=devel@spectrum-os.org \
    --cc=hi@alyssa.is \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).