<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Comamoca</title>
    <description>The latest articles on DEV Community by Comamoca (@comamoca).</description>
    <link>https://dev.to/comamoca</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1010501%2F002860de-7338-46be-9417-c894054697a4.png</url>
      <title>DEV Community: Comamoca</title>
      <link>https://dev.to/comamoca</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/comamoca"/>
    <language>en</language>
    <item>
      <title>Bundle a Gleam project into an AppImage with Nix</title>
      <dc:creator>Comamoca</dc:creator>
      <pubDate>Mon, 29 Dec 2025 17:01:33 +0000</pubDate>
      <link>https://dev.to/comamoca/bundle-a-gleam-project-into-an-appimage-with-nix-66a</link>
      <guid>https://dev.to/comamoca/bundle-a-gleam-project-into-an-appimage-with-nix-66a</guid>
      <description>&lt;p&gt;This article is a translation of this &lt;a href="https://comamoca.dev/blog/2025-12-17-build-gleam-erlang-target-to-single-binary-with-nix/" rel="noopener noreferrer"&gt;Japanese article&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  nix bundle
&lt;/h2&gt;

&lt;p&gt;Nix has a convenient, albeit unstable, command called &lt;code&gt;nix bundle&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nix.dev/manual/nix/2.24/command-ref/new-cli/nix3-bundle" rel="noopener noreferrer"&gt;https://nix.dev/manual/nix/2.24/command-ref/new-cli/nix3-bundle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command packages Nix dependencies into a single binary, allowing you to generate a standalone executable.&lt;/p&gt;

&lt;p&gt;For example, running the following command will generate a single Python 3.14 binary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nix bundle nixpkgs#python314
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  bundler
&lt;/h2&gt;

&lt;p&gt;By specifying the &lt;code&gt;--bundler&lt;/code&gt; option, you can change the bundling algorithm.&lt;br&gt;
For instance, specifying &lt;code&gt;github:ralismark/nix-appimage&lt;/code&gt; allows you to generate a single binary as an AppImage.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ralismark/nix-appimage" rel="noopener noreferrer"&gt;https://github.com/ralismark/nix-appimage&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To bundle the aforementioned Python 3.14 as an AppImage, you would do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nix bundle &lt;span class="nt"&gt;--bundler&lt;/span&gt; github:ralismark/nix-appimage nixpkgs#python314
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since AppImage works by self-extracting only the necessary files on the fly, it offers faster startup speeds compared to traditional bundling methods. Therefore, using AppImage for bundling is generally recommended.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bundling Gleam
&lt;/h2&gt;

&lt;p&gt;Previously, generating a single binary with Gleam required using tools like &lt;a href=""&gt;garnet&lt;/a&gt;. However, since these rely on Deno and Bun, they were limited to the JavaScript target.&lt;/p&gt;

&lt;p&gt;The method introduced here does not depend on the features of the runtime Gleam uses, making it possible to turn Erlang targets into single binaries as well.&lt;br&gt;
I have a trial version available here; running &lt;code&gt;nix build&lt;/code&gt; should generate a single binary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Comamoca/sandbox-gleam/tree/main/appimage_build" rel="noopener noreferrer"&gt;https://github.com/Comamoca/sandbox-gleam/tree/main/appimage_build&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used &lt;code&gt;gleam2nix&lt;/code&gt; to build the Gleam project with Nix.&lt;br&gt;
&lt;a href="https://gleam2nix.foxgirl.engineering/" rel="noopener noreferrer"&gt;https://gleam2nix.foxgirl.engineering/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;code&gt;nix bundle&lt;/code&gt; allows you to turn any package into a single binary.&lt;/li&gt;
&lt;li&gt;You can switch the bundling method with the &lt;code&gt;--bundler&lt;/code&gt; option.&lt;/li&gt;
&lt;li&gt;Using AppImage provides a single binary with fast startup times.&lt;/li&gt;
&lt;li&gt;This also enables single binaries for Gleam projects targeting Erlang.&lt;/li&gt;
&lt;li&gt;It's convenient, but the binary size can become quite large (e.g., several hundred MBs).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nix</category>
      <category>gleam</category>
    </item>
  </channel>
</rss>
