🚀 Introducing Scalapptainer: drive Linux containers from Scala 3, on any OS. No daemon, no root

:rocket: Introducing Scalapptainer: drive Linux containers from Scala 3, on any OS. No daemon, no root.

Ever wanted a reproducible Linux toolchain (a specific compiler, simulator, CLI, or even a GUI app) that behaves identically on every machine? Apptainer gives you exactly that: a whole environment as a single, immutable .sif file. The catch is it only runs on Linux and usually means wrestling with shell scripts.

Scalapptainer makes that catch disappear. One dependency, and the same Scala code runs on Linux, Windows (via WSL2), and macOS (via Lima). It detects your host and routes commands to the right backend. On first use it installs Apptainer for you in user mode, bundling the helper tools the installer needs so even a minimal distro just works.

The API is typed and fluent: pull/build hand you back an immutable image handle you configure with bind mounts, env vars, and X11 forwarding, then exec / run / shell. Yes, that includes GUI apps rendered right on your desktop.

Want a taste? No project, no build file, just a .scala file:

//> using dep io.github.dfiantworks::scalapptainer:0.4.0
import scalapptainer.*

@main def cow(): Unit =
  Apptainer.pull("docker://ghcr.io/dfiantworks/scalapptainer-cowsay").runInteractive()
scala run cow.scala

A ~30 MB image, an ASCII cow, and a random fortune, running in seconds. :cow_face:

:star: Check it out on GitHub: GitHub - DFiantWorks/Scalapptainer: Scalapptainer: A cross-platform Scala wrapper around Apptainer · GitHub

Apache-2.0, built with Mill. Give it a try and let me know what you build with it!

1 Like

This sounds very similar to nix, what are the similarities/differences ?
(A common misconseption is that you need NixOS to use nix, but it’s just another package manager. There’s also home-manager that is a declarative wrapper for user apps)

Don’t know enough to answer with confidence. Haven’t used nix. But from what I understand Nix is mainly about the build (ship IKEA instructions, components, and tools to build a chair) and Apptainer is mainly about the runtime (send the chair that is built with clear instructions, components and tools at the factory).

There is the build cache that builds the chair on the server, and ships only it to you
And nix guarantees that the shipped chair is exactly the same as the one you would have built locally (as long as the cache is not malicious)
To continue the metaphor, only chairs on the catalogue (nixpkgs) get pre-built on the (default) cache, if you change, say, a compilation flag, you’ll have to build it locally
(with the certainty that someone else who changed the same flag in the same way would get the same binary bit for bit)

But I think the big difference is the isolation present ?
Given apptainer gives you a container, and nix I’m not sure how it works, but I think it’s at most a chroot jail

To me its not a good look for a “SIP Committee member” advertising their 3 day old vibe coded off-topic product on the contributors forum.

3 Likes

Library announcements have been done on this forum before. Beyond that your comment is not worthy of further attention.