Bundle a Gleam project into an AppImage with Nix

Published: (December 29, 2025 at 12:01 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

nix bundle

Nix has a convenient, albeit unstable, command called nix bundle.

Documentation: nix3‑bundle manual

This command packages Nix dependencies into a single binary, allowing you to generate a standalone executable.

Example

nix bundle nixpkgs#python314

bundler

By specifying the --bundler option, you can change the bundling algorithm.

For instance, using github:ralismark/nix-appimage generates a single binary as an AppImage.

Repository: nix‑appimage

To bundle the aforementioned Python 3.14 as an AppImage

nix bundle --bundler github:ralismark/nix-appimage nixpkgs#python314

AppImage works by self‑extracting only the necessary files on the fly, offering faster startup speeds compared to traditional bundling methods. Therefore, using AppImage for bundling is generally recommended.

Bundling Gleam

Previously, generating a single binary with Gleam required tools like garnet, which relied on Deno and Bun and were limited to the JavaScript target.

The method introduced here does not depend on the runtime features Gleam uses, making it possible to turn Erlang targets into single binaries as well.

A trial version is available here; running nix build should generate a single binary:

sandbox‑gleam appimage_build

The project uses gleam2nix to build the Gleam code with Nix:

gleam2nix

Summary

  • Using nix bundle allows you to turn any package into a single binary.
  • You can switch the bundling method with the --bundler option.
  • Using AppImage provides a single binary with fast startup times.
  • This also enables single binaries for Gleam projects targeting Erlang.
  • It’s convenient, but the binary size can become quite large (e.g., several hundred MB).
Back to Blog

Related posts

Read more »

Sort by File Extension - Bash Script

Overview This Bash script organizes the contents of a directory by file extension. It creates a sorted_files folder inside the source directory and, for each d...

Why Bash Syntax Feels So Arcane

Bash’s Historical Roots Bash runs deep beneath the surface of Linux. With only a line or two, it can take full control of your machine. It is often viewed by b...

[Boost]

The 5-Second Boot: Building a Minimalist 'Browser OS' for 1GB RAM Machines techno kraft ・ Jan 1 discuss performance challenge archlinux...