Painless Swift development on NixOS using rootless containers
The article describes how to set up Swift development on NixOS using Distrobox, a tool that creates rootless containers based on Docker or Podman. By running a Fedora container with Distrobox, developers can use Swift's official toolchain and package manager without modifying the host NixOS system or dealing with its packaging limitations.
Background
- Swift is Apple's programming language used for iOS/macOS apps; it has historically been difficult to use on Linux, especially on NixOS (a Linux distribution built around a unique, declarative package manager).
- Distrobox is a tool that lets you run a different Linux distribution inside a "rootless container" (a lightweight virtual environment that doesn't require admin privileges), making it easy to use software not available on your host OS.
- This post shows developers how to combine Swift and Distrobox on NixOS to get a working Swift development environment without fighting NixOS's unusual filesystem layout or package restrictions — a pain point for anyone wanting to do Apple-platform development on non-Apple Linux systems.