From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id DF883632D; Sun, 28 Sep 2025 23:25:23 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id D4AB5629E; Sun, 28 Sep 2025 23:25:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by atuin.qyliss.net (Postfix) with ESMTPS id 203D46291 for ; Sun, 28 Sep 2025 23:25:19 +0000 (UTC) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-74435335177so69073087b3.0 for ; Sun, 28 Sep 2025 16:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759101918; x=1759706718; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CBgdcRcrfQiBaLSiUSySZBucsWwTKLlkxOjmiuepJPU=; b=fulGlCaMIpZR2BA19qt1LObLluQTjOgcuM6M988qNq6HpWmUzov8hAuICkeyrMDAkI bFRPs3C0BoqLu3eaaPLcALlWnWtNE9V++0lFJkNVBbnPZoHG2aP9GNUdF0TETwi59GV+ zeVeDUPCMiknFKR3eQUYGUGWrAqMXs5LQnjvh3HJejNzJkLOiPUl9LEvx/IAq+E8NeDm VH3I+jIo33v/eSPMQvnmPqlMi8A7+86UQ1yTh/BAa2D20Qrr4yZA982UGeH2CXZcRH6O EleBGjMCNr4Qk7J3HhUWnwmQxm9cP7OVwr52tf8EzJrL+CYmqx7kdKaeCEtUdhPtl0a1 k/+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759101918; x=1759706718; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CBgdcRcrfQiBaLSiUSySZBucsWwTKLlkxOjmiuepJPU=; b=cicep2dsgn9Wdtgx+Yswcww1a4iTbWSYEXelneyA+FaO65KyAlovDY4eElrzYqDjRi OYPTIuvkpRLW2RNJLwF9LYOKIZqs9b7u0ALD/3NHGosG1hSIz2JeFCndeAJiTQQh/L0s EPAcHTvkmzvODGCHTuPZwE46+DBIep28Ogy5Wm+uEHA13yAt4/G6/tVS/rKD6AokH1sZ cYDxS4pqIFbnQzJsFZiLVDx2PZ+CCP/+s9N6vCNpMjXkrDXCDU1txjesVdQ9iRxphgaB XdJl79bXMIDW/s+mu2US1h++4Wfo1Nd3ayhR5AJY9nAigaqpYMziGHR8o5g8+skivlqI GiBg== X-Gm-Message-State: AOJu0YxQx2+hUspQ3UmB/v87SV1UhYe2ibmpcQlbQ8fv3e43wHXtfKOf eWEr4VrPHxX5eI7JBFal7BiKIcnIdipbFaUyMgiRoUVnPfO5yAHIVBokrmj4uA== X-Gm-Gg: ASbGncv82Pfoqknr0x9DrDO2y/E7LZyXpI7EpZjo0UWpi/dte3qomvRmTauZ/Au3hHm LDrSWaBCYd6CJBwzmPMAZq+E7R6k+1ll4C2csROhqLQriSR1BIuNOL4rxGJ+EaSpWseEJyVoLFG V8M8WkgkZ83vUt4qo0o7ioXtzUh2kbbWU+knvPoaKGOGcfhEOfjSS4mZyLdzURLXp+ZO9xfTP9o AUlwFduszIV8JIY5jyo3VINzbqQDhFsFzxR+pUc7M/thQtbxpOa3QGM8ZO3x41TfFS2Wif72bRK 7Ufc/KqiInkV89GoxObQWfiBWLrVds7bBQAQT2K+DumAKPqy9y365vKyoC8bFLE3ikHbzUlFt17 WAsKibehQAAie2NB60kY13NaYsywJ5y9iOf93foI/bmSmmF4KP0sldihfASi/0jbxmey97eHVs4 W5Y9cS7ytcrxbv8ZsCquqT0mM5yJcAtoMoFrlvFoik8BlghgX+ApkYqw== X-Google-Smtp-Source: AGHT+IFvFWZaC1kypWj4nCcNr+X7NGIKdrcs4LBVdGqwxdsYQ6IML5Q9zKv0U/T2JbIpoRpxIjvkZA== X-Received: by 2002:a05:690e:1558:20b0:636:20c2:8eb8 with SMTP id 956f58d0204a3-63620c29080mr12852746d50.6.1759101917675; Sun, 28 Sep 2025 16:25:17 -0700 (PDT) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 3f1490d57ef6-eb51f3dc320sm1130575276.9.2025.09.28.16.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Sep 2025 16:25:17 -0700 (PDT) From: Demi Marie Obenour Date: Sun, 28 Sep 2025 18:51:48 -0400 Subject: [PATCH v3 2/2] host/rootfs: Switch to systemd-udevd MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250928-udev-v3-2-bb0e9612c415@gmail.com> References: <20250928-udev-v3-0-bb0e9612c415@gmail.com> In-Reply-To: <20250928-udev-v3-0-bb0e9612c415@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1759099907; l=28886; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=ptMJ283jW96D0JCeKm2f0MxW72/8SIeJsoEdId0Ru3k=; b=Y3toTsIPHBOIRtpwxh96Ddbv8m4+mMB/GZfyTJNWRIkt7xeJag8bNbWQknCsO2V7swe+fcjrx WEBoFZ95yxUD1fA6U6MqWnATgywGdF3IusRFesUXQ0Kc7jtTxQHe5/w X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: BGNHREEISLKZHTM62A5MZJIBNJ7AWMIV X-Message-ID-Hash: BGNHREEISLKZHTM62A5MZJIBNJ7AWMIV X-MailFrom: demiobenour@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Demi Marie Obenour , Alyssa Ross X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This replaces the mdevd uevent daemon with systemd-udevd, which supports much more hardware and is therefore to be preferred for a full desktop environment. Various Wayland compositors integrate with systemd-udevd, allowing them to discover devices as they appear rather than having to only use devices plugged in when the compositor is started. Additionally, systemd-udevd has quirks for various devices that are needed to support the wide variety of hardware end-users have. The dependency on /dev/dri/card0 being present is eliminated, and whatever devices the user has are now picked up by the compositor. New dependencies are added to ensure that udev coldplug has finished before any non-trivial services are started. systemd-udev-trigger.service runs 'udevadm trigger' and has Before=sysinit.target, so anything that is not an early boot service can assume 'udevadm trigger' has run. systemd-udevd unsets PATH. Therefore, manually set it to /usr/bin before invoking any scripts, like /usr/libexec/net-add. systemd-udevd provides the 'udevadm wait' command to wait for a device to appear and be processed. This replaces all uses of /etc/mdev/wait, so this script is removed. /etc/mdev/listen and /run/wait only existed to wake up /etc/mdev/wait, so they are also removed. systemd-udevd does have a module loading feature via the 'kmod load' builtin. However, this does not work, so a manual call to modprobe is used instead. Signed-off-by: Demi Marie Obenour --- I am not sure why the 'kmod load' builtin is broken in Spectrum. I suspect it is either a bug in Nixpkgs or a bug in systemd-udevd when not spawned by systemd. The simplest way to check which is the case would be to see what Gentoo does, as Gentoo uses systemd-udevd with OpenRC by default. An early version of this patch didn't allow systemd-udevd to load libkmod.so.2, but the problem persisted even after that was fixed. --- host/rootfs/Makefile | 36 +++---- host/rootfs/default.nix | 118 ++++++++------------- host/rootfs/image/etc/mdev.conf | 7 -- host/rootfs/image/etc/mdev/listen | 11 -- host/rootfs/image/etc/mdev/wait | 14 --- host/rootfs/image/etc/s6-rc/card0/type.license | 2 - host/rootfs/image/etc/s6-rc/card0/up | 4 - host/rootfs/image/etc/s6-rc/kvm/timeout-up | 1 - host/rootfs/image/etc/s6-rc/kvm/timeout-up.license | 2 - host/rootfs/image/etc/s6-rc/kvm/type | 1 - host/rootfs/image/etc/s6-rc/kvm/type.license | 2 - host/rootfs/image/etc/s6-rc/kvm/up | 4 - host/rootfs/image/etc/s6-rc/mdevd-coldplug/type | 1 - host/rootfs/image/etc/s6-rc/mdevd-coldplug/up | 4 - .../image/etc/s6-rc/mdevd/notification-fd.license | 2 - host/rootfs/image/etc/s6-rc/mdevd/run | 5 - .../contents.d/systemd-udevd-coldplug} | 0 .../dependencies.d/systemd-udevd} | 0 .../s6-rc/{card0 => systemd-udevd-coldplug}/type | 0 .../type.license | 0 .../image/etc/s6-rc/systemd-udevd-coldplug/up | 3 + .../kvm => systemd-udevd/flag-essential} | 0 .../s6-rc/{mdevd => systemd-udevd}/notification-fd | 0 .../s6-rc/systemd-udevd/notification-fd.license | 2 + host/rootfs/image/etc/s6-rc/systemd-udevd/run | 13 +++ .../image/etc/s6-rc/{mdevd => systemd-udevd}/type | 0 .../s6-rc/{mdevd => systemd-udevd}/type.license | 0 .../contents.d/systemd-udevd-coldplug} | 0 host/rootfs/image/etc/s6-rc/vm-env/type.license | 2 - .../vmm-env/contents.d/systemd-udevd-coldplug | 0 .../weston/dependencies.d/systemd-udevd-coldplug | 0 .../image/etc/udev/rules.d/99-spectrum.rules | 19 ++++ host/rootfs/image/usr/bin/run-vmm | 3 + host/rootfs/image/usr/bin/systemd-udevd | 1 + .../{etc/mdev/net/add => usr/libexec/net-add} | 0 35 files changed, 100 insertions(+), 157 deletions(-) diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile index 4b163de68c38943117eb54a9a954eb77f682c150..4945bfed3cd9000eccc3daa43bf4044497a35498 100644 --- a/host/rootfs/Makefile +++ b/host/rootfs/Makefile @@ -13,10 +13,6 @@ FILES = \ image/etc/group \ image/etc/init \ image/etc/login \ - image/etc/mdev.conf \ - image/etc/mdev/listen \ - image/etc/mdev/net/add \ - image/etc/mdev/wait \ image/etc/parse-devname \ image/etc/passwd \ image/etc/s6-linux-init/env/WAYLAND_DISPLAY \ @@ -52,6 +48,7 @@ FILES = \ image/etc/s6-linux-init/run-image/service/xdg-desktop-portal-spectrum-host/template/notification-fd \ image/etc/s6-linux-init/run-image/service/xdg-desktop-portal-spectrum-host/template/run \ image/etc/s6-linux-init/scripts/rc.init \ + image/etc/udev/rules.d/99-spectrum.rules \ image/etc/xdg/weston/autolaunch \ image/etc/xdg/weston/weston.ini \ image/usr/bin/assign-devices \ @@ -63,12 +60,14 @@ FILES = \ image/usr/bin/vm-start \ image/usr/bin/vm-stop \ image/usr/bin/xdg-open \ + image/usr/libexec/net-add \ image/usr/share/dbus-1/services/org.freedesktop.portal.Documents.service DIRS = \ dev \ etc/s6-linux-init/env \ etc/s6-linux-init/run-image/configs \ + etc/s6-linux-init/run-image/sd-notify-wrapper \ etc/s6-linux-init/run-image/service/dbus/instance \ etc/s6-linux-init/run-image/service/dbus/instances \ etc/s6-linux-init/run-image/service/dbus/template/data \ @@ -93,7 +92,6 @@ DIRS = \ etc/s6-linux-init/run-image/user \ etc/s6-linux-init/run-image/vm/by-id \ etc/s6-linux-init/run-image/vm/by-name \ - etc/s6-linux-init/run-image/wait \ ext \ proc \ run \ @@ -108,7 +106,8 @@ LINKS = \ image/etc/s6-linux-init/run-image/opengl-driver \ image/etc/s6-linux-init/run-image/service/vmm/template/run \ image/lib \ - image/sbin + image/sbin \ + image/usr/bin/systemd-udevd BUILD_FILES = build/etc/s6-rc @@ -129,21 +128,10 @@ build/empty: mkdir -p $@ S6_RC_FILES = \ - image/etc/s6-rc/card0/type \ - image/etc/s6-rc/card0/up \ image/etc/s6-rc/core/type \ image/etc/s6-rc/core/up \ - image/etc/s6-rc/kvm/timeout-up \ - image/etc/s6-rc/kvm/type \ - image/etc/s6-rc/kvm/up \ - image/etc/s6-rc/mdevd-coldplug/dependencies.d/mdevd \ - image/etc/s6-rc/mdevd-coldplug/type \ - image/etc/s6-rc/mdevd-coldplug/up \ - image/etc/s6-rc/mdevd/notification-fd \ - image/etc/s6-rc/mdevd/run \ - image/etc/s6-rc/mdevd/type \ - image/etc/s6-rc/ok-all/contents.d/mdevd-coldplug \ image/etc/s6-rc/ok-all/contents.d/sys-vmms \ + image/etc/s6-rc/ok-all/contents.d/systemd-udevd-coldplug \ image/etc/s6-rc/ok-all/contents.d/vm-env \ image/etc/s6-rc/ok-all/type \ image/etc/s6-rc/static-nodes/type \ @@ -151,14 +139,22 @@ S6_RC_FILES = \ image/etc/s6-rc/sys-vmms/dependencies.d/vmm-env \ image/etc/s6-rc/sys-vmms/type \ image/etc/s6-rc/sys-vmms/up \ + image/etc/s6-rc/systemd-udevd-coldplug/dependencies.d/systemd-udevd \ + image/etc/s6-rc/systemd-udevd-coldplug/type \ + image/etc/s6-rc/systemd-udevd-coldplug/up \ + image/etc/s6-rc/systemd-udevd/flag-essential \ + image/etc/s6-rc/systemd-udevd/notification-fd \ + image/etc/s6-rc/systemd-udevd/run \ + image/etc/s6-rc/systemd-udevd/type \ image/etc/s6-rc/vm-env/contents.d/static-nodes \ + image/etc/s6-rc/vm-env/contents.d/systemd-udevd-coldplug \ image/etc/s6-rc/vm-env/contents.d/weston \ image/etc/s6-rc/vm-env/type \ image/etc/s6-rc/vmm-env/contents.d/core \ - image/etc/s6-rc/vmm-env/contents.d/kvm \ image/etc/s6-rc/vmm-env/contents.d/static-nodes \ + image/etc/s6-rc/vmm-env/contents.d/systemd-udevd-coldplug \ image/etc/s6-rc/vmm-env/type \ - image/etc/s6-rc/weston/dependencies.d/card0 \ + image/etc/s6-rc/weston/dependencies.d/systemd-udevd-coldplug \ image/etc/s6-rc/weston/notification-fd \ image/etc/s6-rc/weston/run \ image/etc/s6-rc/weston/type diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix index 116b55232b0b9f0ef2d04a4b15ba6f198cfb832c..276cc434fdf0e3a76655ecd3565cbff164b7f3ee 100644 --- a/host/rootfs/default.nix +++ b/host/rootfs/default.nix @@ -6,88 +6,48 @@ import ../../lib/call-package.nix ( { callSpectrumPackage, lseek, src, pkgsMusl, pkgsStatic, linux_latest }: pkgsStatic.callPackage ( -{ spectrum-host-tools -, lib, stdenvNoCC, nixos, runCommand, writeClosure, erofs-utils, s6-rc -, busybox, cloud-hypervisor, cryptsetup, dbus, execline, inkscape -, iproute2, inotify-tools, jq, kmod, mdevd, s6, s6-linux-init, socat -, util-linuxMinimal, virtiofsd, xorg, xdg-desktop-portal-spectrum-host +{ busybox, cloud-hypervisor, cryptsetup, dbus, erofs-utils, execline +, inkscape, inotify-tools, iproute2, jq, lib, mdevd, nixos +, runCommand, s6, s6-linux-init, s6-rc, socat, spectrum-host-tools +, stdenvNoCC, util-linuxMinimal, virtiofsd, writeClosure +, xdg-desktop-portal-spectrum-host, xorg }: - let - inherit (nixosAllHardware.config.hardware) firmware; inherit (lib) - concatMapStringsSep concatStrings escapeShellArgs fileset optionalAttrs + concatMapStringsSep concatStrings escapeShellArgs fileset mapAttrsToList systems trivial; - pkgsGui = pkgsMusl.extend ( - final: super: - (optionalAttrs (systems.equals pkgsMusl.stdenv.hostPlatform super.stdenv.hostPlatform) { - flatpak = super.flatpak.override { - withMalcontent = false; - }; - - libgudev = super.libgudev.overrideAttrs ({ ... }: { - # Tests use umockdev, which is not compatible with libudev-zero. - doCheck = false; - }); - - qt6 = super.qt6.overrideScope (_: prev: { - qttranslations = prev.qttranslations.override { - qttools = prev.qttools.override { - qtbase = prev.qtbase.override { - qttranslations = null; - systemdSupport = false; - }; - qtdeclarative = null; - }; - }; - - qtbase = prev.qtbase.override { - systemdSupport = false; - }; - }); - - systemd = super.systemd.overrideAttrs ({ meta ? { }, ... }: { + _final: super: + (lib.optionalAttrs (systems.equals pkgsMusl.stdenv.hostPlatform super.stdenv.hostPlatform) { + malcontent = super.malcontent.overrideAttrs ({ meta ? { }, ... }: { meta = meta // { platforms = [ ]; }; }); + })); +in +# Something already pulls in the full +# systemd, so might as well use it. +pkgsGui.callPackage ( +{ cosmic-files, crosvm, dejavu_fonts, foot, kmod, mesa +, systemd, westonLite, xdg-desktop-portal, xdg-desktop-portal-gtk +}: - upower = super.upower.override { - # Not ideal, but it's the best way to get rid of an installed - # test that needs umockdev. - withIntrospection = false; - }; - - udev = final.libudev-zero; - - weston = super.weston.overrideAttrs ({ mesonFlags ? [], ... }: { - mesonFlags = mesonFlags ++ [ - "-Dsystemd=false" - ]; - }); - - xdg-desktop-portal = (super.xdg-desktop-portal.override { - enableSystemd = false; - }).overrideAttrs ({ ... }: { - # Tests use umockdev. - doCheck = false; - }); - }) - ); - - foot = pkgsGui.foot.override { allowPgo = false; }; +let + inherit (nixosAllHardware.config.hardware) firmware; + no_pgo_foot = foot.override { allowPgo = false; }; packages = [ - cloud-hypervisor cryptsetup dbus execline inotify-tools iproute2 - jq kmod mdevd s6 s6-linux-init s6-rc socat spectrum-host-tools - virtiofsd xdg-desktop-portal-spectrum-host + cloud-hypervisor crosvm cryptsetup dbus execline inotify-tools + iproute2 jq mdevd s6 s6-linux-init s6-rc socat + spectrum-host-tools virtiofsd xdg-desktop-portal-spectrum-host (busybox.override { extraConfig = '' CONFIG_CHATTR n CONFIG_DEPMOD n CONFIG_FINDFS n + CONFIG_HALT n CONFIG_INIT n CONFIG_INSMOD n CONFIG_IP n @@ -98,10 +58,13 @@ let CONFIG_MODINFO n CONFIG_MODPROBE n CONFIG_MOUNT n + CONFIG_POWEROFF n + CONFIG_REBOOT n CONFIG_RMMOD n + CONFIG_SHUTDOWN n ''; }) - ] ++ (with pkgsGui; [ cosmic-files crosvm foot ]); + ]; nixosAllHardware = nixos ({ modulesPath, ... }: { imports = [ (modulesPath + "/profiles/all-hardware.nix") ]; @@ -111,14 +74,15 @@ let kernel = linux_latest; - appvm = callSpectrumPackage ../../img/app { inherit (foot) terminfo; }; - netvm = callSpectrumPackage ../../vm/sys/net { inherit (foot) terminfo; }; + appvm = callSpectrumPackage ../../img/app { inherit (no_pgo_foot) terminfo; }; + netvm = callSpectrumPackage ../../vm/sys/net { inherit (no_pgo_foot) terminfo; }; # Packages that should be fully linked into /usr, # (not just their bin/* files). usrPackages = [ - appvm kernel.modules firmware netvm - ] ++ (with pkgsGui; [ mesa dejavu_fonts westonLite ]); + appvm kernel.modules firmware kmod kmod.lib + netvm mesa dejavu_fonts westonLite + ]; appvms = { appvm-firefox = callSpectrumPackage ../../vm/app/firefox.nix {}; @@ -136,16 +100,16 @@ let # Weston doesn't support SVG icons. inkscape -w 20 -h 20 \ -o $out/usr/share/icons/hicolor/20x20/apps/com.system76.CosmicFiles.png \ - ${pkgsGui.cosmic-files}/share/icons/hicolor/24x24/apps/com.system76.CosmicFiles.svg + ${cosmic-files}/share/icons/hicolor/24x24/apps/com.system76.CosmicFiles.svg ln -st $out/usr/bin \ ${concatMapStringsSep " " (p: "${p}/bin/*") packages} \ - ${pkgsGui.xdg-desktop-portal}/libexec/xdg-document-portal \ - ${pkgsGui.xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk + ${xdg-desktop-portal}/libexec/xdg-document-portal \ + ${xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk ln -st $out/usr/share/dbus-1 \ ${dbus}/share/dbus-1/session.conf ln -st $out/usr/share/dbus-1/services \ - ${pkgsGui.xdg-desktop-portal-gtk}/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service + ${xdg-desktop-portal-gtk}/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service for pkg in ${escapeShellArgs usrPackages}; do lndir -ignorelinks -silent "$pkg" "$out/usr" @@ -159,6 +123,10 @@ let # programs we want. # https://lore.kernel.org/util-linux/87zgrl6ufb.fsf@alyssa.is/ ln -s ${util-linuxMinimal}/bin/{findfs,uuidgen,lsblk,mount} $out/usr/bin + + # TODO: this is another hack and it should be possible + # to build systemd without this. + ln -s -- ${lib.escapeShellArg systemd}/bin/udevadm "$out/usr/bin" ''; in @@ -195,7 +163,7 @@ stdenvNoCC.mkDerivation { unsafeDiscardReferences = { out = true; }; passthru = { - inherit appvm firmware kernel nixosAllHardware packagesSysroot pkgsGui; + inherit appvm firmware kernel nixosAllHardware packagesSysroot; }; meta = with lib; { @@ -203,4 +171,4 @@ stdenvNoCC.mkDerivation { platforms = platforms.linux; }; } -) {}) (_: {}) +) {}) {}) (_: {}) diff --git a/host/rootfs/image/etc/mdev.conf b/host/rootfs/image/etc/mdev.conf deleted file mode 100644 index bddcfdc44ec2a8b1aa95e84cb88fdde625c766d8..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/mdev.conf +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021-2022, 2024 Alyssa Ross - -$PCI_CLASS=^2....$ 0:0 660 +/etc/mdev/net/add --$MODALIAS=.* 0:0 660 +importas -Siu MODALIAS modprobe -q $MODALIAS -kvm 0:0 660 +background { /etc/mdev/listen kvm } -dri/card0 0:0 660 +background { /etc/mdev/listen card0 } diff --git a/host/rootfs/image/etc/mdev/listen b/host/rootfs/image/etc/mdev/listen deleted file mode 100755 index ab50ee8c5ed1139d1129bac56afa7263af150745..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/mdev/listen +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/execlineb -S1 -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021 Alyssa Ross - -foreground { - redirfd -w 2 /dev/null - mkfifo /run/wait/${1} -} - -redirfd -w 1 /run/wait/${1} -echo diff --git a/host/rootfs/image/etc/mdev/wait b/host/rootfs/image/etc/mdev/wait deleted file mode 100755 index 6bddb303d2671ce4e5b8581cd81235d7404916e7..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/mdev/wait +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/execlineb -S1 -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021 Alyssa Ross - -foreground { - redirfd -w 2 /dev/null - mkfifo /run/wait/${1} -} - -foreground { - redirfd -w 1 /dev/null - head -1 /run/wait/${1} -} -rm /run/wait/${1} diff --git a/host/rootfs/image/etc/s6-rc/card0/type.license b/host/rootfs/image/etc/s6-rc/card0/type.license deleted file mode 100644 index c49c11b66262c7edc57ac06a486c1166d867c31d..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/card0/type.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2021 Alyssa Ross diff --git a/host/rootfs/image/etc/s6-rc/card0/up b/host/rootfs/image/etc/s6-rc/card0/up deleted file mode 100644 index 703562e5442aea45198350afe86a8f38c11ed072..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/card0/up +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2021 Alyssa Ross - -/etc/mdev/wait card0 diff --git a/host/rootfs/image/etc/s6-rc/kvm/timeout-up b/host/rootfs/image/etc/s6-rc/kvm/timeout-up deleted file mode 100644 index c5da56ae490a8ab35074fdcb6644a0dbbd280e3b..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/kvm/timeout-up +++ /dev/null @@ -1 +0,0 @@ -40000 diff --git a/host/rootfs/image/etc/s6-rc/kvm/timeout-up.license b/host/rootfs/image/etc/s6-rc/kvm/timeout-up.license deleted file mode 100644 index d705e974a864074490588104a24a9ea789141572..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/kvm/timeout-up.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2024 Alyssa Ross diff --git a/host/rootfs/image/etc/s6-rc/kvm/type b/host/rootfs/image/etc/s6-rc/kvm/type deleted file mode 100644 index bdd22a1850ae6c03a414eeb8084998679a2cdf92..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/kvm/type +++ /dev/null @@ -1 +0,0 @@ -oneshot diff --git a/host/rootfs/image/etc/s6-rc/kvm/type.license b/host/rootfs/image/etc/s6-rc/kvm/type.license deleted file mode 100644 index a941ca495a4211cf6659eda03b30f83c02985fe6..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/kvm/type.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2023 Alyssa Ross diff --git a/host/rootfs/image/etc/s6-rc/kvm/up b/host/rootfs/image/etc/s6-rc/kvm/up deleted file mode 100644 index c02e3f90245e005b98b4de8245a1863fb49c1158..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/kvm/up +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2023 Alyssa Ross - -/etc/mdev/wait kvm diff --git a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/type b/host/rootfs/image/etc/s6-rc/mdevd-coldplug/type deleted file mode 100644 index bdd22a1850ae6c03a414eeb8084998679a2cdf92..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/type +++ /dev/null @@ -1 +0,0 @@ -oneshot diff --git a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/up b/host/rootfs/image/etc/s6-rc/mdevd-coldplug/up deleted file mode 100644 index 8698f7d7988a017786fb91a584eafbfb23b3165d..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/up +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2020-2021 Alyssa Ross - -mdevd-coldplug diff --git a/host/rootfs/image/etc/s6-rc/mdevd/notification-fd.license b/host/rootfs/image/etc/s6-rc/mdevd/notification-fd.license deleted file mode 100644 index 2b3b032142b7286bd317cf0abaa44fba3a9b8941..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/mdevd/notification-fd.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2020 Alyssa Ross diff --git a/host/rootfs/image/etc/s6-rc/mdevd/run b/host/rootfs/image/etc/s6-rc/mdevd/run deleted file mode 100644 index 55899bbe674426e4591e866a4d0617361ba34305..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/mdevd/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/execlineb -P -# SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2020-2022 Alyssa Ross - -mdevd -D3 -O4 -b134217728 diff --git a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/dependencies.d/mdevd b/host/rootfs/image/etc/s6-rc/ok-all/contents.d/systemd-udevd-coldplug similarity index 100% rename from host/rootfs/image/etc/s6-rc/mdevd-coldplug/dependencies.d/mdevd rename to host/rootfs/image/etc/s6-rc/ok-all/contents.d/systemd-udevd-coldplug diff --git a/host/rootfs/image/etc/s6-rc/ok-all/contents.d/mdevd-coldplug b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/dependencies.d/systemd-udevd similarity index 100% rename from host/rootfs/image/etc/s6-rc/ok-all/contents.d/mdevd-coldplug rename to host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/dependencies.d/systemd-udevd diff --git a/host/rootfs/image/etc/s6-rc/card0/type b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/type similarity index 100% rename from host/rootfs/image/etc/s6-rc/card0/type rename to host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/type diff --git a/host/rootfs/image/etc/s6-rc/mdevd-coldplug/type.license b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/type.license similarity index 100% rename from host/rootfs/image/etc/s6-rc/mdevd-coldplug/type.license rename to host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/type.license diff --git a/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up new file mode 100644 index 0000000000000000000000000000000000000000..1732c98158046d0fb6ba6e8fb2201444fcf9128a --- /dev/null +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd-coldplug/up @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour +udevadm trigger diff --git a/host/rootfs/image/etc/s6-rc/vmm-env/contents.d/kvm b/host/rootfs/image/etc/s6-rc/systemd-udevd/flag-essential similarity index 100% rename from host/rootfs/image/etc/s6-rc/vmm-env/contents.d/kvm rename to host/rootfs/image/etc/s6-rc/systemd-udevd/flag-essential diff --git a/host/rootfs/image/etc/s6-rc/mdevd/notification-fd b/host/rootfs/image/etc/s6-rc/systemd-udevd/notification-fd similarity index 100% rename from host/rootfs/image/etc/s6-rc/mdevd/notification-fd rename to host/rootfs/image/etc/s6-rc/systemd-udevd/notification-fd diff --git a/host/rootfs/image/etc/s6-rc/systemd-udevd/notification-fd.license b/host/rootfs/image/etc/s6-rc/systemd-udevd/notification-fd.license new file mode 100644 index 0000000000000000000000000000000000000000..c4a0586a407fe14c3e0855749a7524ac3871dda4 --- /dev/null +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd/notification-fd.license @@ -0,0 +1,2 @@ +SPDX-License-Identifier: CC0-1.0 +SPDX-FileCopyrightText: 2025 Demi Marie Obenour diff --git a/host/rootfs/image/etc/s6-rc/systemd-udevd/run b/host/rootfs/image/etc/s6-rc/systemd-udevd/run new file mode 100644 index 0000000000000000000000000000000000000000..8d0fd046e2d38aef9c0010fa40aa7b9a57c76373 --- /dev/null +++ b/host/rootfs/image/etc/s6-rc/systemd-udevd/run @@ -0,0 +1,13 @@ +#!/bin/execlineb -P +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour +s6-setlock -d 4 /run/sd-notify-wrapper/systemd-udevd.lock +if { rm -f /run/sd-notify-wrapper/systemd-udevd.sock } +background { + s6-ipcserver-socketbinder -b0 -m -a 0600 /run/sd-notify-wrapper/systemd-udevd.sock + fdmove 1 3 + sd-notify-adapter +} +fdclose 3 +export NOTIFY_SOCKET /run/sd-notify-wrapper/systemd-udevd.sock +systemd-udevd diff --git a/host/rootfs/image/etc/s6-rc/mdevd/type b/host/rootfs/image/etc/s6-rc/systemd-udevd/type similarity index 100% rename from host/rootfs/image/etc/s6-rc/mdevd/type rename to host/rootfs/image/etc/s6-rc/systemd-udevd/type diff --git a/host/rootfs/image/etc/s6-rc/mdevd/type.license b/host/rootfs/image/etc/s6-rc/systemd-udevd/type.license similarity index 100% rename from host/rootfs/image/etc/s6-rc/mdevd/type.license rename to host/rootfs/image/etc/s6-rc/systemd-udevd/type.license diff --git a/host/rootfs/image/etc/s6-rc/weston/dependencies.d/card0 b/host/rootfs/image/etc/s6-rc/vm-env/contents.d/systemd-udevd-coldplug similarity index 100% rename from host/rootfs/image/etc/s6-rc/weston/dependencies.d/card0 rename to host/rootfs/image/etc/s6-rc/vm-env/contents.d/systemd-udevd-coldplug diff --git a/host/rootfs/image/etc/s6-rc/vm-env/type.license b/host/rootfs/image/etc/s6-rc/vm-env/type.license deleted file mode 100644 index 5a4063310c3d22dbf59b30792e8e6f55a57ec9c0..0000000000000000000000000000000000000000 --- a/host/rootfs/image/etc/s6-rc/vm-env/type.license +++ /dev/null @@ -1,2 +0,0 @@ -SPDX-License-Identifier: CC0-1.0 -SPDX-FileCopyrightText: 2022 Alyssa Ross diff --git a/host/rootfs/image/etc/s6-rc/vmm-env/contents.d/systemd-udevd-coldplug b/host/rootfs/image/etc/s6-rc/vmm-env/contents.d/systemd-udevd-coldplug new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/host/rootfs/image/etc/s6-rc/weston/dependencies.d/systemd-udevd-coldplug b/host/rootfs/image/etc/s6-rc/weston/dependencies.d/systemd-udevd-coldplug new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules b/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules new file mode 100644 index 0000000000000000000000000000000000000000..f9047d5dabe493f21b5f27d6ef7d44b31f9d741b --- /dev/null +++ b/host/rootfs/image/etc/udev/rules.d/99-spectrum.rules @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour + +# systemd-udevd has a built-in module loading feature, +# but it seems to not work for some reason or another. +# This works. +ACTION!="remove", ENV{MODALIAS}!="", RUN+="/usr/bin/modprobe -q $env{MODALIAS}" +# systemd-udevd unsets PATH, so fix that. +ACTION=="remove", GOTO="spectrum-end" +ENV{PCI_CLASS}!="2????", GOTO="spectrum-end" + +# net-add unbinds and rebinds the driver, so avoid calling +# it more than once. +IMPORT{db}="SPECTRUM_DRIVER_ASSIGNED" +ENV{SPECTRUM_DRIVER_ASSIGNED}=="yes", GOTO="spectrum-end" +# systemd-udevd unsets PATH, so fix that. +RUN+="/usr/bin/env PATH=/usr/bin /usr/libexec/net-add" +ENV{SPECTRUM_DRIVER_ASSIGNED}="yes" +LABEL="spectrum-end" diff --git a/host/rootfs/image/usr/bin/run-vmm b/host/rootfs/image/usr/bin/run-vmm index bcb6cdaf6646da6bb4970fe97f5ef03badbd66a6..00d8b0ee75311855f0b2c0686b66616c747b68c0 100755 --- a/host/rootfs/image/usr/bin/run-vmm +++ b/host/rootfs/image/usr/bin/run-vmm @@ -53,4 +53,7 @@ unexport ! fdmove -c 3 0 redirfd -r 0 /dev/null +# Do this last so that udev has as much +# time to set up KVM as possible. +if { udevadm wait /dev/kvm } cloud-hypervisor --api-socket fd=3 diff --git a/host/rootfs/image/usr/bin/systemd-udevd b/host/rootfs/image/usr/bin/systemd-udevd new file mode 120000 index 0000000000000000000000000000000000000000..b7887eaf6dd3279116ba61d613bd467598089597 --- /dev/null +++ b/host/rootfs/image/usr/bin/systemd-udevd @@ -0,0 +1 @@ +udevadm \ No newline at end of file diff --git a/host/rootfs/image/etc/mdev/net/add b/host/rootfs/image/usr/libexec/net-add similarity index 100% rename from host/rootfs/image/etc/mdev/net/add rename to host/rootfs/image/usr/libexec/net-add -- 2.51.0