[PATCH 1/7] host/rootfs: Use full util-linux and systemd

Demi Marie Obenour
2025-10-29T10:14:26Z

Busybox provides a broken fdisk that doesn't support GPT, only MBR.
The systemd built against musl doesn't include systemd-pull, so
systemd-sysupdate doesn't work. Therefore, use all of util-linux's
command-line tools, and use systemd built against glibc.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
host/rootfs/default.nix | 43 ++++++++++++++++++-------------------------
1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 0d79f7ca54ccc86eb0fa6e743f2011237d365f24..00052222507077b9e94a5ed0a3fbddd27caeefc3 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -4,20 +4,20 @@

import ../../lib/call-package.nix (
{ callSpectrumPackage, spectrum-build-tools, src
-, pkgsMusl, pkgsStatic, linux_latest
+, pkgsMusl, pkgsStatic, linux_latest, systemd
}:
pkgsStatic.callPackage (

{ 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
+, stdenvNoCC, util-linux, virtiofsd, writeClosure
, xdg-desktop-portal-spectrum-host, xorg
}:
let
inherit (lib)
- concatMapStringsSep concatStrings escapeShellArgs fileset
- mapAttrsToList systems trivial;
+ concatMapStringsSep concatStrings escapeShellArg
+ escapeShellArgs fileset mapAttrsToList systems trivial;
pkgsGui = pkgsMusl.extend (
_final: super:
(lib.optionalAttrs (systems.equals pkgsMusl.stdenv.hostPlatform super.stdenv.hostPlatform) {
@@ -32,7 +32,7 @@ in
# 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
+, westonLite, xdg-desktop-portal, xdg-desktop-portal-gtk
}:

let
@@ -83,7 +83,7 @@ let
# (not just their bin/* files).
usrPackages = [
appvm kernel.modules firmware kmod kmod.lib
- netvm mesa dejavu_fonts westonLite
+ netvm mesa dejavu_fonts systemd util-linux westonLite
];

appvms = {
@@ -99,36 +99,29 @@ let
mkdir -p $out/usr/bin $out/usr/share/dbus-1/services \
$out/usr/share/icons/hicolor/20x20/apps

+ for pkg in ${escapeShellArgs usrPackages}; do
+ lndir -ignorelinks -silent "$pkg" "$out/usr"
+ done
+
# Weston doesn't support SVG icons.
inkscape -w 20 -h 20 \
-o $out/usr/share/icons/hicolor/20x20/apps/com.system76.CosmicFiles.png \
${cosmic-files}/share/icons/hicolor/24x24/apps/com.system76.CosmicFiles.svg

- ln -st $out/usr/bin \
- ${concatMapStringsSep " " (p: "${p}/bin/*") packages} \
- ${xdg-desktop-portal}/libexec/xdg-document-portal \
- ${xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk
+ ln -sft "$out/usr/bin" \
+ ${concatMapStringsSep " " (p: "${escapeShellArg p}/bin/*") packages} \
+ ${escapeShellArg xdg-desktop-portal}/libexec/xdg-document-portal \
+ ${escapeShellArg xdg-desktop-portal-gtk}/libexec/xdg-desktop-portal-gtk
ln -st $out/usr/share/dbus-1 \
- ${dbus}/share/dbus-1/session.conf
+ ${escapeShellArg dbus}/share/dbus-1/session.conf
ln -st $out/usr/share/dbus-1/services \
- ${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"
- done
+ ${escapeShellArg xdg-desktop-portal-gtk}/share/dbus-1/services/org.freedesktop.impl.portal.desktop.gtk.service
+ # clobber any conflicting files from busybox
+ ln -sft "$out/usr/bin" ${escapeShellArg util-linux}/bin/*

${concatStrings (mapAttrsToList (name: path: ''
ln -s ${path} $out/usr/lib/spectrum/vm/${name}
'') appvms)}
-
- # TODO: this is a hack and we should just build the util-linux
- # 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

--
2.51.2