🚀 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!

2 Likes

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.

4 Likes

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

This is a potentially very useful addition to the open source scala platform albeit in an early stage. We are all in the SIP-committee working for the community voluntarily on a non-profit basis and I do not see any ungood looks in announcing a liberally-licensed contribution to all of us. Or maybe I missed some problem that you saw but I didnt?

( @soronpo maybe ragnar just wnated to discuss/ask about policy for the sake of perceived SIP integrity and may not know how the SIP actually works in a non-profit, high-integrity mode… )

I don’t see any integrity issue here.

But, I do think that the users forum announcement was sufficient:

and it wasn’t necessary to also post it here in the contributors forum.

It’s possible other people have double-posted like this and didn’t get called out for it, but if so, it was merely because we didn’t notice. In general, double-posting like this is discouraged.

2 Likes

It’s possible other people have double-posted like this and didn’t get called out for it, but if so, it was merely because we didn’t notice. In general, double-posting like this is discouraged.

It feels to me like that’s been semi-common. I think this is a reasonable policy, but I don’t recall it being clearly stated – might be worth a clarifying post at some point.

1 Like