<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on Man-You</title><link>https://man-you.ringum.net/tags/linux/</link><description>Recent content in Linux on Man-You</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 24 Mar 2026 09:30:00 +0100</lastBuildDate><atom:link href="https://man-you.ringum.net/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>The most useless way to port a macOS app</title><link>https://man-you.ringum.net/posts/clone-desktop/</link><pubDate>Tue, 24 Mar 2026 09:30:00 +0100</pubDate><guid>https://man-you.ringum.net/posts/clone-desktop/</guid><description>&lt;p&gt;I grew up fascinated by projects like GNUStep, Haiku, Etoile, Wine, and ReactOS. Engineering feats, all of them. They reverse-engineer or reimplement entire operating system APIs so that software written for one platform can run on another. And they almost always end up in the same place: impressive technically, starved for contributors, forever chasing a moving target they can never quite catch.&lt;/p&gt;
&lt;p&gt;I never liked the state of the Linux desktop either. Not because it&amp;rsquo;s bad per se, but because it&amp;rsquo;s fragmented. A KDE app on GNOME looks alien. Firefox rolls its own everything. GTK and Qt will never agree on anything. Every toolkit draws its own widgets, manages its own text rendering, handles its own accessibility story. The result is a desktop that feels like a coalition of independent projects rather than a coherent system.&lt;/p&gt;
&lt;p&gt;This project is not going to fix any of that. But it&amp;rsquo;s an interesting story about how a combination of prior work, Apple open-sourcing key components, and an AI pair programmer led me down a rabbit hole I didn&amp;rsquo;t plan to enter.&lt;/p&gt;
&lt;h2 id="the-prior-art-that-made-this-possible"&gt;The prior art that made this possible&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;ve been working with wgpu (Rust&amp;rsquo;s WebGPU implementation) for a while now, building a &lt;a href="https://man-you.ringum.net/backroom/woosmap-tiles/"&gt;map renderer&lt;/a&gt; for Woosmap. That project taught me the fundamentals: how to manage GPU pipelines, how to do instanced rendering, how to deal with text atlases and glyph rasterization, how to bridge Rust and Swift through UniFFI.&lt;/p&gt;
&lt;p&gt;On the Swift side, I had two apps: &lt;strong&gt;Tunes&lt;/strong&gt;, a music player, and &lt;strong&gt;Leela&lt;/strong&gt;, an internal management tool for Woosmap services. Both are SwiftUI apps, both depend on Apple&amp;rsquo;s frameworks in the usual way.&lt;/p&gt;
&lt;p&gt;So one evening, half-curious and half-joking, I fed Claude the source of those projects alongside some context about GNUStep and friends, and typed:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;ldquo;What would it take to make Tunes build and run on Linux?&amp;rdquo;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And then things got out of control.&lt;/p&gt;
&lt;h2 id="what-claude-came-back-with"&gt;What Claude came back with&lt;/h2&gt;
&lt;p&gt;The answer was, predictably, &amp;ldquo;a lot.&amp;rdquo; But the interesting part was the breakdown. SwiftUI is the main dependency, and SwiftUI is closed-source. But Swift itself is open-source. Swift Foundation is open-source. The Swift Package Manager works on Linux. So the gap is really:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A SwiftUI implementation (the view hierarchy, state management, layout engine, modifiers)&lt;/li&gt;
&lt;li&gt;Some AppKit shims (NSColor, NSAppearance, the bits that SwiftUI still leans on)&lt;/li&gt;
&lt;li&gt;A rendering backend that isn&amp;rsquo;t Core Animation or Metal&lt;/li&gt;
&lt;li&gt;A compositor to manage windows, menus, and the desktop chrome&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Instead of stopping at &amp;ldquo;that&amp;rsquo;s insane, don&amp;rsquo;t do it,&amp;rdquo; I kept going. Claude kept going. We started building.&lt;/p&gt;
&lt;h2 id="architecture"&gt;Architecture&lt;/h2&gt;
&lt;p&gt;The project (codenamed &lt;strong&gt;Clone&lt;/strong&gt;) splits pretty naturally along a language boundary.&lt;/p&gt;
&lt;p&gt;Rust does what Rust is good at: GPU work. A wgpu renderer with pipelines for rectangles, rounded rects (SDF-based, because I can&amp;rsquo;t stop using SDFs apparently), shadows, text via a glyph atlas, and wallpapers. It also runs the window compositor through winit.&lt;/p&gt;
&lt;p&gt;Swift does what Swift is good at: UI. A from-scratch SwiftUI implementation (about 50 View types, &lt;code&gt;@State&lt;/code&gt;/&lt;code&gt;@Binding&lt;/code&gt;/&lt;code&gt;@Environment&lt;/code&gt;, &lt;code&gt;ViewBuilder&lt;/code&gt;, layout, modifiers), the whole declarative stack. Plus enough AppKit shims to keep real apps happy, a SwiftData reimplementation backed by SQLite, and an IPC protocol over Unix sockets.&lt;/p&gt;
&lt;p&gt;UniFFI bridges the two. Each frame, Rust asks Swift for render commands, Swift resolves the view tree into a flat list of positioned primitives, and Rust batches them into instanced GPU draws. It&amp;rsquo;s the same bridge I use in the map renderer, so at least that part wasn&amp;rsquo;t new territory.&lt;/p&gt;
&lt;pre class="mermaid"&gt;graph LR
A["App.body"] --&gt; B["ViewBuilder"] --&gt; C["_resolve()"] --&gt; D["Layout"]
D --&gt; E["CommandFlattener"] --&gt; F["IPC
CGFloat → Float"] --&gt; G["Rust batcher"] --&gt; H["wgpu draws"]
style A fill:#c4a7e7,stroke:#6e6a86,color:#191724
style B fill:#c4a7e7,stroke:#6e6a86,color:#191724
style C fill:#c4a7e7,stroke:#6e6a86,color:#191724
style D fill:#c4a7e7,stroke:#6e6a86,color:#191724
style E fill:#f6c177,stroke:#6e6a86,color:#191724
style F fill:#f6c177,stroke:#6e6a86,color:#191724
style G fill:#9ccfd8,stroke:#6e6a86,color:#191724
style H fill:#9ccfd8,stroke:#6e6a86,color:#191724
&lt;/pre&gt;
&lt;h2 id="first-signs-of-life"&gt;First signs of life&lt;/h2&gt;
&lt;p&gt;The moment I&amp;rsquo;ll remember is the grey rectangle. &amp;ldquo;Clone Desktop&amp;rdquo; in the center, a dock at the bottom with colored squares. I&amp;rsquo;d been at it for hours, wrestling with UniFFI bindings and layout math, and suddenly there it was: pixels on screen, drawn by Swift code, pushed through a Rust GPU backend, on something that was decidedly not macOS.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
&lt;img
src="https://man-you.ringum.net/posts/clone-desktop/clone-1_hu_60da9db4b46e573c.webp"
srcset="https://man-you.ringum.net/posts/clone-desktop/clone-1_hu_60da9db4b46e573c.webp 960w, https://man-you.ringum.net/posts/clone-desktop/clone-1_hu_cd2b29062a903b83.webp 2784w"
sizes="(max-width: 960px) 100vw, 960px"
alt="The first Clone Desktop render: a grey surface, centered label, and a color-swatch dock"
width="960"
height="651"
loading="lazy"
decoding="async"
/&gt;
&lt;figcaption&gt;Day one: a grey box, a label, and a dock. It&amp;#39;s not much, but it compiles and renders.&lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id="settings-and-finder"&gt;Settings and Finder&lt;/h2&gt;
&lt;p&gt;Once the basic views worked (stacks, text, lists, navigation), I needed something real to throw at them. Settings was a natural first target: sidebars, forms, toggles, text fields, the kind of layout variety that breaks things fast. Finder came next because browsing a directory with &lt;code&gt;List&lt;/code&gt; and &lt;code&gt;ForEach&lt;/code&gt; is such a fundamental SwiftUI pattern that if it didn&amp;rsquo;t work, nothing would.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
&lt;img
src="https://man-you.ringum.net/posts/clone-desktop/clone-2_hu_c535fac1e06a428f.webp"
srcset="https://man-you.ringum.net/posts/clone-desktop/clone-2_hu_c535fac1e06a428f.webp 960w, https://man-you.ringum.net/posts/clone-desktop/clone-2_hu_d543a0938420ea6e.webp 2784w"
sizes="(max-width: 960px) 100vw, 960px"
alt="Clone Desktop running Settings (Wi-Fi panel) and Finder side by side, dark mode"
width="960"
height="651"
loading="lazy"
decoding="async"
/&gt;
&lt;figcaption&gt;Settings showing Wi-Fi preferences alongside Finder browsing the home directory. Both are SwiftUI apps running through Clone&amp;#39;s stack.&lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Dark mode just kind of happened. Once I shimmed &lt;code&gt;NSAppearance&lt;/code&gt; and implemented the semantic color system (&lt;code&gt;Color.primary&lt;/code&gt;, &lt;code&gt;.secondary&lt;/code&gt;, the system grays), flipping between light and dark was a toggle. A small thing, but unreasonably satisfying: it made the whole experiment feel like a real desktop for the first time.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
&lt;img
src="https://man-you.ringum.net/posts/clone-desktop/clone-3_hu_7656abf32f2c59d8.webp"
srcset="https://man-you.ringum.net/posts/clone-desktop/clone-3_hu_7656abf32f2c59d8.webp 960w, https://man-you.ringum.net/posts/clone-desktop/clone-3_hu_477ea4514a69efe6.webp 2784w"
sizes="(max-width: 960px) 100vw, 960px"
alt="Settings showing the General panel in light mode"
width="960"
height="651"
loading="lazy"
decoding="async"
/&gt;
&lt;figcaption&gt;The same Settings app in light mode. Appearance switching works through the reimplemented NSAppearance and Color system.&lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id="tunes"&gt;Tunes&lt;/h2&gt;
&lt;p&gt;This was the whole point, remember? &amp;ldquo;What would it take to make Tunes build and run on Linux?&amp;rdquo; Well, it builds. The login sheet renders inside the app window rather than as a separate &lt;code&gt;NSPanel&lt;/code&gt; (a compromise, but not a terrible one), and the SwiftUI code is essentially unchanged. &lt;code&gt;TextField&lt;/code&gt;, &lt;code&gt;SecureField&lt;/code&gt;, &lt;code&gt;Toggle&lt;/code&gt;, &lt;code&gt;Button&lt;/code&gt;, &lt;code&gt;Link&lt;/code&gt;: they all resolve and render. Same source, different universe.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
&lt;img
src="https://man-you.ringum.net/posts/clone-desktop/clone-4_hu_5ff44dcb7735661f.webp"
srcset="https://man-you.ringum.net/posts/clone-desktop/clone-4_hu_5ff44dcb7735661f.webp 960w, https://man-you.ringum.net/posts/clone-desktop/clone-4_hu_b08f4d867416f64c.webp 2784w"
sizes="(max-width: 960px) 100vw, 960px"
alt="Tunes showing a login form with username/password fields, a toggle, and a registration link, alongside a Finder window"
width="960"
height="651"
loading="lazy"
decoding="async"
/&gt;
&lt;figcaption&gt;Tunes running its login flow through Clone. The sheet renders in-window rather than as a separate panel, one of many compromises.&lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;h2 id="leela"&gt;Leela&lt;/h2&gt;
&lt;p&gt;Leela is a management dashboard for Woosmap services: tabs, lists, nested navigation, version selectors, deploy queues. Most of the UI is driven by API responses, so it hammers &lt;code&gt;ForEach&lt;/code&gt; with dynamic data, &lt;code&gt;@StateObject&lt;/code&gt;, and conditional rendering. If Settings was a stroll through the park, Leela was a stress test.&lt;/p&gt;
&lt;p&gt;&lt;figure&gt;
&lt;img
src="https://man-you.ringum.net/posts/clone-desktop/clone-5_hu_2145acbb1b59b75f.webp"
srcset="https://man-you.ringum.net/posts/clone-desktop/clone-5_hu_2145acbb1b59b75f.webp 960w, https://man-you.ringum.net/posts/clone-desktop/clone-5_hu_a5c8020ac9f97b4f.webp 2784w"
sizes="(max-width: 960px) 100vw, 960px"
alt="Leela showing a service management view with sidebar navigation, tab bar, version tags, and service listings"
width="960"
height="651"
loading="lazy"
decoding="async"
/&gt;
&lt;figcaption&gt;Leela&amp;#39;s services view running through Clone. Tabs, lists, version badges, sidebar navigation, all SwiftUI, all reimplemented.&lt;/figcaption&gt;
&lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;I won&amp;rsquo;t pretend it was smooth. Getting here meant implementing a surprising amount of SwiftUI&amp;rsquo;s surface area. The state management system alone (&lt;code&gt;StateGraph&lt;/code&gt;, scoped identity for &lt;code&gt;ForEach&lt;/code&gt;, call-index disambiguation) went through several iterations where everything would render once and then silently stop updating. The kind of bug where you stare at a diff for an hour before realizing a closure captured a copy instead of a reference.&lt;/p&gt;
&lt;h2 id="under-the-hood"&gt;Under the hood&lt;/h2&gt;
&lt;h3 id="text-rendering"&gt;Text rendering&lt;/h3&gt;
&lt;p&gt;Text goes through cosmic-text for shaping, then gets rasterized into a 4096x4096 glyph atlas (single-channel, R8). Each glyph is cached and rendered as an instanced GPU quad. Fonts are bundled: Inter for UI text, Phosphor for icons.&lt;/p&gt;
&lt;p&gt;This is almost certainly not how Apple does it. A real system would share GPU textures between the compositor and app, or pull from a system font cache. But it works, and there&amp;rsquo;s a special joy in watching a glyph atlas fill up character by character as the UI renders for the first time.&lt;/p&gt;
&lt;h3 id="layout"&gt;Layout&lt;/h3&gt;
&lt;p&gt;I reverse-engineered SwiftUI&amp;rsquo;s layout by reading &lt;a href="https://www.objc.io/books/thinking-in-swiftui/"&gt;objc.io&amp;rsquo;s&lt;/a&gt; thinking-in-swiftui and a lot of trial and error. The model: parents propose a size to children, children report back what they need, parents position them. Sounds simple until &lt;code&gt;ZStack&lt;/code&gt; enters the picture: nil-sized views from &lt;code&gt;.background()&lt;/code&gt; modifiers would expand to fill constraints and eat space from real siblings. That one took a while.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ScrollView&lt;/code&gt; was another head-scratcher: it fills its proposed size but lays out content unbounded in the scroll axis. Getting that inversion right, where the container constrains in one direction and is infinite in the other, broke my mental model twice before clicking.&lt;/p&gt;
&lt;h3 id="ipc"&gt;IPC&lt;/h3&gt;
&lt;p&gt;Each app is a separate process. The compositor (CloneDesktop) runs the Rust event loop and manages surfaces. Apps connect over a Unix socket at &lt;code&gt;/tmp/clone-compositor.sock&lt;/code&gt; and exchange length-prefixed JSON messages. There&amp;rsquo;s an annoying &lt;code&gt;CGFloat&lt;/code&gt;-to-&lt;code&gt;Float&lt;/code&gt; conversion at the wire boundary: Swift thinks in 64-bit coordinates, the GPU thinks in &lt;code&gt;f32&lt;/code&gt;, and someone has to reconcile that at the border.&lt;/p&gt;
&lt;h3 id="the-ycodebuild-trick"&gt;The &lt;code&gt;ycodebuild&lt;/code&gt; trick&lt;/h3&gt;
&lt;p&gt;This is probably my favorite hack in the project. To compile an existing macOS app against Clone instead of Apple&amp;rsquo;s frameworks, &lt;code&gt;ycodebuild&lt;/code&gt; generates a shadow SPM package that maps &lt;code&gt;import SwiftUI&lt;/code&gt; to Clone&amp;rsquo;s SwiftUI, &lt;code&gt;import AppKit&lt;/code&gt; to Clone&amp;rsquo;s shims, and so on. The app source code doesn&amp;rsquo;t change at all: you just build against a different package graph, and the compiled binary talks to the compositor over the socket. The same &lt;code&gt;.swift&lt;/code&gt; file, two completely different platforms.&lt;/p&gt;
&lt;h2 id="honest-assessment"&gt;Honest assessment&lt;/h2&gt;
&lt;p&gt;I should be upfront about the gap between &amp;ldquo;it renders&amp;rdquo; and &amp;ldquo;it works.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Animations are mostly stubbed. Accessibility is nonexistent. The compositor redraws every surface every frame like it&amp;rsquo;s 1997. There are &lt;code&gt;// TODO: implement&lt;/code&gt; scattered across the codebase where AppKit APIs return no-ops and hope nobody notices. Sheets render in-window because I never built the panel system. The glyph atlas will fall over the moment someone opens a CJK document.&lt;/p&gt;
&lt;p&gt;And (this is the awkward part) it doesn&amp;rsquo;t actually run on Linux yet. The whole premise was &amp;ldquo;what would it take,&amp;rdquo; and the answer turned out to include some Apple framework dependencies I haven&amp;rsquo;t replaced with their open-source equivalents. It&amp;rsquo;s doable. It&amp;rsquo;s just not done.&lt;/p&gt;
&lt;p&gt;But here&amp;rsquo;s the thing that caught me off guard. The time from that initial Claude prompt to a state where Tunes and Leela compile and render recognizable UI was hours, not weeks. Not autonomous AI magic (plenty of manual fixes and architectural decisions along the way) but Claude carried an enormous amount of boilerplate: generating 50 View type stubs, wiring up modifier chains, implementing the state graph, setting up IPC. The kind of work that would&amp;rsquo;ve taken me days of tedious typing, compressed into a conversation.&lt;/p&gt;
&lt;h2 id="why-this-matters-a-little"&gt;Why this matters (a little)&lt;/h2&gt;
&lt;p&gt;Apple open-sourcing Swift and Foundation was a bigger deal than most people realize. Not because anyone&amp;rsquo;s going to ship a SwiftUI app on Linux tomorrow, but because it lowered the floor for experiments like this from &amp;ldquo;completely impossible&amp;rdquo; to &amp;ldquo;merely impractical.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The projects I admired growing up (GNUStep, Haiku, Wine) were built by small teams reverse-engineering closed systems over years. The combination of open-source language infrastructure and AI assistance compresses that timeline dramatically. Not to a point where it&amp;rsquo;s practical or production-ready, but to a point where a single person can explore the shape of the problem in a weekend.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s the real takeaway. Not &amp;ldquo;I ported macOS to Linux.&amp;rdquo; I didn&amp;rsquo;t. But I went from a throwaway prompt to colored boxes on screen running real SwiftUI app code, and that felt like something worth writing about.&lt;/p&gt;
&lt;h2 id="whats-next"&gt;What&amp;rsquo;s next&lt;/h2&gt;
&lt;p&gt;Honestly? Probably nothing. The project scratched a twenty-year itch. But I know myself, and I know there&amp;rsquo;s a Kawase blur pipeline sitting unused in the renderer that&amp;rsquo;s going to call my name at 11pm some Tuesday. If I do keep going:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Per-window offscreen textures&lt;/strong&gt;: the compositor shouldn&amp;rsquo;t redraw everything every frame, that&amp;rsquo;s embarrassing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Glassmorphism / backdrop blur&lt;/strong&gt;: because what&amp;rsquo;s the point of reimplementing macOS if you can&amp;rsquo;t have the frosted glass&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Actually running on Linux&lt;/strong&gt;: the whole original premise, still unfinished&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shared GPU textures&lt;/strong&gt;: how a real compositor would work, instead of copying pixels through a socket like an animal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Or maybe it stays as a weekend experiment and a blog post. Either way, the kid who thought GNUStep was the coolest thing ever is pretty happy right now.&lt;/p&gt;</description></item></channel></rss>