<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>Brandon Lucas: Blog</title>
<link>https://blu.cx/posts/blog/</link>
<description>Brandon Lucas writes about software, history and philosophy, and builds Kai and Lyceum.</description>
<language>en</language>
<atom:link href="https://blu.cx/posts/blog/rss.xml" rel="self" type="application/rss+xml"/>
<item><title>Kai Devlog #6: κατακλυσμός!</title><link>https://blu.cx/posts/blog/2026-09-19-kai-devlog-6/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-09-19-kai-devlog-6/</guid><pubDate>Sat, 19 Sep 2026 12:00:00 +0000</pubDate><description>Refactoring Kai's plugin schema while adding better errors, system management, deployment, ISO creation, SOPS secrets, and backend escape hatches.</description><content:encoded><![CDATA[<blockquote>
<p>Are we being good ancestors?</p>
<p>— <a href="https://longnow.org/clock/">Jonas Salk, referenced from <em>The 10,000-year clock</em> below</a></p>
</blockquote>
<!-- Keep adjacent quotations as separate blockquotes. -->
<blockquote>
<p>The 10,000-year clock will mark time with astronomic and calendric displays and a chime generator designed with the help of Brian Eno that can produce over 3.5 million unique bell chime sequences — one for every day the clock is visited for the next 10,000 years.</p>
</blockquote>
<!-- Keep adjacent quotations as separate blockquotes. -->
<blockquote>
<p>Ten thousand years is about the age of modern civilization, so the clock will measure out a future of civilization equal to its past. This assumes our civilization is in the middle of whatever journey we are on — an implicit statement of optimism.</p>
</blockquote>
<p><a href="https://longnow.org/clock/">The 10,000-year clock</a></p>
<p><img src="/images/blog/kai-devlog-6/clock.png" alt="The 10,000-year clock mechanism" /></p>
<p>How do you build a clock that will last 10,000 years? Look at the list given in the article above:</p>
<blockquote>
<p>Longevity</p>
<p>10,000-year clocks should display the correct time for the next 10,000 years</p>
<ul>
<li>Go slow</li>
<li>Minimize sliding friction</li>
<li>Stay clean and dry</li>
<li>Expect bad weather and earthquakes</li>
<li>Expect non-malicious human interaction</li>
<li>Don’t tempt thieves</li>
</ul>
<p>Maintainability</p>
<p>It should be possible to maintain a 10,000-year clock with little maintenance, using bronze-age technology</p>
<ul>
<li>Use familiar materials</li>
<li>Make it easy to build parts</li>
<li>Include the manual</li>
</ul>
<p>Transparency</p>
<p>It should be possible to determine the operational principles of a 10,000-year clock with close inspection</p>
<ul>
<li>Allow inspection</li>
<li>Allow rehearsed motions</li>
<li>Expect restarts</li>
</ul>
<p>Evolvability</p>
<p>It should be possible to improve a 10,000-year clock over time</p>
<ul>
<li>Separate functions</li>
<li>Provide simple interfaces</li>
</ul>
<p>Scalability</p>
<p>It should be possible to build working models of a 10,000-year clock from table top to monumental size using the same design</p>
<ul>
<li>Make all parts similar size</li>
</ul>
</blockquote>
<p>Some of these sound similar to software, no?</p>
<blockquote>
<ul>
<li>Make it easy to build parts</li>
<li>Include the manual</li>
<li>Separate functions</li>
<li>Provide simple interfaces</li>
</ul>
</blockquote>
<p>Indeed, many fundamental principles of nature are true across domains.</p>
<p>This latest release is called <a href="https://github.com/thebrandonlucas/kai/releases/tag/v0.0.7"><em>κατακλυσμός</em></a>, and for the savvy transliterator, you can see that means <em>cataclysm</em>!</p>
<p>But its real meaning in <a href="https://en.wikipedia.org/wiki/Koine_Greek">Koine</a> Greek is more like <em>flood</em>, which is a better description for this release. The biggest <em>single</em> change, though, is once again another plugin refactor — and we’ll probably do it again. Getting those abstractions right will allow Kai to be designed for the Long Now, and hopefully grow organically into something great that can stand the test of time.</p>
<p><strong>Please note: SOPS/system-level commands modify system state and that and the ISO command is very experimental. Use them with caution on disposable machines as this is still a prototype!</strong></p>
<p>Highlights:</p>
<ul>
<li>Refactored the plugin schema (again)</li>
<li>Lots of ergonomics and UX infrastructure</li>
<li>Tests for every command implementation!</li>
<li>Better errors and Nix error bubbling</li>
<li><code>system</code>-level commands to control your Nix config!
<ul>
<li><code>generations</code>/<code>rollback</code>/<code>switch</code></li>
</ul>
</li>
<li>ISO create command (for an eventual KaiOS…?)</li>
<li><a href="https://github.com/getsops/sops">SOPS</a> secrets</li>
<li>backend-scoping and passthrough</li>
</ul>
<h2 id="refactoring-the-plugin-schema-again">Refactoring the plugin schema (again)<a href="#refactoring-the-plugin-schema-again" aria-label="Link to heading 'Refactoring the plugin schema (again)'" data-heading-content="Refactoring the plugin schema (again)" class="anchor"></a></h2>
<p>Kai is built via plugins similar to how <a href="https://caddyserver.com/">Caddy</a> works. The standard (and currently only useful) plugin, <code>std</code>, is compiled using <code>xkai</code>, which, like <a href="https://github.com/caddyserver/xcaddy"><code>xcaddy</code></a>, just bundles the <code>std</code> package together and provides a generic CLI skeleton around it. As noted in previous posts, getting this plugin structure right is crucial to Kai’s essential goals of being <em>generic</em>, <em>flexible</em>, and <em>modular</em>. The single biggest refactor is <a href="https://github.com/thebrandonlucas/kai/pull/86">changing the schema design</a> to more accurately reflect the separation between commands, blocks, and backend implementations.</p>
<h2 id="ergonomics">Ergonomics<a href="#ergonomics" aria-label="Link to heading 'Ergonomics'" data-heading-content="Ergonomics" class="anchor"></a></h2>
<p>Kai didn’t have much in the way of a help menu, and errors literally just spit out raw Roc constructs (gross!) which made them difficult for humans to read.</p>
<h3 id="help-menu">Help Menu<a href="#help-menu" aria-label="Link to heading 'Help Menu'" data-heading-content="Help Menu" class="anchor"></a></h3>
<p>Finally, a proper help menu!</p>
<pre><code class="language-sh">kai
A friendly frontend for determinate computing

Usage:
  kai [OPTIONS] &lt;COMMAND&gt; [ARGUMENTS] [--json]

Kai is a tool for providing a simplified interface on top of determinate
systems (mainly Nix) for ease of use. Commands often correspond with a
Kaifile block defining their behavior:

  $ kai shell
  $ cowsay &quot;Hello from Kai!&quot;

  # Kaifile
  shell {
      packages: [&quot;cowsay&quot;]
  }

Commands:
  build     Build an artifact declared in the Kaifile.
  deploy    Build and activate a machine on its declared target.
  image     Build an image from a machine declared in the Kaifile.
  iso       Build a bootable ISO from a machine declared in the Kaifile.
  machine   Build a machine declared in the Kaifile.
  run       Run a task declared in the Kaifile.
  service   Build a service declared in the Kaifile.
  shell     Enter an inline or declared developer environment.
  system    Manage machine-wide state.
  update    Update and lock project dependencies.
  workflow  Run a workflow declared in the Kaifile.
  version   Print version information.

Options:
  -f, --file &lt;PATH&gt;  Use the Kaifile at PATH
      --json         Output JSON Lines
      --no-color     Disable colored output
  -y, --yes          Assume yes for confirmation prompts.
  -h, --help         Print help

Environment:
  KAI_DIR             Project-local workspace directory (default: .kai)

More information: https://github.com/thebrandonlucas/kai
</code></pre>
<h4 id="cli-examples-on-each-help-menu">CLI examples on each help menu<a href="#cli-examples-on-each-help-menu" aria-label="Link to heading 'CLI examples on each help menu'" data-heading-content="CLI examples on each help menu" class="anchor"></a></h4>
<p>Each subcommand has a help menu with its equivalent <code>Kaifile</code> block example if applicable:</p>
<pre><code class="language-sh">kai help build
Build an artifact declared in the Kaifile.

Usage:
  kai [OPTIONS] build [BACKEND] &lt;ARTIFACT&gt; [--json]

Examples:
  kai build &lt;my-artifact&gt;

Kaifile block:
  build my-artifact {
    environment: dev
    run: [&quot;make&quot;]
    output: &quot;result&quot;
  }

Arguments:
  BACKEND  Optional backend name
  ARTIFACT  Artifact name from the Kaifile

Options:
  -f, --file &lt;PATH&gt;  Use the Kaifile at PATH
      --json         Output JSON Lines
  -y, --yes          Assume yes for confirmation prompts.
  -h, --help         Print help
</code></pre>
<h3 id="--json-outputs"><code>--json</code> Outputs<a href="#--json-outputs" aria-label="Link to heading '--json Outputs'" data-heading-content="--json Outputs" class="anchor"></a></h3>
<p><a href="https://clig.dev/#output">clig.dev</a> has a great entry on how you should design everything for humans <em>and</em> machines (so tools can be composable), so we have a <code>--json</code> flag that should work for each command:</p>
<pre><code class="language-sh">kai help build --json
{&quot;type&quot;:&quot;help&quot;,&quot;message&quot;:&quot;Build an artifact declared in the Kaifile.\n\nUsage:\n  kai [OPTIONS] build [BACKEND] &lt;ARTIFACT&gt; [--json]\n\nExamples:\n  kai build &lt;my-artifact&gt;\n\nKaifile block:\n  build my-artifact {\n    environment: dev\n    run: [\&quot;make\&quot;]\n    output: \&quot;result\&quot;\n  }\n\nArguments:\n  BACKEND  Optional backend name\n  ARTIFACT  Artifact name from the Kaifile\n\nOptions:\n  -f, --file &lt;PATH&gt;  Use the Kaifile at PATH\n      --json         Output JSON Lines\n  -y, --yes          Assume yes for confirmation prompts.\n  -h, --help         Print help&quot;}
</code></pre>
<p>I should probably add a <code>--pretty</code> flag or something for humans to be able to use the JSON version if they’d like, but we’ll wait and see if that use case gets justified.</p>
<h3 id="ansi">ANSI<a href="#ansi" aria-label="Link to heading 'ANSI'" data-heading-content="ANSI" class="anchor"></a></h3>
<p>We added ANSI coloring infrastructure. Just the very basics, <strong>bold</strong> for headers, red for errors, etc. The base is there and we can easily add/modify as needed.</p>
<h3 id="errors">Errors<a href="#errors" aria-label="Link to heading 'Errors'" data-heading-content="Errors" class="anchor"></a></h3>
<h4 id="kai-errors">Kai Errors<a href="#kai-errors" aria-label="Link to heading 'Kai Errors'" data-heading-content="Kai Errors" class="anchor"></a></h4>
<p>I think the correct philosophy around error message design is <a href="https://clig.dev/#errors">clig.dev’s</a>:</p>
<blockquote>
<p>One of the most common reasons to consult documentation is to fix errors. If you can make errors into documentation, then this will save the user loads of time.</p>
<p><strong>Catch errors and rewrite them for humans.</strong> If you’re expecting an error to happen, catch it and rewrite the error message to be useful. Think of it like a conversation, where the user has done something wrong and the program is guiding them in the right direction. Example: “Can’t write to file.txt. You might need to make it writable by running ‘chmod +w file.txt’.”</p>
<p><strong>Signal-to-noise ratio is crucial.</strong> The more irrelevant output you produce, the longer it’s going to take the user to figure out what they did wrong. If your program produces multiple errors of the same type, consider grouping them under a single explanatory header instead of printing many similar-looking lines.</p>
<p><strong>Consider where the user will look first.</strong> Put the most important information at the end of the output. The eye will be drawn to red text, so use it intentionally and sparingly.</p>
<p><strong>If there is an unexpected or unexplainable error, provide debug and traceback information, and instructions on how to submit a bug.</strong> That said, don’t forget about the signal-to-noise ratio: you don’t want to overwhelm the user with information they don’t understand. Consider writing the debug log to a file instead of printing it to the terminal.</p>
<p>Make it effortless to submit bug reports. One nice thing you can do is provide a URL and have it pre-populate as much information as possible.</p>
</blockquote>
<p>That last one wasn’t considered in this release, but I do love the idea and will add it in the future.</p>
<p>Now, errors that used to look like this:</p>
<pre><code class="language-text">Program exited with error: PlanningFailed({ backend: &quot;nix&quot;, command:
&quot;build&quot;, location: None, message: &quot;build requires exactly one config
name&quot;, plugin: &quot;std&quot; })
</code></pre>
<p>Now, in the new release, look like this:</p>
<pre><code class="language-text">error: build requires exactly one artifact argument
usage: kai build &lt;ARTIFACT&gt;
example: kai build &lt;my-artifact&gt;
</code></pre>
<p>Much better!</p>
<h4 id="nix-error-bubbling">Nix Error Bubbling<a href="#nix-error-bubbling" aria-label="Link to heading 'Nix Error Bubbling'" data-heading-content="Nix Error Bubbling" class="anchor"></a></h4>
<p>Since the <code>std</code> plugin in Kai sits on top of Nix, there will always be a subset of errors that Kai won’t be able to capture itself, since there can always be drift between how Kai mirrors the underlying implementation and we’ll never be able to have a perfect one-to-one error map. For example, if the user defines a package <code>foo</code> that is not in <code>nixpkgs</code>, Kai will presently still just write the <code>flake.nix</code> file and try to evaluate it under the hood, resulting in one of those ugly gargantuan Nix errors like:</p>
<pre><code class="language-text">error:
       … while calling the 'derivationStrict' builtin
         at «nix-internal»/derivation-internal.nix:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'nix-shell'

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'foo' missing
       at /nix/store/…-source/flake.nix:7:15:
            6|       packages = [
            7|               nixpkgs.&quot;legacyPackages&quot;.&quot;x86_64-linux&quot;.&quot;foo&quot;
             |               ^
            8|       ];
       Did you mean one of fio, fjo, folo, foot or fop?
</code></pre>
<p>This violates the rules above by showing so much information <em>internal to Nix</em> itself rather than the user’s code, where the violation actually lies. That should be up front and immediately obvious.</p>
<p>The real error is just this:</p>
<pre><code class="language-text">error: attribute 'foo' missing
at /nix/store/…-source/flake.nix:7:15:
    6|       packages = [
    7|               nixpkgs.&quot;legacyPackages&quot;.&quot;x86_64-linux&quot;.&quot;foo&quot;
     |               ^
    8|       ];
Did you mean one of fio, fjo, folo, foot or fop?
</code></pre>
<p>So we attempt to strip this out, but more work/experimentation will need to be done.</p>
<h2 id="features">Features<a href="#features" aria-label="Link to heading 'Features'" data-heading-content="Features" class="anchor"></a></h2>
<h3 id="import-blocks"><code>import</code> blocks<a href="#import-blocks" aria-label="Link to heading 'import blocks'" data-heading-content="import blocks" class="anchor"></a></h3>
<p><code>Kaifile</code>s can now import each other! This is not a whole module system like a programming language, but rather basically just string concatenation under the hood similar to <code>Caddy</code>. We really just needed a way for large <code>Kaifile</code>s to be expanded.</p>
<p><code>Kaifile</code> imports work like this:</p>
<pre><code class="language-Kaifile"># parts/environment.kai
environment dev {
  packages: [&quot;cowsay&quot;, &quot;fortune&quot;]
}
</code></pre>
<p>Then, <code>Kaifile</code>:</p>
<pre><code class="language-Kaifile">import &quot;parts/environment.kai&quot;
shell {
  environment: dev
}
</code></pre>
<h3 id="system-command-and-subcommand-groups"><code>system</code> Command and Subcommand Groups<a href="#system-command-and-subcommand-groups" aria-label="Link to heading 'system Command and Subcommand Groups'" data-heading-content="system Command and Subcommand Groups" class="anchor"></a></h3>
<p>Why should Kai only be used at the project level? What if you wanted to use it to configure your whole system like NixOS does? What if we could start working on combining the UX and flash of <a href="https://omarchy.org/">Omarchy</a> with the power of NixOS? The first step toward this is to group commands which do this under the <code>system</code> command (i.e. command which manipulate the system). This is the first command which has a few subcommands:</p>
<pre><code class="language-text">WARNING: These commands are experimental and can modify your system! Advised to use only on throwaway machines.
</code></pre>
<pre><code class="language-sh">kai system
Manage machine-wide state.

Usage:
  kai system &lt;COMMAND&gt;

Commands:
  generations  List local system generations.
  rollback     Roll back the current host one system generation.
  switch       Build and activate the declared machine.
</code></pre>
<p>One of the most powerful features of NixOS over other operating systems is the ability to rollback your machine’s state. Since most things in NixOS are declarative in a version-controlled file, this provides an enormous advantage over other operating systems which quickly become a tangled layered mess descending into dependency hell. Nix’s <code>rollback</code> allows you to switch between <code>generations</code> of your system’s state if anything goes wrong, or you just liked how one of your previous versions worked better. Paired with a solid UX, I expect this concept to unlock many novel use cases for people that aren’t fully utilizing their NixOS systems. At present, our <code>rollback</code> just goes back to the previous generation, the most useful command to recover from brokenness caused by an upgrade.</p>
<p>The other command added, <code>switch</code>, is what actually does the activation of your Nix derivations to change the state of the software. Under the hood this is <code>nixos-rebuild switch</code> and is probably the most essential and commonly used NixOS command.</p>
<h3 id="deploy">Deploy<a href="#deploy" aria-label="Link to heading 'Deploy'" data-heading-content="Deploy" class="anchor"></a></h3>
<p>Another big use-case unlock. If you have a machine in the cloud, it’s extremely convenient to be able to deploy a new config at will. I’ll be adding this to my personal websites — as soon as I can configure them completely using Kai on NixOS machines (more to come!):</p>
<pre><code class="language-sh">kai help deploy
Build and activate a machine on its declared target.

Usage:
  kai [OPTIONS] deploy [BACKEND] &lt;MACHINE&gt; [--json]

Examples:
  kai deploy &lt;machine&gt;
  kai deploy -y &lt;machine&gt;

Kaifile block:
  machine &lt;machine&gt; {
        environment: server
        system: &quot;x86_64-linux&quot;
        target: &quot;root@example.com&quot;
  }

Arguments:
  BACKEND  Optional backend name
  MACHINE  Machine name from the Kaifile

Options:
  -f, --file &lt;PATH&gt;  Use the Kaifile at PATH
      --json         Output JSON Lines
  -y, --yes          Assume yes for confirmation prompts.
  -h, --help         Print help
</code></pre>
<h3 id="iso">ISO<a href="#iso" aria-label="Link to heading 'ISO'" data-heading-content="ISO" class="anchor"></a></h3>
<blockquote>
<p><strong>WARNING! Experimental, please don’t use on any important machines yet.</strong></p>
</blockquote>
<p>Another path to an Omarchy-but-with-Kai is an ISO. With a valid machine config, you should be able to boot into a valid NixOS machine from a <code>Kaifile</code> with this ISO on a flash drive! Eventually, this’ll be spruced up to give a much better UX.</p>
<h3 id="sops-secrets">SOPS Secrets<a href="#sops-secrets" aria-label="Link to heading 'SOPS Secrets'" data-heading-content="SOPS Secrets" class="anchor"></a></h3>
<blockquote>
<p><strong>WARNING! Experimental, please don’t use on any important machines yet.</strong></p>
</blockquote>
<p>We added <a href="https://github.com/Mic92/sops-nix"><code>sops-nix</code></a>, a standard tool for safely integrating encrypted secrets in Nix/Git. This is a bit limited as at the moment <em>you</em> have to encrypt the secret — Kai only accepts already-SOPS encrypted secrets and doesn’t handle that itself. However, this unlocks being able to deploy machines with predefined secrets on them.</p>
<h3 id="backend-escape-hatch">Backend Escape Hatch<a href="#backend-escape-hatch" aria-label="Link to heading 'Backend Escape Hatch'" data-heading-content="Backend Escape Hatch" class="anchor"></a></h3>
<p>I wanted to allow the NixOS options assignments in flakes resulting from <code>Kaifile</code>s. This is a tricky problem because Nix has a <em>lot</em> of custom options keys for tons of services. Obviously Kai can’t re-hardcode all these. Further, there are some concepts which Kai is tying itself directly to Nix for, like overlays, which <a href="https://guix.gnu.org/">Guix</a> doesn’t have (though it does have analogous concepts).</p>
<p>At present, I’m unaware of a good way around the “non-overlapping concepts” problem for backends which should allow the Kai frontend to remain seamlessly usable. So the best approach I could find is to provide an escape hatch for these scenarios:</p>
<pre><code class="language-Kaifile">machine server {
 environment: server
 system: &quot;x86_64-linux&quot;
 users: [&quot;agent&quot;]
 services: [&quot;openssh&quot;]

 backend nix {
   networking.hostName: &quot;kai-server&quot;
   services.fail2ban.enable: true
   networking.firewall.allowedTCPPorts: [22, 443]
 }
}
</code></pre>
<p>Everything under <code>backend nix</code> is a restricted set of typed assignments that “lowers” Kaifile code into <code>flake.nix</code>. This is a big flexibility leap forward for Kai which will allow the base cases to remain separately abstracted from the bespoke code in the short term. Long-term, we’ll probably have to find something better.</p>
<h3 id="global-backend-config">Global Backend Config<a href="#global-backend-config" aria-label="Link to heading 'Global Backend Config'" data-heading-content="Global Backend Config" class="anchor"></a></h3>
<p>One repo I was attempting to add Kai to did not use the standard <code>nixpkgs</code> branch but rather <code>nixos-unstable-small</code>, a use case I hadn’t accounted for yet. While I’d ultimately like a large set of decisions like this to be configurable by the Kai binary, I think it’s also useful to have it available as a declarative config option. This is of course backend-specific, so we also scope this by its backend:</p>
<pre><code class="language-Kaifile">backend nix {
 packages: &quot;github:NixOS/nixpkgs/nixos-unstable-small&quot;
}
</code></pre>
<h3 id="scoped-architecture-predicates">Scoped Architecture Predicates<a href="#scoped-architecture-predicates" aria-label="Link to heading 'Scoped Architecture Predicates'" data-heading-content="Scoped Architecture Predicates" class="anchor"></a></h3>
<p>Similar to the above, this repo also required architecture-specific config. We already had <em>OS</em>-level config e.g.:</p>
<pre><code class="language-Kaifile">on linux {
    ..
}

on macos {
    ..
}
</code></pre>
<p>But this doesn’t provide the full host picture, as you also have architectural variation:</p>
<pre><code class="language-Kaifile">on linux x86_64 {
    ..
}

on macos aarch64 {
    ..
}
</code></pre>
<h2 id="future">Future<a href="#future" aria-label="Link to heading 'Future'" data-heading-content="Future" class="anchor"></a></h2>
<p>With all these features, Kai’s surface area is getting bigger. There are a growing number of commands that do very different things. <a href="https://en.wikipedia.org/wiki/Unix_philosophy">Unix Philosophy</a> says that tools should do one thing well. But the legendary Unix designers had an early-mover advantage in that they got to define much the set of tools that we use today, and therefore they didn’t have to operate as strictly <em>within</em> the set of available tooling. If Kai took the approach of splitting up every concern into sub-binaries, we would both have to ship a binary for every little tool <code>rollback</code>, <code>deploy</code>, <code>switch</code>, <code>generations</code> etc. <em>and</em> you’d have to know that each one of these things was Kai-specific. Nix does some of this with <code>nixos-rebuild</code> etc., but I think in the modern world we don’t want to have to redefine entire systems if we can get the majority of benefits without doing it. Swiss Army knives are closer to the mark for largely capable tools like this.</p>
<p>So I do think packaging things together with the plugin approach is the right one — different plugins can ship different sets of features: we could have a <code>kai-slim</code>, <code>kai-full</code>, one for project-level configs only, one for full OS management, one for Nix, one for Guix, etc.</p>
<p>That said, the plugin system is not being fully <em>utilized</em>: We are neither building out the Guix plugin system nor generalizing <code>std</code> to allow switching between Nix and Guix seamlessly.</p>
<p>I think this will be essential to avoid overfitting ourselves to Nix-only backends. While tempting in the short term, an agnostic design will pay huge dividends over time.</p>
<p>I’m also realizing that Nix can do <em>lots</em> of things and is very flexible. As such, people use it in a thousand different ways, which is something some love and others hate. This directly conflicts with the “one canonical way to do things” approach, which makes it far easier to create standards and form community (which, case in point, Nix really struggles with!).</p>
<p>This is an early canary — and one that we’ll have to pay close attention to mitigating in the future.</p>
<p>Alan Kay’s pithy phrase remains evergreen in my head such that I’m tempted to make it the philosophical motto of the project:</p>
<blockquote>
<p>Simple things should be simple, complex things should be possible.</p>
<p>— <a href="https://www.quora.com/What-is-the-story-behind-Alan-Kay-s-adage-Simple-things-should-be-simple-complex-things-should-be-possible">Alan Kay</a></p>
</blockquote>
<p>Achieving both, though, ain’t easy!</p>
<p>But what great things worth doing ever were?</p>
<p>Onward!</p>
]]></content:encoded></item>
<item><title>Kai Devlog #5: Conceptual Integrity and Being a Better Programmer</title><link>https://blu.cx/posts/blog/2026-09-02-kai-devlog-5-conceptual-integrity-better-programmer/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-09-02-kai-devlog-5-conceptual-integrity-better-programmer/</guid><pubDate>Wed, 02 Sep 2026 12:00:00 +0000</pubDate><description>Building Kai for the long term through conceptual integrity, better tools, deliberate practice, and dogfooding.</description><content:encoded><![CDATA[<blockquote>
<p>In the beginning all you want are results, in the end all you want is control.</p>
<p><a href="https://www.youtube.com/@eskilsteenberg">Eskil Steenberg</a>, <a href="https://www.youtube.com/watch?v=443UNeGrFoM">How I Program in C</a></p>
</blockquote>
<!-- Keep adjacent quotations as separate blockquotes. -->
<blockquote>
<p>Life is long enough, and it has been given in sufficiently generous measure to allow the accomplishment of the very greatest things if the whole of it is well invested.</p>
<p>Seneca, <a href="https://standardebooks.org/ebooks/seneca/dialogues/aubrey-stewart"><em>On the Shortness of Life</em></a></p>
</blockquote>
<!-- Keep adjacent quotations as separate blockquotes. -->
<blockquote>
<p>Most European cathedrals show differences in plan or architectural style between parts built in different generations by different builders. The later builders were tempted to “improve” upon the designs of the earlier ones, to reflect both changes in fashion and differences in individual taste. So the peaceful Norman transept abuts and contradicts the soaring Gothic nave, and the result proclaims the pridefulness of the builders as much as the glory of God.
Against these, the architectural unity of Reims stands in glorious contrast. The joy that stirs the beholder comes as much from the integrity of the design as from any particular excellences. As the guidebook tells, this integrity was achieved by the self-abnegation of eight generations of builders, each of whom sacrificed some of his ideas so that the whole might be of pure design.
Even though they have not taken centuries to build, most programming systems reflect conceptual disunity far worse than that of cathedrals […] I will contend that conceptual integrity is <em>the</em> most important consideration in system design. It is better to have a system omit certain anomalous features and improvements, but to reflect one set of design ideas, than to have one that contains many good but independent and uncoordinated ideas.</p>
<p>Fred Brooks, <a href="https://en.wikipedia.org/wiki/The_Mythical_Man-Month"><em>The Mythical Man-Month</em></a></p>
</blockquote>
<p><img src="/images/blog/kai-devlog-5/reims-cathedral.jpg" alt="Reims Cathedral" /></p>
<p>This update might be a bit unusual, as I want to write an update but also some a little more personal about my experience of programming.</p>
<p>There are two things that are true of Kai that were never true of a programming project for me before:</p>
<ol>
<li>I’m building something from scratch as its progenitor, that</li>
<li>Is completely open source, that</li>
<li>I want to last a long time</li>
</ol>
<p>I’ve taken serious aim at all but (3) before, but the longer I live the more Karl Popper’s maxim of working on long-term problems speaks to me:</p>
<blockquote>
<p>I think that there is only one way to science - or to philosophy, for that matter: to meet a problem, to see its beauty and fall in love with it; to get married to it and to live with it happily, till death do ye part - unless you should meet another and even more fascinating problem or unless, indeed, you should obtain a solution. But even if you do obtain a solution, you may then discover, to your delight, the existence of a whole family of enchanting, though perhaps difficult, problem children, for whose welfare you may work, with a purpose, to the end of your days.</p>
<p>Karl Popper, <a href="https://www.routledge.com/Realism-and-the-Aim-of-Science-From-the-Postscript-to-The-Logic-of-Scientific-Discovery/BartleyIII-Popper/p/book/9780415084000">Realism and the Aim of Science</a></p>
</blockquote>
<p>By taking Kai <em>seriously</em>, by striving to make something that provides as close to a <em>strictly better</em> experience in using computers (to the extent achievable, there’s <a href="https://www.cgl.ucsf.edu/Outreach/pc204/NoSilverBullet.html"><em>No Silver Bullet</em></a>), I am forced to think harder than I ever have about <em>what</em> I’m building and <em>why</em>, the alignment between my highest-level end-goals and day to day tasks, how to make incremental progress every day which is aligned with these goals, how to maintain motivation, etc.</p>
<p>The genuine attempt to build something great is a forcing function for practices which lead to mastery.</p>
<p>As such, I’ve been doing a lot of reading (and more writing than I’ve ever done before!).</p>
<p>Sometimes I make mistakes or take some shortcuts of course. I think it can be very helpful to make something badly at first and just <em>get it out there</em>, share it, and get feedback from other really smart people in the community.</p>
<p>Kai is already starting to get <em>fun</em>, <em>real</em>, and <em>useful</em>, so I’m working to ensure it stays that way for a long time.</p>
<p>There’s been two releases since the <a href="/posts/blog/2026-08-17-kai-devlog-4-environment-task-build-workflow">last update</a>: <a href="https://github.com/thebrandonlucas/kai/releases/tag/v0.0.5">προιεναι - 0.0.5</a> (means “to proceed”) and <a href="https://github.com/thebrandonlucas/kai/releases/tag/v0.0.6">ετυγχανε - 0.0.6</a> (means “it happened”), and a lot of changes in them.</p>
<p>So many changes, where to start? Let’s just follow <a href="https://stephenking.com/works/nonfiction/on-writing-a-memoir-of-the-craft.html">Stephen King’s</a> advice for novels on this one, and just <em>skip the boring stuff</em>.</p>
<h2 id="external-features">External Features!<a href="#external-features" aria-label="Link to heading 'External Features!'" data-heading-content="External Features!" class="anchor"></a></h2>
<p>Let’s start with the fun stuff relevant to <em>you</em>, dear reader. Here are the new Kai commands added to the <code>StdPlugin</code> since the last update.</p>
<h3 id="source">Source<a href="#source" aria-label="Link to heading 'Source'" data-heading-content="Source" class="anchor"></a></h3>
<p>Not all things that a project needs are always in <code>nixpkgs</code>. Sometimes you need to declare an external link to a URL <code>tar</code> or something, as was the case for me with <code>aion</code> (also built in Roc), where I had to declare <code>bitcoin-qr</code> (a QR code NPM package I wrote for adding bitcoin payments to your site) URL as a source as this isn’t on <code>nixpkgs</code>. This is really useful and makes Kai far more flexible!</p>
<pre><code class="language-Kaifile">source bitcoin-qr {
  url: &quot;tarball+https://registry.npmjs.org/bitcoin-qr/-/bitcoin-qr-1.4.1.tgz&quot;
}

build aion {
  environment: cli
  source: &quot;src/aion.roc&quot;
  output: &quot;aion&quot;
}
</code></pre>
<h3 id="machine">Machine<a href="#machine" aria-label="Link to heading 'Machine'" data-heading-content="Machine" class="anchor"></a></h3>
<p>The <code>machine</code> block allows us to define full NixOS closures which we can then deploy or activate (for already-extant NixOS machines), which when combined with Kai can run services on startup or have particular packages installed.</p>
<p>Invoke with <code>kai machine &lt;name&gt;</code></p>
<pre><code class="language-Kaifile"># Build a typed NixOS deployment closure with `kai machine agent`.
environment server {
  packages: [&quot;curl&quot;]
}

machine &lt;name&gt; {
  environment: server
  system: &quot;x86_64-linux&quot;
  users: [&quot;&lt;name&gt;&quot;]
  services: [&quot;openssh&quot;]
}
</code></pre>
<h3 id="image">Image<a href="#image" aria-label="Link to heading 'Image'" data-heading-content="Image" class="anchor"></a></h3>
<p>That’s great, but what if we don’t already have a machine and want to create a <em>bootable</em> NixOS image? You can do that too via the <code>image</code> command! Which builds a generic QCOW2 image from a <code>machine</code> definition. For example, <code>kai image agent</code> turns the <code>agent</code> machine in your <code>Kaifile</code> into a portable image that a cloud provider can import.</p>
<p>I was able to test and verify this works on Digital Ocean via <code>aion</code> (below). The definition looks the same as machine, but it is invoked via <code>kai image &lt;name&gt;</code>:</p>
<pre><code class="language-Kaifile"># Build a generic QCOW2 image from the same machine definition.
environment server {
  packages: [&quot;curl&quot;]
}

machine &lt;name&gt; {
  environment: server
  system: &quot;x86_64-linux&quot;
  users: [&quot;&lt;name&gt;&quot;]
  services: [&quot;openssh&quot;]
}
</code></pre>
<h3 id="service">Service<a href="#service" aria-label="Link to heading 'Service'" data-heading-content="Service" class="anchor"></a></h3>
<p>Services are basically programs that run on startup and just continue running in the background. Caddy is a good example: You just want a web server that’s always on and routing requests to your sites. A crucial prerequisite if Kai is going to be useful in spinning up NixOS machines on desktop or in the cloud.</p>
<p>Example:</p>
<pre><code class="language-Kaifile"># A service turns an executable build artifact into a NixOS systemd service.
environment cow {
  packages: [&quot;cowsay&quot;]
}

build cow {
  environment: cow
  run: [&quot;sh&quot;, &quot;-c&quot;, &quot;cp \&quot;$(command -v cowsay)\&quot; cow&quot;]
  output: &quot;cow&quot;
}

service cow {
  artifact: &quot;cow&quot;
  secrets: []
  restart: on-failure
}
</code></pre>
<h3 id="secret">Secret<a href="#secret" aria-label="Link to heading 'Secret'" data-heading-content="Secret" class="anchor"></a></h3>
<p>A secret is basically an environment variable in either your shell, or machine, etc. This allows people to have the same machine but have behavior change based on the environment variables they set or have them set API keys or whatnot that allow them to use services. For example, I used <code>aion</code> to spin up a machine that ran <a href="https://pi.dev"><code>pi</code></a> coding agent connected to my <a href="https://ppq.ai">ppq.ai</a> API key. So in one command I could spin up a NixOS machine based on a <code>Kaifile</code> that had an agent running on it!</p>
<p>Example:</p>
<pre><code class="language-Kaifile">environment cow {
  packages: [&quot;cowsay&quot;]
}

# Build the &quot;cow&quot; program artifact
build cow {
  environment: cow
  run: [&quot;sh&quot;, &quot;-c&quot;, &quot;printf '#!%s\\ntest -s \&quot;$CREDENTIALS_DIRECTORY/message\&quot;\\nexec %s \&quot;secret loaded\&quot;\\n' \&quot;$(command -v sh)\&quot; \&quot;$(command -v cowsay)\&quot; &gt; cow &amp;&amp; chmod +x cow&quot;]
  output: &quot;cow&quot;
}

# Secret values stay outside the Kaifile. For this example, put
# &quot;classified moo&quot; in /run/kai/secrets/message on the machine.
secret message {
  provision: runtime
}

# Systemd passes the file to the service without exposing its contents.
service cow {
  artifact: &quot;cow&quot;
  secrets: [&quot;message&quot;]
  restart: on-failure
}
</code></pre>
<h2 id="internal-updates">Internal Updates<a href="#internal-updates" aria-label="Link to heading 'Internal Updates'" data-heading-content="Internal Updates" class="anchor"></a></h2>
<h2 id="plugin-overhaul-again">Plugin Overhaul (again)<a href="#plugin-overhaul-again" aria-label="Link to heading 'Plugin Overhaul (again)'" data-heading-content="Plugin Overhaul (again)" class="anchor"></a></h2>
<p>I once more redid the Plugin system, and it still isn’t quite where I want it to be. Getting this right is really important because it’s the gateway to others adding plugins for Kai to create their own plugins and features outside of <code>std</code>. I won’t yet go into the details because it isn’t <em>quite</em> there yet, but suffice to say that I’ve spent a lot of time making this much more self-documenting better abstracted. My goal is to get to the point where new users can “just dive in” making and experimenting with their own plugins.</p>
<h2 id="tidyroc">Tidy.roc<a href="#tidyroc" aria-label="Link to heading 'Tidy.roc'" data-heading-content="Tidy.roc" class="anchor"></a></h2>
<p><a href="https://matklad.github.io/">matklad</a> has a wonderful <a href="https://matklad.github.io/2025/12/06/mechanical-habits.html#Tidy-Script">article</a> on automating desired patterns of behavior for your codebase via a <a href="https://github.com/tigerbeetle/tigerbeetle/blob/main/src/tidy.zig">tidy</a> script they made at <a href="https://tigerbeetle.com/">TigerBeetle</a>. This is a really cool concept and one I wished I’d considered sooner. Basically, imagine you just wrote your own linter, not merely to enforce generic code style rules, but also to enforce <em>invariants</em> that you seek to ensure your custom rules are followed with every commit. This is essentially another additional layer of ensuring conceptual integrity for the project, for whatever invariants you care about.</p>
<p>I started simple in Kai, just adding a <code>Tidy.roc</code> which enforces:</p>
<ol>
<li>Every code module has a top-level explainer comment</li>
<li>Limit line length to 80 (some really long strings were getting hard to read)</li>
</ol>
<p>Tigerbeetle’s <code>tidy.zig</code> does so much more, of course, and some things I’d like to do, like ensuring large blobs don’t get committed (once they’re merged in that history, they’re hard to remove!).</p>
<p>But the real value is that I now have a script that I can edit to analyze my codebase on every commit and ensure nothing has violated a growing list specific list of invariants!</p>
<h2 id="guix-shell">Guix Shell<a href="#guix-shell" aria-label="Link to heading 'Guix Shell'" data-heading-content="Guix Shell" class="anchor"></a></h2>
<p><a href="https://en.wikipedia.org/wiki/The_Mythical_Man-Month"><em>The Mythical Man-Month</em></a> talks a lot about the importance of maintaining Conceptual Integrity in a program, and much of my research and thinking around Kai has evolved around this concept. Conceptual Integrity is the idea that your program should be <em>aligned</em> conceptually around what it’s supposed to be doing, and that this drifts as programs grow over time and abstractions get leakier.</p>
<p>One suggestion he has for maintaining conceptual integrity is having multiple implementations as a means to do ensure the design does what you want and is not too tied to your specific implementation. After all, one thing we’re trying to explore with Kai is the bounds of a <em>generic</em> determinate system – we need not and should not repeat Nix’s mistakes or tie ourselves too closely to their architectural mistakes.</p>
<p>So, just as a proof of concept for now that Kai will indeed work with two systems, I added just a single Guix shell command, which proved out that the <code>command</code>/<code>backend</code>/<code>implementation</code> architecture works for both Nix and Guix!</p>
<p>You can compile it with <code>nix run .#xkai -- build plugins/guix/GuixPlugin.roc</code>.</p>
<p>Then run <code>./kai shell guix</code>.</p>
<p>One day, I hope this flexibility will allow us to surgically replace problematic parts of Nix, in an incremental and backward compatible way, with our own implementation of a determinate system!</p>
<h2 id="fuzzer">Fuzzer<a href="#fuzzer" aria-label="Link to heading 'Fuzzer'" data-heading-content="Fuzzer" class="anchor"></a></h2>
<p>I’ve never fuzzed code before, and I’ll admit to ignorance on a lot of the theory and practice, especially with regards to practical benefit. But with <a href="https://github.com/lukewilliamboswell">Luke Boswell’s</a> new <a href="https://github.com/lukewilliamboswell/roc-fuzz">Roc fuzzer library</a>, and given that it was just a small bit of code surface to run for my parser (which fuzzers are apparently pretty good for), I decided to give it a try. Right now it’s only implemented for a portion of the parsing code, but it’s nice to know I have a way of easily and automatically testing thousands of inputs to the parser!</p>
<h2 id="dogfooding-kai">Dogfooding Kai<a href="#dogfooding-kai" aria-label="Link to heading 'Dogfooding Kai'" data-heading-content="Dogfooding Kai" class="anchor"></a></h2>
<p>So far I’ve created two in-progress greenfield projects with Kai with the robot friend. This has proven a lot of the use case for Kai. But I’ll also be adding it to extant projects like <a href="https://lyceum.quest/">lyceum.quest</a>, <a href="https://conllu.lyceum.quest/">conllu.lyceum.quest</a>, and this personal website, to prove that Kai can be used both for hosting and deployments, as well as developer environments and builds. Essentially, Kai should be able eventually to cover most common use cases for things that happen <em>around</em> the code, so that you can spend more time doing what you want to do – focus on the code itself.</p>
<h3 id="aion">Aion<a href="#aion" aria-label="Link to heading 'Aion'" data-heading-content="Aion" class="anchor"></a></h3>
<p>I built a <em>very</em> vibe coded (do not use yet!) tool to dogfood Kai with that I wanted for myself, a way for me to spin up NixOS servers on <a href="https://www.digitalocean.com/">DigitalOcean</a> at-will which spin up machines according to their Kai configuration. With this I was able, for example, to spin up an agent that “just works” and allows me to build things on that box with environment secret variables, services, packages, and just declarative computer setups in general, via just a single <code>Kaifile</code>!</p>
<p>This feels like a huge milestone, because one of the goals of Kai is to be able to augment/replace the traditional interface of using NixOS. If you can easily spin up simple to read declarative, version-controllable operating systems, it’s a massive game-changer for the headache of maintaining and remembering how you set up software environments. Your operating system setup becomes self-documenting, portable, shareable, trivially modifiable, trivially rollback-able, and now, because it’s not written in pure Nix, understandable!</p>
<p>The greater eventual ambition with this will be to allow people to use something like a <code>KaiOS</code> as a <em>desktop</em> as well, just like you can with NixOS. Then, maybe we can steal some of the Omarchy mindshare and prove to DHH that Nix-for-Desktop <em>can</em> be made easy ;)</p>
<p>There are a lot of knobs to think about before doing this in earnest, but we’ve already come a long way.</p>
<p>It’s completely open source and you can use it with your own Digital Ocean account (they’re one of the few that allow you to spin up custom NixOS servers).</p>
<h3 id="gump">Gump<a href="#gump" aria-label="Link to heading 'Gump'" data-heading-content="Gump" class="anchor"></a></h3>
<p>With <a href="https://github.blog/news-insights/company-news/addressing-githubs-recent-availability-issues/">all</a> <a href="https://github.blog/news-insights/company-news/an-update-on-github-availability/">the</a> <a href="https://github.blog/news-insights/company-news/github-availability-report-july-2026/">recent</a> <a href="https://blog.incidenthub.cloud/github-actions-pages-outage-aug-6-2026">problems</a> <a href="https://github.blog/news-insights/company-news/the-august-17-outage-and-the-work-ahead">with</a> <a href="https://www.theverge.com/news/757461/microsoft-github-thomas-dohmke-resignation-coreai-team-transition">Github</a> <a href="https://mitchellh.com/writing/ghostty-leaving-github">lately</a>, I figured I’d try my hand at a (again, <em>very vibecoded</em>) version-control system with a few twists.</p>
<p>I’m calling it <a href="https://github.com/thebrandonlucas/gump">Gump</a> (short for <code>git dump</code>!). The goals are:</p>
<ol>
<li>Self-hostable alternative to Github.</li>
<li>Allows for portable <em>projects</em>, not just portable <em>code</em>. i.e., issues, pull requests, wiki updates, etc. should all be concepts built into and portable and them selves version-controlled, like <a href="https://fossil-scm.org/">Fossil</a> but for decentralized work like <code>git</code>.</li>
<li>Treats <code>jj</code> concepts as first-class as opposed to <code>git</code>. Like Nix, most people who’ve spent the time to figure out <code>jj</code> seem to far prefer it as a major innovation over <code>git</code>. Plus, unlike Nix but very much like Kai, <code>jj</code> is completely backward compatible with <code>git</code> and your teammates don’t even need to know you’re using it.</li>
<li>Easy to use CLI, usable by agents with configurable permissions.</li>
</ol>
<p>The main goal, of course, is simply to work on Kai. It’s going to be extremely opinionated and bespoke to my wants, if I keep working on it at all. It’s going to do weird stuff like probably only use public key encryption for auth (the fact that most websites still do “check your inbox for an email code” is insane and backward). Or take <a href="https://matklad.github.io/">matklad’s</a> advice of <a href="https://matklad.github.io/2023/06/18/GitHub-merge-queue.html">queueing PR merges by default</a> instead of waiting for the merge button to be green, then reviewing, then clicking merge.</p>
<p>Who knows? Maybe this will even lead to building a <code>jj</code>-based generic <code>magit</code> style editing experience too. There’s so much to improve upon.</p>
<p>There are a lot of <a href="https://www.scattered-thoughts.net/writing/pain-we-forgot">problems we forgot</a> because we were all just using <code>git</code> and Github for so long that we forgot to question many basic assumptions.</p>
<p>There are of course a whole host of things Github does really well that would be extremely difficult to replicate, but it’s also been really bad lately and the coding world is waking up to the idea that maybe it was not-so-great idea to make all of open source code in the world dependent on a single company.</p>
<p>I don’t want to distract too much from Kai though, and if I actually start using/depending on this I’ll need to throw the slop code away and rebuild something proper from scratch, but Kai development comes first and foremost and I need to stay focused on the bigger goal, but still, this is a fun idea to pursue.</p>
<h2 id="bootstrapping-and-playing-with-kai">Bootstrapping and Playing with Kai<a href="#bootstrapping-and-playing-with-kai" aria-label="Link to heading 'Bootstrapping and Playing with Kai'" data-heading-content="Bootstrapping and Playing with Kai" class="anchor"></a></h2>
<p>You can try Kai without installing it by running <code>nix run github:thebrandonlucas/kai -- version</code>. That is how Aion and Gump keep their custom Kai plugins reproducible without requiring a global installation, while this package is not yet on <code>nixpkgs</code>.</p>
<h2 id="notes-and-learnings">Notes and Learnings<a href="#notes-and-learnings" aria-label="Link to heading 'Notes and Learnings'" data-heading-content="Notes and Learnings" class="anchor"></a></h2>
<h3 id="making-code-smaller">Making Code Smaller<a href="#making-code-smaller" aria-label="Link to heading 'Making Code Smaller'" data-heading-content="Making Code Smaller" class="anchor"></a></h3>
<p><a href="https://www.youtube.com/watch?v=JjDsP5n2kSM">Jonathan Blow</a> has a talk where he has an interesting section about how “deleting code is always a good thing”. I’m not sure I agree completely, but a common theme I’m noticing in all these investigations is that conceptual integrity, and an understanding of the entire system is paramount to maintaining good code.</p>
<p>One aspect of understanding things well is having less things to understand. Deleting code while keeping it readable is one way to do this. This also means deleting anything that feels superfluous, inessential, etc. It means careful abstraction when helpful, and no abstraction when not.</p>
<p>Lines of code I think can generally be a helpful metric for whether code is getting smaller but it’s not the full story. If your code is very DRY but opaque, the true workings of it buried under layers and layers of indirection, what was the point?</p>
<h2 id="testing-must-be-done-up-front">Testing Must Be Done Up Front<a href="#testing-must-be-done-up-front" aria-label="Link to heading 'Testing Must Be Done Up Front'" data-heading-content="Testing Must Be Done Up Front" class="anchor"></a></h2>
<p>SQLite creator <a href="https://www.sqlite.org/crew.html">Richard Hipp</a> says in his excellent <a href="https://www.youtube.com/watch?v=V_qzqY1bb7I">Software Should Work</a> talk that the secrets to making SQLite <em>probably</em> the most-used piece of software in the world are:</p>
<ol>
<li>Extreme portability. As Hipp says, “it’s just a file you can email to your friends!”</li>
<li>It just works. He primarily attributes this to an <em>extreme</em> approach to testing. In fact, there is far more test code in SQLite than code being tested!</li>
</ol>
<p>I will admit with some shame that I do not have any test yet other than a single integration test that doesn’t block CI. At first, I just blindly told the bot to add tests “in the style of <a href="https://matklad.github.io/2021/05/31/how-to-test.html">‘How to Test’</a>” which was silly and lazy and didn’t solve my essential problem: Helping to know <em>what</em> my code did (free documentation) and more importantly give me <em>confidence</em> that it worked.</p>
<p>The main reason I don’t have much testing is that I’m heavily debating and considering my strategy. <em>How to Test</em> says that tests should be cheap, operate at the <a href="https://www.destroyallsoftware.com/talks/boundaries">boundaries</a> of your interface, operate only on data (i.e. only do CPU work, no I/O), and therefore be <em>fast</em>, that they should be very easy to maintain (or else you won’t want to do them), and more.</p>
<p>That’s a lot of things to think about! Roc thankfully makes much of that easy by having a <code>!</code> marker to declare effect<em>ful</em> and effect<em>free</em> (pure) code, and so if you just trivially separate the code which performs effects from the code which just operates on pure data (same input always results in same output). This means if you just test the pure functions your tests will run fast. But I was finding that my tests were adding a lot of surface area, that I didn’t understand how they worked or what they were doing, and that they therefore didn’t give me much confidence and in fact hampered my understanding of the code.</p>
<p>So, in the meantime, I wrote a <code>zig build kaifiles</code> command which just runs all the Kaifiles in the <code>examples</code> folder end-to-end. I figured that since the examples demonstrate and run through basically all syntax using the simple <code>cowsay</code> program, having those work and actually seeing their output gives me a lot of confidence that at least the happy path is consistently working. I didn’t block <code>zig build ci</code> with these since they’re neither pure nor fast, which may be a mistake, and that has bitten me (while writing this, I realized the command failed because I hadn’t run it in awhile!), so I may change that despite it being effectful.</p>
<p>But a major next step for me is figuring out and working hard on the right fast test boundary so I can start building more confidence moving forward that Kai doesn’t have many bugs.</p>
<p>I should probably also add an invariant to <code>tidy.roc</code> to verify that every block of Kai’s <code>StdPlugin</code> <code>Kaifiles</code> are used. As we add new blocks, the examples won’t include them all automatically without some rule.</p>
<h2 id="dependency-cultures">Dependency Cultures<a href="#dependency-cultures" aria-label="Link to heading 'Dependency Cultures'" data-heading-content="Dependency Cultures" class="anchor"></a></h2>
<p><a href="https://github.com/rtfeldman">Richard Feldman’s</a> <a href="https://www.youtube.com/watch?v=E82ly38YEEQ"><em>Dependency Cultures</em></a> talk at <a href="https://softwareshould.work/">Software Should Work</a> really took me out of my Javascript bubble and got me asking deeper questions about what tools I should be using.</p>
<p>There are real downsides to the Tigerbeetle approach of manually maintaining <em>all</em> of your own tools and needing to understand <em>everything</em> about your program. I don’t have a great grasp of assembly or the theory of electricity and yet I can still write code to make computers do things. Tools and dependencies do exist for a reason.</p>
<p><em>But</em>.</p>
<p>There are two edges to this sword. If you take a short enough view, never having sought or gained a deeper understanding of how the things you use work, you’ll always be spending your time learning things which don’t last and are always changing.</p>
<p>The more time I’ve spent in the room with the creators of great things, they tend to have a deep understanding of the foundational structures of the tools they use and are building on, and as a result are much more versatile and capable. As new technologies slowly die in favor of newer technologies, they are less and less affected, because the deeper down into the foundations you go the less the knowledge you gained becomes irrelevant.</p>
<p>There’s a line between the practical utility of leveraging new technologies and the foundational stability of learning the old ones, and I think in tech by our very nature we’re drawn to the former more than we generally should be.</p>
<p>Often, if you think about the software you love the most that’s lasted the longest, it’s usually by people who spend a lot of time learning <em>deeply</em>.</p>
<h2 id="the-tools-youre-using-are-enough">The Tools You’re Using Are Enough<a href="#the-tools-youre-using-are-enough" aria-label="Link to heading 'The Tools You’re Using Are Enough'" data-heading-content="The Tools You’re Using Are Enough" class="anchor"></a></h2>
<p>Relatedly, one of matklad’s articles linked to a <a href="https://twitter.com/id_aa_carmack/status/989951283900514304">John Carmack</a> discussion about “just using the tools you already have”. Since this is being built in a language for which the compiler is being rebuilt, I run into a lot of bugs. So, because:</p>
<p>a) I’m excited to help in some small way contribute to this new language.
b) I want to use more reliable, fast tools (who doesn’t?) and Roc’s model fits my concerns well.
c) There’s less mental overhead and more conceptual integrity in using one tool for me.
d) It’s fun and I get to do a bunch of mini-projects in the language.
e) Not all code is equally important. The code that checks your code is less important than the code it’s checking, and I don’t need to anguish over every tiny detail.</p>
<h2 id="trunk-based-development">Trunk-based Development<a href="#trunk-based-development" aria-label="Link to heading 'Trunk-based Development'" data-heading-content="Trunk-based Development" class="anchor"></a></h2>
<p><a href="https://web.archive.org/web/20220517144332/https://ourmachinery.com/post/step-by-step-programming-incrementally/">This article</a> struck an idea in my mind that I can’t get out: every commit should add value to the codebase. This is <em>hard</em> to think about how to do properly, since features rarely lend themselves to single-commit completion! But there are tricks to do so for bigger features as noted in the article, and even in reviewing agent constructed code the idea of constantly merging things to <code>master</code> has been helping tremendously in avoiding not only cumbersome merge conflicts but just keeping the full program in my head, which is becoming more important as features keep getting added. The rapid development speed increases in adding more features provided by agents means that a lot of discipline is required to monitor them, reign them in, maintain control over what the code should actually be doing, and simplifying it. Agents have a huge bias in favor of bloat, and I’ve actually found it pretty hard to have them keep things <em>simple</em>, <em>small</em>, and <em>easy to understand</em>. Trunk-based development helps by reducing the number of concepts I’m having to keep up with at once.</p>
<h2 id="thoughts-on-commits">Thoughts on Commits<a href="#thoughts-on-commits" aria-label="Link to heading 'Thoughts on Commits'" data-heading-content="Thoughts on Commits" class="anchor"></a></h2>
<p>Different projects have different philosophies on what a commit is, it seems, which has consequences for how your repo history is written and what history you allow to be merged. Mitchell Hashimoto, for example, thinks 1 PR equals 1 commit. Therefore a commit is the mergeable, PRable unit of change. So, the process would be something like: work on your feature locally, adding WIP commits or whatever as you go, then, amending, rebasing, fixup’ing, etc. when you’re done into a single commit that you push and merge.</p>
<p><a href="https://mitchellh.com/writing/contributing-to-complex-projects">According</a> to Hashimoto, that final mergeable product should be +50/-50 ideally (easy to review, small incremental change) but no greater than +500/-500 (beyond that it starts getting difficult for a human to review).</p>
<p>Matklad has a looser <a href="https://matklad.github.io/2023/12/31/git-things.html">definition</a>, in that commit history can show the <em>progress</em> of how the final idea came to be. So a commit doesn’t need to necessarily be an isolated independent unit of work, the merge commit can be that, but it should tell a cohesive, easy to understand <em>story</em> about how you got there (and therefore you should still rebase/amend/fixup your WIP or exploration commits into something comprehensible by later review). He finds this useful as you can more easily trace the <em>why</em> and <em>how</em> for features and bugs when doing <code>git blame</code>, and if you have the merge commits, you already have the “final commit” at which that feature got merged.</p>
<p>I’ve been tending to favor Matklad’s approach on this, and trying to balance/reconcile that with <a href="https://web.archive.org/web/20220517144332/https://ourmachinery.com/post/step-by-step-programming-incrementally/">this article</a>’s trunk-based development approach where each commit can still provide independent value.</p>
<p>Also, I just started using <a href="https://jj-vcs.github.io/jj/latest/"><code>jj</code></a>, the new darling VCS of most who take the time to use it, it seems, and that also requires a huge rethinking of how to do all these things.</p>
<p>Regardless, I’m trying to pay much more attention now to the utility of the history.</p>
<h2 id="ai-use">AI Use<a href="#ai-use" aria-label="Link to heading 'AI Use'" data-heading-content="AI Use" class="anchor"></a></h2>
<h3 id="matklads-loop-closing-strategy">Matklad’s “Loop Closing” Strategy<a href="#matklads-loop-closing-strategy" aria-label="Link to heading 'Matklad’s “Loop Closing” Strategy'" data-heading-content="Matklad’s “Loop Closing” Strategy" class="anchor"></a></h3>
<p>Vibe coding has been both great and terrible for me. It’s difficult to find the right middle ground between having the robot do everything for you and doing everything yourself old-school. Obviously typing every <code>for</code> loop yourself should no longer be necessary. But I do think I should at least read every loop, and if I can’t understand the code (which I frequently can’t) that’s a red flag for me. This is becoming increasingly important and increasingly my bar: if I can’t understand the code as I read through it, it’s not good enough. This means that I either need to add comments (I plan on adding <em>many</em> more comments as part of cleaning up this codebase) or name variables something better, or either abstract more or even sometimes abstract less (abstracting can <a href="https://matklad.github.io/2020/08/15/concrete-abstraction.html">make internals unnecessarily opaque</a>).</p>
<p>But one strategy I’ve been trying that’s been working as a nice middle ground (though I still need a bit more discipline) is:</p>
<ol>
<li>Create a <code>.gitignore</code>’d directory called <code>plans</code>.</li>
<li>Inside <code>plans</code>, create a folder for <code>my-feature-plan</code> or <code>my-bug-fix</code>.</li>
<li>Inside <code>my-feature-plan</code>, create a <code>spec.md</code>.</li>
<li>Describe, in as much detail with as many real and specific examples you can of how you’d like the thing to work, the feature, fix, or refactor.</li>
<li>Tell the AI to create a <code>plan.md</code> which follows repository rules and splits the work into small, reviewable, independently value-adding chunks (Using <a href="https://mitchellh.com/writing/contributing-to-complex-projects">Mitchell Hashimoto’s</a> rule of +50/-50, no more than +500/-500 – a human (me!) has to read all the code after all!). Tell it to give examples of what it intends to do.</li>
<li>Review and refine that plan (I always find I underspecify and the AI didn’t get what I meant exactly).</li>
<li>Tell it “Do first chunk”, review that chunk, merge into <code>master</code>. Sometimes if I’ve got multiple things going I’ll be lazy and just have it do all the chunks at once but even with all the invariants, CI checks on every commit, and commit rules, I find this still bites me and I have to end up having it redo things. So I’m becoming more convinced that smaller chunks, each reviewed by a human before moving on, is still the way.</li>
</ol>
<h2 id="focus-motivation-mistakes">Focus, Motivation, Mistakes<a href="#focus-motivation-mistakes" aria-label="Link to heading 'Focus, Motivation, Mistakes'" data-heading-content="Focus, Motivation, Mistakes" class="anchor"></a></h2>
<p>Some final thoughts.</p>
<h3 id="focus-focus-focus">Focus Focus Focus!<a href="#focus-focus-focus" aria-label="Link to heading 'Focus Focus Focus!'" data-heading-content="Focus Focus Focus!" class="anchor"></a></h3>
<p>Focus is extremely important yet really hard. I have to play all sorts of tricks on myself because the internet as it stands is adversarial by default: that is, more helpful than harmful to my overall happiness and effectiveness unless I actively take steps to make it a positive. I shouldn’t have to <em>work</em> to make a computer a net positive for me (which is a big part of what I want Kai to help with). This universal constant in my life should be a net positive by default, or at least trivial to make it one.</p>
<h3 id="maintaining-motivation">Maintaining Motivation<a href="#maintaining-motivation" aria-label="Link to heading 'Maintaining Motivation'" data-heading-content="Maintaining Motivation" class="anchor"></a></h3>
<p>Read <a href="https://www.scattered-thoughts.net/writing/setting-goals">this</a> fantastic blog on programming and just a lot of good general life advice.</p>
<p>Sometimes, I’ll find that reading and re-reading my code with the purpose of refactoring just doesn’t sound fun. Or thinking about testing strategy or whatever. And then I don’t want to do it. And then I find myself trying to reach for Yet Another Side Project instead of just making the software I want most (Kai) great.</p>
<p>I’m trying to employ several tricks to get around this, such as:</p>
<ul>
<li>Work in smaller and smaller chunks</li>
<li>Walk away from the computer when tired and, if I still want to feel like I’m making progress, read a book on programming that would help (e.g. <em>The Mythical Man-Month</em> or <em>The Cathedral and the Bazaar</em>) read a blog article, or watch a talk.</li>
<li>Sharing! Writing blog posts takes a lot of effort, even relatively simple or sloppy, plain-English ones like this one. But even just slight positive feedback from real humans who would like to use this is uber-motivating. And, it helps me think through things at a high-level again and remind myself what I’m really trying to do and forces me to understand the system I built better.</li>
<li>Frequent releases (Mechanical Habits).</li>
<li>Working on automating <em>processes</em>. E.g. creating a release script which makes releasing as simple as <code>zig build release ...</code>.</li>
<li>Releasing frequently. Doing “the whole vertical” from top to bottom for every small change or small set of changes, that is, writing code, running it, testing it, releasing it, and writing about it, all frequently, makes the whole process run smoother and be less stressful. If you deploy every small change to prod every day, prod deploys accumulate less cruft, become muscle memory, and each one has a lower surface area for problems. <a href="http://www.catb.org/~esr/writings/cathedral-bazaar/cathedral-bazaar/">Many eyes make all bugs shallow</a> much faster in that case. Plus, it’s more exciting for both you and people who like your project!</li>
<li>Dogfood your project into another project. I can’t tell you how exciting it was to just say to an agent: “Build thing X. For anything that isn’t code itself, you are only allowed to use <code>kai</code>. No bash scripts, no <code>python</code> helpers, no <code>nix</code>. Just <code>kai</code>” and have it work! It’s a bit clunky, but in Aion and Gump, you really can do everything you need to do, from develop to deploy, using Kai!</li>
</ul>
<p>Some other great sources I’m borrowing from are:</p>
<ul>
<li><a href="https://matklad.github.io/2021/05/31/how-to-test.html">matklad’s How to Test</a></li>
<li><a href="https://mitchellh.com/">Mitchell Hashimoto</a></li>
</ul>
<h3 id="mistakes">Mistakes<a href="#mistakes" aria-label="Link to heading 'Mistakes'" data-heading-content="Mistakes" class="anchor"></a></h3>
<p>I’ve already found myself making a lot of mistakes with Kai:</p>
<ul>
<li>Overreliance on AI. It takes a lot of discipline to not just keep building and instead fixing what you already have and trying to make it great. That said, if I spend a whole year working on Kai in isolation, just to rip it apart and throw it away in favor of some new implementation when someone points out a completely better architecture, I won’t feel bad about not trying to achieve <em>perfection</em> on the first go before even sharing it.</li>
<li>Not reading code enough (<a href="https://www.teamten.com/lawrence/programming/dont-write-bugs.html">Don’t write bugs!</a>). And, as a result, having some of the internals of things like the parser or assembler remain a bit fuzzy in my brain.</li>
<li>Getting distracted. I think it was an overall positive to vibe code <a href="https://github.com/thebrandonlucas/aion">Aion</a> and <a href="https://github.com/thebrandonlucas/gump">Gump</a> (and vibing was <em>absolutely</em> the correct decision in their case – anything more would have meant spending an unjustifiable amount of time on two projects I may might 1. throw away or 2. distract from Kai too much).</li>
</ul>
]]></content:encoded></item>
<item><title>Kai Devlog #4: Environment, Task, Build, Workflow</title><link>https://blu.cx/posts/blog/2026-08-17-kai-devlog-4-environment-task-build-workflow/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-08-17-kai-devlog-4-environment-task-build-workflow/</guid><pubDate>Mon, 17 Aug 2026 12:00:00 +0000</pubDate><description>Expanding Kai with reusable environments, runnable tasks, composable workflows, portable builds, and overlays.</description><content:encoded><![CDATA[<p>This release of <code>kai</code> is all about new features!</p>
<p>A lot of upfront work went into ensuring modular design, especially so that new features could be added relatively cleanly under a contract that I liked. The abstractions aren’t perfect yet by any means, and it may still be a little confusing for a newcomer writing their own plugin. We’ll work more on that in some future release.</p>
<p>But I did feel it was good enough to finally build more of the features that would put <code>kai</code> to good use. That said, here are the features currently available in <code>kai</code>. These examples are all available in the latest code release:</p>
<p>As before, you could enter shells with certain programs:</p>
<pre><code class="language-Kaifile"># The simplest possible Kaifile.
#
# Run `kai shell` to enter this environment on Linux or macOS.
shell {
  packages: [&quot;cowsay&quot;, &quot;fortune&quot;]
}
</code></pre>
<p>But now we have a more generic <code>environment</code> builtin which can be used to describe the same package set across the other new keys. For example: you can now create <code>task</code>s and run them via <code>kai run &lt;task name&gt;</code></p>
<pre><code class="language-Kaifile"># Run `kai run moo` to make the cow say a pithy quote!
environment cow {
  packages: [&quot;cowsay&quot;, &quot;fortune&quot;]
}

task moo {
  environment: &quot;cow&quot;
  run: [&quot;sh&quot;, &quot;-c&quot;, &quot;fortune | cowsay&quot;]
}
</code></pre>
<p>Try running this with <code>kai run moo</code>!</p>
<p>You can also run <code>task</code>s together as part of a <code>workflow</code> (think CI). Run the below via <code>kai run cowvolution</code>:</p>
<pre><code class="language-Kaifile"># Workflows compose tasks and builds into one repeatable command.
# Run this one with `kai workflow cowvolution`.
environment cow {
  packages: [&quot;cowsay&quot;]
}

task normalcow {
  environment: &quot;cow&quot;
  run: [&quot;cowsay&quot;, &quot;moo&quot;]
}

task antiquitycow {
  environment: &quot;cow&quot;
  run: [&quot;cowsay&quot;, &quot;Non nobis solum nati sumus.&quot;]
}

task victoriancow {
  environment: &quot;cow&quot;
  run: [&quot;cowsay&quot;, &quot;doth mother know you weareth her drapes?&quot;]
}

workflow cowvolution {
  steps: [
    &quot;run normalcow&quot;,
    &quot;run antiquitycow&quot;,
    &quot;run victoriancow&quot;,
  ]
}
</code></pre>
<p>What if you want to package things together into a portably <code>build</code>-able derivation? You can! Here’s a little shell script which will combine <code>cowsay</code> and <code>fortune</code> to have the <code>fortune</code> piped into whatever <code>cowsay</code> has to say. Run via <code>kai build &lt;output-name&gt;</code> (in this case <code>wisecow</code>)</p>
<pre><code class="language-Kaifile"># You can build artifacts using the build command!
#
# This one combines `cowsay` and `fortune` to give you a
# `wisecow` binary.

environment cow {
  packages: [&quot;cowsay&quot;, &quot;fortune&quot;]
}

build wisecow {
  environment: cow
  run: [
    &quot;sh&quot;,
    &quot;-c&quot;,
    &quot;printf '#!%s\\n%s | %s\\n' \&quot;$(command -v sh)\&quot; \&quot;$(command -v fortune)\&quot; \&quot;$(command -v cowsay)\&quot; &gt; wisecow &amp;&amp; chmod +x wisecow&quot;
  ]
  output: &quot;wisecow&quot;
}
</code></pre>
<p>Finally, we have <code>overlay</code>s, to help people run things that may not be in <code>nixpkgs</code> (<code>kai</code> itself needs this ability)</p>
<pre><code class="language-Kaifile"># Overlays add packages that are not provided directly by nixpkgs.
shell {
  packages: [&quot;rocpkgs.nightly&quot;]
  overlays: [&quot;github:thebrandonlucas/roc-overlay&quot;]
}
</code></pre>
<p>That’s it for now! Stay tuned!</p>
]]></content:encoded></item>
<item><title>Kai Devlog #3: Custom DSL &amp; Plugin Modules</title><link>https://blu.cx/posts/blog/2026-08-11-kai-devlog-3-custom-dsl-plugin-modules/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-08-11-kai-devlog-3-custom-dsl-plugin-modules/</guid><pubDate>Tue, 11 Aug 2026 12:00:00 +0000</pubDate><description>Replacing Kai's embedded Roc config with a custom DSL and making plugin modules simpler, reusable, and validated.</description><content:encoded><![CDATA[<p>Something that is bred into <code>kai</code>‘s bones is the idea that if something is hard to use, it won’t be used unless it <em>must</em> be. In the last devlog we made <code>kai</code> modular in that you could build your own plugins, but there were several problems:</p>
<ul>
<li>You had to write custom parsing logic (terrible!)</li>
<li>They weren’t strict definitionally and the concept of a <code>Backend</code> was unclear and vague (does that just mean <code>nix</code>? What if there is more than one requirement?)</li>
<li>They were unvalidated. You could “do whatever you wanted” and received no help from <code>xkai</code> when you did something illogical</li>
<li>Plugin modules themselves were not modular/reusable/easy to make</li>
</ul>
<p>This release now updates that so the plugins should be much simpler to write, parsing is handled for you, a few validations are done by <code>xkai</code> to help ensure you built it right, and <code>Backend</code> was given a much stronger definition that represented the system much better.</p>
<p>Additionally, I made a custom DSL! Even though the previous <em>embedded</em> <code>roc</code> DSL was pretty thin, I realized I could make things much simpler if I made a custom one. The primary motivation to do it in an embedded language was to inherit things like conditional logic, but I really only needed it for switching between systems (e.g. <code>if system == linux then install ...</code>) and that alone did not justify the extra complexity. Plus, it would require every user to have both a determinate system installed like <code>nix</code> <em>and</em> the <code>roc</code> compiler. Instead, we remove that extra 30MB or so and the final <code>kai</code> binary comes out to about 600KB! This does come at the cost of a lot of gutsy config parsing and validation, which is annoying, but I think the tradeoff is worth it.</p>
<p>But the best part is now, the simplest <code>config.kai</code> (which I’ll soon rename <code>Kaifile</code>) looks like this:</p>
<pre><code class="language-Kaifile">shell {
    pkgs: [&quot;cowsay&quot;]
}
</code></pre>
<p>With just this, you’ll be able to define reproducible dev environments! For changing behavior on different systems:</p>
<pre><code class="language-Kaifile">on linux {
    shell {
        pkgs: [&quot;cowsay&quot;]
    }
}

on macos {
    shell {
        pkgs: [&quot;pokemonsay&quot;]
    }
}
</code></pre>
<p>Much simpler and straightforward than a <code>flake.nix</code>, that’s for sure!</p>
<p>Onward!</p>
]]></content:encoded></item>
<item><title>Kai Devlog #2: Modularity</title><link>https://blu.cx/posts/blog/2026-08-04-kai-devlog-2-modularity/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-08-04-kai-devlog-2-modularity/</guid><pubDate>Tue, 04 Aug 2026 12:00:00 +0000</pubDate><description>Building Kai around replaceable commands, extensible plugins, and custom determinate backends.</description><content:encoded><![CDATA[<p>Read any classic book about software, and you’ll find that it’s supposed to be modular. Why? Because modular software that does something useful is software that will <em>last</em>, roughly in proportion to:</p>
<ul>
<li>Its usefulness</li>
<li>Its modularity</li>
<li>Its evangelistic efforts</li>
<li>Its ease of use</li>
</ul>
<p>I believe this has become orders of magnitude more important in the Age of AI, as <em>code</em> (which was never the most expensive piece of the software development lifecycle anyway) has become incredibly cheap to produce. I also believe, perhaps controversially, that the principles of software development as established by its progenitors are <em>even more relevant</em>, with perhaps some tweaks and modifications.</p>
<p>A recurring theme, whether it be in such classics as the <a href="https://shop.elsevier.com/books/the-unix-philosophy/gancarz/978-0-08-094819-5">Unix Philosophy</a> or <a href="https://www.informit.com/store/mythical-man-month-essays-on-software-engineering-anniversary-9780201835953">The Mythical Man-Month</a> or <a href="https://www.oreilly.com/library/view/the-cathedral/0596001088/">The Cathedral and the Bazaar</a> or modern works like <a href="https://press.stripe.com/working-in-public">Working in Public</a>, is that good software should be modular. Think of the success of <a href="https://www.lego.com/en-us/history/articles/lego-system-in-play">LEGO</a>. A wonderful toy that embodies the spirit of open source software. LEGO’s have outlived many a toy because their design allows them endless reconfigurability and modifiability. If grandpa builds a castle from LEGO’s, then dad can add a dragon, and son, having slain it, can finally give the freed princess’ tower a long-overdue remodeling. This means that the efforts of the tower have not been lost, from grandpa to father to son, that there is a deeply human <em>history</em> and <em>personalization</em> to that tower.</p>
<p>Code works the same way. Linux is the undisputed king of infrastructure OS, and will probably overcome Windows and Apple: as the latter continue to get worse, piling on more and more new bloatware on already inferior foundations, their software will become more and more intractable to fix while the former continues to get more featureful, more useable, more battle-tested.</p>
<p>Thus, a modular approach will allow the code to be more flexible, interoperable, changeable, robust, and last much longer.</p>
<h2 id="making-kai-modular">Making Kai Modular<a href="#making-kai-modular" aria-label="Link to heading 'Making Kai Modular'" data-heading-content="Making Kai Modular" class="anchor"></a></h2>
<p>The three concerns for <code>kai</code> modularity outlined in previous articles are:</p>
<ul>
<li>Allowing replacement of any standard command with custom logic</li>
<li>Allowing commands to be added since we can’t anticipate every use case</li>
<li>Allowing piecemeal replacement of underlying <code>nix</code> or <code>guix</code> pain points (such as the famously slow <code>nix</code> evaluator) with custom interoperable solutions</li>
</ul>
<p>I modeled the design after <a href="https://caddyserver.com/"><code>caddy</code></a>, the best web server technology I’ve ever used, which has great defaults, is fantastically easy to use and configure, and is extremely <a href="https://caddyserver.com/docs/architecture">modular</a>.</p>
<p>I created a separate binary, called <code>xkai</code> (analagous to <code>caddy</code>’s <code>xcaddy</code>) which creates custom <code>kai</code> binaries which execute the behavior specified in a custom <code>Plugin.roc</code> file. For example, the “core library” of <code>kai</code> is <code>StdPlugin</code> which looks like this:</p>
<pre><code class="language-roc">import kai.Plugin as PluginApi

# The standard plugin is pure. kai.roc imports its typed configuration
# constructor; only the generic executor performs the resulting actions.
# TODO: it's explicitly limited to nix for now. This might be long-term
# desirable behavior, but we may want to consider providing guix support
# out of the box as a fallback. Or keep it as a separate Guix plugin/binary.
StdPlugin := [].{
    ShellConfig : { pkgs : List(Str) }

    nix : PluginApi.Backend
    nix = PluginApi.Backend.{ name: &quot;nix&quot; }

  # Only support the nix backend for now
    backends = [nix]

  # We have one command, shell, which just creates a nix dev shell
  # with a flake and enters it.
    shell_command : PluginApi.Command
    shell_command = PluginApi.Command.{
        argv: [],
        backends,
        name: &quot;shell&quot;,
    }

  # Whereas `shell` is a portable `Command` variable, `nix_shell`
  # is the actual implementation that tells the `kai` binary resulting
  # from `xkai build` on this plugin which side-effects to perform.
  #
  # Separating these two concepts is important - if we supported, say,
  # `guix shell`, then we could have one command in kai which would run
  # `guix shell` or `nix shell` depending on which system the user wanted
  # to use. So it's very flexible!
    nix_shell : PluginApi.Implementation
    nix_shell = PluginApi.Implementation.{
        actions: [
            WriteConfigUtf8({ path: &quot;.kai/flake.nix&quot; }),
            Exec({
                args: [&quot;develop&quot;, &quot;path:.kai#default&quot;],
                command: nix.name,
            }),
        ],
        backend: nix,
        command: shell_command,
        requirement: Program(nix.name),
    }

    shell : ShellConfig -&gt; {
        implementation : PluginApi.Implementation,
        rendered_config : Str,
    }
    shell = |shell_config| {
        implementation: nix_shell,
        rendered_config: StdPlugin.render_nix(
            shell_config.pkgs,
        ),
    }

  # Render the actual flake, which will be written to a managed
  # directory called `.kai`
    render_nix : List(Str) -&gt; Str
    render_nix = |pkgs| {
        package_lines = pkgs.map(
            |pkg| &quot;              nixpkgs.\&quot;legacyPackages\&quot;.\&quot;x86_64-linux\&quot;.\&quot;${pkg}\&quot;&quot;,
        )
        lines = [
            &quot;{&quot;,
            &quot;  inputs.nixpkgs.url = \&quot;github:NixOS/nixpkgs/nixos-unstable\&quot;;&quot;,
            &quot;  outputs = { nixpkgs, ... }: {&quot;,
            &quot;    devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {&quot;,
            &quot;      packages = [&quot;,
        ].concat(package_lines).concat([
            &quot;      ];&quot;,
            &quot;    };&quot;,
            &quot;  };&quot;,
            &quot;}&quot;,
        ])
        Str.join_with(lines, &quot;\n&quot;)
    }
}

# Plugins are pure, so we can do cheap, no I/O tests!
expect {
    module_config = StdPlugin.shell({ pkgs: [&quot;hello&quot;] })
    module_config.implementation == StdPlugin.nix_shell and
        module_config.rendered_config.contains(&quot;.\&quot;hello\&quot;&quot;)
}
</code></pre>
<p>This means that plugin creators need only write this plugin file, run <code>xkai build</code> on it, and they have their own custom <code>kai</code> binary! Which is, of course, how I will also be developing <code>kai</code>.</p>
<p>Thinking through this design has been by far the most difficult aspect of this project so far, and required a lot of research up front. But I am profoundly satisfied with this architecture.</p>
<p>Although <code>kai</code> is still very much a prototype which needs much better testing, interface, and of course, feature work, this is beginning to feel like a very solid and extensible foundation which will allow not just me, but <em>anyone</em>, to easily contribute meaningfully to this in the future.</p>
<p>Onward!</p>
]]></content:encoded></item>
<item><title>Kai Devlog #1: Boundaries</title><link>https://blu.cx/posts/blog/2026-07-28-kai-devlog-1-boundaries/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-07-28-kai-devlog-1-boundaries/</guid><pubDate>Tue, 28 Jul 2026 12:00:00 +0000</pubDate><description>Finding the right boundary between Kai's simple configuration and Nix's power.</description><content:encoded><![CDATA[<p>I’ve released a tiny prototype of <a href="https://github.com/thebrandonlucas/kai">Kai</a>. It has one useful command: <code>kai shell</code>. It does one thing: reads the contents of a <code>kai.roc</code> file, creates a <code>.kai/flake.nix</code> in the current directory, then calls <code>nix</code> under the hood to put you into a shell with the programs defined in the flake.</p>
<p>A <em>lot</em> of work went into doing that very basic thing that is a near-zero improvement over <code>nix</code> itself, because so much went into the underlying design that I’m hoping will make Kai a <a href="https://www.ebay.com/itm/254467919121?_skw=zero+to+one&amp;epid=167621430&amp;itmmeta=01KYK8B5T2R1700BNT92NH7B4W&amp;hash=item3b3f784d11:g:weYAAOSwbKJglu9o&amp;itmprp=enc%3AAQALAAAA0GfYFPkwiKCW4ZNSs2u11xDO%2BTPzFgfgppO%2BGxK2WxXD0LFr--%2BcpcQnEL22eIxi0ffSConw%2FSboIzOyd8hE4smQE70cDmIK8G78BzAURQbg9eZcUC7ZAdsCaPYikvzMLwRoHkuNnEivxx6Og4KrJKzsRTdRybMhlykiTo%2FC5ecL7v6rwXk2dkkApAy4lKvoYaddnkmabN3VKGjnAcrr1nlRSUSKrG3B64JejIarC4lbFgsUHquCv8rfbgYxEiA99DDGpvcjXIz718Bj03aFQag%3D%7Ctkp%3ABk9SR6DdrOj0Zw"><em>Zero to One</em></a> tool: an upgrade to the interface of deterministic computers so delectable and powerful that it will make the human experience, tooling interop, and agentic efficiency orders of magnitude better.</p>
<h2 id="finding-a-boundary">Finding a Boundary<a href="#finding-a-boundary" aria-label="Link to heading 'Finding a Boundary'" data-heading-content="Finding a Boundary" class="anchor"></a></h2>
<p>One of the main ideas behind Kai is for the user to manage a simple config file, <code>kai.roc</code>, which can serve as a simplified interface for interacting with your determinate system (for the vast majority, Nix under the hood). This is hard, because:</p>
<ul>
<li>A) Nix has so many layers of the stack, e.g.:
<ul>
<li>Nix the language, used by:</li>
<li>Nix the package manager, used by:</li>
<li>NixOS, along with:</li>
<li>The nixpkgs package repository</li>
</ul>
</li>
</ul>
<p>That’s a <em>lot</em> of layers interoperating in a “closed” way because:</p>
<ul>
<li>B) Nix built these monolithically, such that it’s <a href="https://tvl.fyi/blog/rewriting-nix">very hard</a> to take one piece of that stack and use it for anything useful outside of the broader ecosystem. This means two things:
<ul>
<li>Boundaries are difficult to isolate at the conceptual level (essential complexity baked into the Nix ecosystem).</li>
<li>Boundaries are difficult to isolate at the code level (accidental complexity due to years upon years of cruft, ad-hoc development, and no real competition leading to a lack of need for interop).</li>
</ul>
</li>
</ul>
<p>All of this together forms a natural walled garden: unlike Apple, which <em>intentionally</em> fights its users by hiding code for the sake of (Apple believes) reduced complexity and financial incentives, Nix seems to have created one by accident. While explicitly encoding preferences for open software (via, for example, needing to manually modify configs to set a flag <code>allowUnfree = true</code>) and a philosophy which advocates maximal user control over their systems, in practice it is so complex and abstruse for the average daily user, with so many layers, that anyone who wishes to improve upon or isolate a single piece faces a very effective barrier to general adoption because, in sum:</p>
<ul>
<li>A) Users can’t figure out how to use it, and:</li>
<li>B) Developers don’t have a middle ground between improving on the current ecosystem (thus adopting its current problems and working <em>backward</em> to solve a limited subset of things it can), or creating new systems (which, despite the profundity of the idea, is so difficult to do—see all the many layers above!—that only one has even tried: <a href="https://guix.gnu.org/">Guix</a>, and its community is very small).</li>
</ul>
<h2 id="enter-kai">Enter Kai<a href="#enter-kai" aria-label="Link to heading 'Enter Kai'" data-heading-content="Enter Kai" class="anchor"></a></h2>
<p>Kai proposes a middle way. Kai acknowledges two fundamental facts:</p>
<ol>
<li>Nix dominance</li>
<li>Nix “Accidental Complexity”</li>
</ol>
<p>Nix has the <a href="https://www.reddit.com/r/NixOS/comments/1n5dgpb/why_nixos_has_one_of_the_largest_repository_un/">largest package ecosystem</a> in the world. A stunning achievement for a package manager which isn’t the most well used, and an easy testament to the power of how reproducible software allows you to <em>ship</em>. Aside from that, it has seen slow increased adoption over the years despite continually fracturing communities and continuously deprecating APIs: even frontier LLMs get frequently confused about the best way to use Nix, because so much of the documentation teaches deprecated practices! Finally, there are no <em>real</em> competitors: imagine trying to build a <em>completely unique</em> package manager which uses a custom language and build a custom operating system from it while maintaining the largest package ecosystem on Earth, <em>without</em> being a for-profit company. Despite valid criticisms of Nix, this is a staggering achievement! One that is <em>extremely</em> difficult to replicate.</p>
<p>On the other hand, Nix suffers from so many problems which don’t need to exist. I sometimes wonder if its creator, <a href="https://edolstra.github.io/">Eelco Dolstra</a>, thought that some enterprisers would take his idea and carry it out to permanently improve the world by eliminating the whole class of <a href="https://edolstra.github.io/pubs/nspfssd-lisa2004-final.pdf">software deployment problems</a>, in the way that, say, Rust did for programmers. Maybe he, like Benjamin Franklin when he named the poles of electricity positive and negative, thought that someone would take his discovery and formalize it more appropriately and give them better names, whereas instead, we are just stuck with these terms, and we are still stuck with Franklin’s conceptual mistake of inverting the logical poles. And thus we are still stuck with many of the tradeoffs of Nix that are probably not worth having, despite the scope of the downstream improvements of using it over our current imperative systems being enormous and fundamental. Here we are over twenty years later, still building on top of inferior foundations. A huge portion of this I think is to be blamed on Nix’s design at basically every level.</p>
<p>Taking these into account, Kai proposes to do the following:</p>
<ol>
<li>Be backward compatible with Nix. Indeed, to simply <em>use</em> Nix directly under the hood at first.</li>
<li>Remove as much accidental complexity from using Nix as possible. Primarily through simplified UX and useful missing features or abstractions.</li>
</ol>
<p>Alan Kay’s motto is my North Star here: “Simple things should be simple; complex things should be possible.” That is, make Nix (via Kai) as easy as possible to use while allowing users to do anything they’d normally be able to do in Nix (even modify/create raw Nix files where they find they can’t do something in pure Kai).</p>
<p>This has resulted in me spending a lot of time seeking the appropriate <a href="https://www.destroyallsoftware.com/talks/boundaries">boundaries</a> to expose. After settling on <a href="https://roc-lang.org/">Roc</a> as the config language to use, I posted my idea on the <a href="https://roc.zulipchat.com/">Roc forum</a>, and to my amazement, Luke Boswell created a working prototype of my idea, <a href="https://github.com/lukewilliamboswell/roc-blueprint">roc-blueprint</a>, overnight!</p>
<p>This was great, as <code>roc-blueprint</code> provided an example of a general, pure, typed, and portable backend which could then be <em>lowered</em> into a compatible backend of choice (i.e. any reproducible system). In reality there are only two: Nix and Guix. Then this lowered Roc representation (itself another platform) could be used to instantiate and run actual respective commands. For example, here’s a program that provides a portable representation of a Nix shell which contains the <code>pokemonsay</code> program:</p>
<pre><code class="language-roc">app [main!] {
    pf: platform &quot;https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/download/1.0.0/AnZoxzoGPtSGQ15EQh6pBeeaHJ7aizP9MQhK81dES3Uq.tar.zst&quot;,
    blueprint: &quot;../../blueprint/package.roc&quot;,
}

import pf.Stdout
import blueprint.Blueprint
import blueprint.Requirement
import blueprint.Target
import blueprint.Environment
import blueprint.Nix

pokemonsay : Requirement
pokemonsay = Requirement.new({
    id: &quot;pokemonsay&quot;,
    display_name: &quot;Pokemonsay Program&quot;,
})

workspace : Blueprint.Draft
workspace = Blueprint.workspace({
    name: &quot;pokemonsay shell&quot;,
    target_systems: [Target.X86_64Linux],
    envs: [
        Environment.new({
            name: &quot;default&quot;,
            requirements: [pokemonsay],
        }),
    ],
})

nix_config : Nix.Config
nix_config = Nix.config({
    nixpkgs: Nix.github_input(
        &quot;nixpkgs&quot;,
        &quot;NixOS&quot;,
        &quot;nixpkgs&quot;,
        &quot;nixos-unstable&quot;,
    ),
    bindings: [
        Nix.bind(
            pokemonsay,
            &quot;nixpkgs&quot;,
            [&quot;pokemonsay&quot;],
        ),
    ],
})

main! : List(Str) =&gt; Try({}, _)
main! = |_args| {
    valid = Blueprint.validate(workspace) ? |errors| BlueprintInvalid(errors)
    source = Nix.render(valid, nix_config) ? |errors| NixInvalid(errors)
    Stdout.line!(source)?
    Ok({})
}
</code></pre>
<p>Cool! But notice any problems?</p>
<ol>
<li>Boilerplate-galore! The actual <code>flake.nix</code> this renders is fewer lines than the config! (21 vs. 54)</li>
</ol>
<pre><code class="language-nix"># Generated by roc-blueprint and roc-blueprint-nix. Do not edit.
{
  &quot;description&quot; = &quot;Development environments for pokemonsay shell&quot;;
  &quot;inputs&quot; = {
    &quot;nixpkgs&quot; = {
      &quot;url&quot; = &quot;github:NixOS/nixpkgs/nixos-unstable&quot;;
    };
  };
  &quot;outputs&quot; = { nixpkgs, ... }:
    {
      &quot;devShells&quot; = {
        &quot;x86_64-linux&quot; = {
          &quot;default&quot; = nixpkgs.&quot;legacyPackages&quot;.&quot;x86_64-linux&quot;.&quot;mkShell&quot; {
            &quot;packages&quot; = [
              nixpkgs.&quot;legacyPackages&quot;.&quot;x86_64-linux&quot;.&quot;pokemonsay&quot;
            ];
          };
        };
      };
    };
}
</code></pre>
<p>So the resulting config file is more complex than what it is simplifying, with this caveat: we define the portable (<code>blueprint</code> platform) and the non-portable (<code>blueprint_nix</code> platform) in the same file, the benefit being we can reuse <code>blueprint</code> programmatically and theoretically have it port to any number of determinate system protocols under the hood (eventually, one config could boil down to a Nix <em>or</em> Guix system). Another benefit is we get strong typing: unlike <code>flake.nix</code>, the individual pieces are strongly typed and thus linters and checkers could be built upon this to much greater effect. So these are some great benefits, the strong typing and portability alone we may even call <em>Zero to One</em> benefits, but we have only achieved goal (1) above:</p>
<blockquote>
<p>Be backward compatible with Nix. Indeed, to simply <em>use</em> Nix directly under the hood at first.</p>
</blockquote>
<p>But we’ve made (2) worse, adding complexity for arguably marginal gains for the average user:</p>
<blockquote>
<p>Remove as much accidental complexity from using Nix as possible. Primarily through simplified UX and useful missing features or abstractions.</p>
</blockquote>
<p>There are also other problems: for example the user must have a compatible <a href="https://roc-lang.org/">Roc</a> compiler installed, and they have to do <code>roc main.roc</code> to run it.</p>
<p>And even if we solve the above, this is an <em>incomplete</em> solution: the platform design is great, but must we really expect every user to just import this into their own programs, and write the logic to lower it?</p>
<p>I thought hard about what to do here, because the pros of this design are real, and I wanted to keep it for the time being as programmers might find this level of control useful, but for the vast majority of people a simpler config is in order. So I wrote one abstraction layer on top of it. Where the previous design looked like this:</p>
<pre><code>[portable blueprint] -&gt; [nix blueprint] -&gt; [nix files]
</code></pre>
<p>The current one adds:</p>
<pre><code>[kai.roc config] -&gt; [portable blueprint] -&gt; [nix blueprint] -&gt; [nix files]
</code></pre>
<p>The <code>kai.roc</code> sacrifices a bit more detail and control for simplicity and looks like this:</p>
<pre><code class="language-roc">app [config] {
    kai: platform &quot;../../platform/config.roc&quot;,
}

import kai.Kai

config : Kai.Config
config = {
    name: &quot;pokemonsay shell&quot;,
    shell: {
        pkgs: [&quot;pokemonsay&quot;],
    },
}
</code></pre>
<p>Much better! 13 total lines, and only 5 are config that the user needs to consider in the base case! But the idea is that the user will be able to move down and use the tool at any layer of abstraction as suits their needs. I’m not sure whether I’ll keep <code>roc-blueprint</code> at all yet, as the benefits of an intermediate representation between high-level abstraction and low-level control must be weighed against the need for maintenance simplicity, and I’m not sure yet of the value proposition when the simpler model exists.</p>
<p>To achieve this simplicity over <code>roc-blueprint</code>, we make some assumptions on:</p>
<ul>
<li>The distinction between a validated <code>blueprint</code> and a <code>Draft</code> workspace</li>
<li>The <code>Environment</code> concept</li>
<li>The machine architecture (we remove <code>Target.X86_64Linux</code> from above, for example)</li>
</ul>
<p>But I think many of these decisions can appropriately be outsourced to under-the-hood management by a CLI tool, which is the second part of the solution.</p>
<p>For example, we don’t have to encode the architecture in the config mandatorily if the CLI tool <code>kai</code> can just save those details in the config (or just default to building for all default/common systems).</p>
<p>Right now, the CLI can only do <code>kai shell</code>. It is dependent on your machine having Nix (and Nix is still hardcoded in) and most egregiously on being x86_64 Linux (sorry!), but this will be modularized away later.</p>
]]></content:encoded></item>
<item><title>Packaging Roc Nightlies with a Nix Flake and Overlay</title><link>https://blu.cx/posts/blog/2026-07-16-packaging-roc-nightlies/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2026-07-16-packaging-roc-nightlies/</guid><pubDate>Thu, 16 Jul 2026 12:00:00 +0000</pubDate><description>Packaging official Roc nightly compiler binaries reproducibly with a Nix flake and overlay.</description><content:encoded><![CDATA[<h2 id="packaging-roc-nightlies-with-a-nix-flake-and-overlay">Packaging Roc Nightlies with a Nix Flake and Overlay<a href="#packaging-roc-nightlies-with-a-nix-flake-and-overlay" aria-label="Link to heading 'Packaging Roc Nightlies with a Nix Flake and Overlay'" data-heading-content="Packaging Roc Nightlies with a Nix Flake and Overlay" class="anchor"></a></h2>
<p><a href="https://mitchellh.com/">Mitchell Hashimoto</a> built an excellent <a href="https://github.com/mitchellh/zig-overlay">Zig overlay flake</a> which allows you to get the nightly version of the Zig compiler with a single Nix command. At the time of this writing, Zig 0.16.0 is the latest stable release. Some projects intentionally track Zig’s rapidly changing development branch instead. <a href="https://codeberg.org/ziglings/exercises">Ziglings</a>, for example, currently requires a sufficiently recent 0.17.0 development build and does not compile with Zig <code>0.16.0</code>! Although Zig’s official binary can run on NixOS, integrating it reproducibly and ensuring host linking works correctly requires additional Nix setup. If <code>zig-overlay</code> didn’t exist, I’d have had to roll a custom solution just for myself. An overlay/flake is thus useful for any project not considered stable to allow anyone to have a reproducible/pinnable or just bleeding-edge environment for any version indexed by the overlay. It makes compatibility and environment setup orders of magnitude easier to achieve. No more hunting down binaries! (or hunting down and patching if you’re on NixOS).</p>
<p>The newer and more in flux the project, the more useful this is. And with the proven utility of the <code>zig-overlay</code> template, I decided to build one for an even newer programming language, <a href="https://roc-lang.org/">Roc</a>. At present, Roc releases <a href="https://github.com/roc-lang/nightlies/releases">nightly</a> binaries of the compiler. They are currently replacing the Rust compiler with a new scratch Zig rewrite, which has breaking changes to Roc’s design such that code and platforms targeting the old compiler are usually incompatible with the new compiler, and have not made a stable release of the Zig compiler <a href="https://github.com/roc-lang/roc/releases">release</a> yet. Thus, there’s a lot of incompatibility between apps which were built using the old and new Roc compilers, since the new compiler introduces a lot of backward-incompatible language features. So, being a nix enthusiast, I thought it would be helpful to create a <code>roc-overlay</code> modeled after <code>zig-overlay</code>, allowing tracked versions of the nightly compiler to be selected by a developer, or even better, declared as an input in <code>flake.nix</code> and pinned to an exact repository revision in <code>flake.lock</code> for given projects so the developer doesn’t even have to think about which nightly to use.</p>
<h3 id="roc-overlay-contents"><code>roc-overlay</code> Contents<a href="#roc-overlay-contents" aria-label="Link to heading 'roc-overlay Contents'" data-heading-content="roc-overlay Contents" class="anchor"></a></h3>
<p><a href="https://github.com/thebrandonlucas/roc-overlay"><code>roc-overlay</code></a> provides a Nix flake for the official Roc new-compiler binaries. It installs prebuilt archives and does not build from source. It mirrors <code>zig-overlay</code> in overall structure. Use it like this:</p>
<pre><code class="language-bash"># To get the latest nightly as seen by the repo,
# run one of these:

# Create a shell with the compiler.
nix shell github:thebrandonlucas/roc-overlay
roc version

# Run one-off commands directly from the flake.
nix run github:thebrandonlucas/roc-overlay -- version
</code></pre>
<p>Including the overlay in your <code>flake.nix</code>:</p>
<pre><code class="language-nix">   {
     inputs = {
       nixpkgs.url = &quot;github:NixOS/nixpkgs/nixos-unstable&quot;;
       roc-overlay.url = &quot;github:thebrandonlucas/roc-overlay&quot;;
     };

     outputs = { nixpkgs, roc-overlay, ... }:
       let
         system = &quot;x86_64-linux&quot;;
         pkgs = import nixpkgs {
           inherit system;
           overlays = [ roc-overlay.overlays.default ];
         };
       in
       {
         devShells.${system}.default = pkgs.mkShell {
           packages = [ pkgs.rocpkgs.nightly ];
         };
       };
   }
</code></pre>
<p>Hopefully you find this overlay useful. Please <a href="https://github.com/thebrandonlucas/roc-overlay/issues/new">open an issue</a> if you find anything that needs improvement.</p>
]]></content:encoded></item>
<item><title>Stack Programs Like Legos with Nix!</title><link>https://blu.cx/posts/blog/2025-11-21-nix-programs-as-legos/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-11-21-nix-programs-as-legos/</guid><pubDate>Fri, 21 Nov 2025 12:00:00 +0000</pubDate><description>Learn how to stitch programs together reprodicibly with Nix</description><content:encoded><![CDATA[<p>Nix was made to solve the <em>software deployment problem</em>, concisely defined by creator Eelco Dolstra thus:</p>
<blockquote>
<p>[The software deployment problem] is about getting computer programs from one machine to another—and having
them still work when they get there.</p>
<p>The Purely Functional Software Deployment Model, Eelco Dolstra</p>
</blockquote>
<p>Nix allows you to setup software on your computer in such a way that your setup is <em>reproducible</em>, meaning your setup on machine A can be <em>exactly</em> the same as your setup on machine B – as long as you have Nix.</p>
<p>To most people, learning Nix is a pain, due to the new concepts, sparse and outdated documentation, and community infighting.</p>
<p>But I think Nix can make using computers <em>fun</em> and <em>powerful</em> and <em>less painful</em>, once you learn how to handle its’ edges.</p>
<p>One fun way we can use Nix is to stitch together programs like Legos and have them interact with each other in a reproducible way. Let’s create an example!</p>
<p>First <a href="https://nixos.org/download/">install Nix</a> if you haven’t.</p>
<p>Say we have a fun little <code>bash</code> script like this:</p>
<pre><code class="language-sh">#!/usr/bin/env bash

# filename: pokefortune.sh

message=&quot;${1:-}&quot;
pokemon=&quot;${2:-slowking}&quot;

# Silence Perl locale warnings.
export LC_ALL=C

# Generate a fortune if user did not pass a message.
if [[ -z &quot;$message&quot; ]]; then
  message=$(fortune)
fi

echo &quot;$message&quot; | pokemonsay -p &quot;$pokemon&quot; -n
</code></pre>
<p>It optionally takes in a message and a <a href="https://pokemondb.net/pokedex/all">Pokédex</a> number, and prints out that Pokémon and message using the <code>pokemonsay</code> program. If either the message or the Pokemon aren’t specified, it uses a default Pokemon and the program <code>fortune</code> to generate the message.</p>
<p>Save this in a file <code>pokefortune.sh</code>, make it executable, then run it:</p>
<pre><code class="language-sh"># Make the bash script executable
chmod +x pokefortune.sh

./pokefortune.sh
</code></pre>
<p>If you’re like most people, you probably don’t have <code>pokemonsay</code> or <code>fortune</code> installed on your system, so you’ll likely see something like this:</p>
<pre><code class="language-sh">./pokefortune.sh: line 6: fortune: command not found
./pokefortune.sh: line 7: pokemonsay: command not found
</code></pre>
<p>Therefore this script, which works on my system because I have these programs installed, isn’t <em>reproducible</em> on your system. Let’s create a Nix <em>derivation</em> to make it so. Create a file called <code>pokefortune.nix</code> and copy the following:</p>
<pre><code class="language-nix"># filename: pokefortune.nix

{
  pkgs ? import (fetchTarball &quot;https://github.com/NixOS/nixpkgs/archive/nixos-24.05.tar.gz&quot;) { },
}:
pkgs.writeShellScriptBin &quot;pokefortune&quot; ''

message=&quot;''${1:-}&quot;
pokemon=&quot;''${2:-slowking}&quot;

# Silence Perl locale warnings.
export LC_ALL=C

# Generate a fortune if user did not pass a message.
if [[ -z &quot;$message&quot; ]]; then
  message=''$(${pkgs.fortune}/bin/fortune)
fi

echo $message | ${pkgs.pokemonsay}/bin/pokemonsay -p &quot;$pokemon&quot; -n
''
</code></pre>
<p>Now run:</p>
<pre><code class="language-sh">nix-build pokefortune.nix
</code></pre>
<p>This may take awhile, especially if this is your first time running Nix. Let’s look at the output:</p>
<pre><code class="language-sh">nix-build src/scripts/nix/pokefortune.nix
unpacking 'https://github.com/NixOS/nixpkgs/archive/nixos-24.05.tar.gz' into the Git cache...
this derivation will be built:
  /nix/store/vg4zmghqcnhjbs8kqhx04xixvm36d3ik-pokefortune.drv
these 9 paths will be fetched (2.65 MiB download, 26.91 MiB unpacked):
  /nix/store/0vdf5mpd762bw53rgl5nkmhvzq8n4m0d-file-5.45
  /nix/store/77cdqhqprqbciyhzsnzmsk7azbk2xv6r-fortune-mod-3.20.0
  /nix/store/d0i8idmbb4jji9ml01xsqgykrbvm7dss-gnu-config-2024-01-01
  /nix/store/0554jm1l1qw1pcfqsliw91hnifn11w8m-gnumake-4.4.1
  /nix/store/2wp235bg03gykpixd9v2nyxp08w8xq8a-patchelf-0.15.0
  /nix/store/c5x32idp600dklz9n25q38lk78j5vwxb-pokemonsay-1.0.0
  /nix/store/pba53n11na87fs4c20mp8yg4j7qx1by2-recode-3.7.14
  /nix/store/zix67r268ihi4c362zw7c0989z12jmy7-stdenv-linux
  /nix/store/2329271b42wh6b6yhl7jmjyi0cs4428b-update-autotools-gnu-config-scripts-hook
copying path '/nix/store/d0i8idmbb4jji9ml01xsqgykrbvm7dss-gnu-config-2024-01-01' from 'https://cache.nixos.org'...
copying path '/nix/store/c5x32idp600dklz9n25q38lk78j5vwxb-pokemonsay-1.0.0' from 'https://cache.nixos.org'...
copying path '/nix/store/0vdf5mpd762bw53rgl5nkmhvzq8n4m0d-file-5.45' from 'https://cache.nixos.org'...
copying path '/nix/store/0554jm1l1qw1pcfqsliw91hnifn11w8m-gnumake-4.4.1' from 'https://cache.nixos.org'...
copying path '/nix/store/2wp235bg03gykpixd9v2nyxp08w8xq8a-patchelf-0.15.0' from 'https://cache.nixos.org'...
copying path '/nix/store/pba53n11na87fs4c20mp8yg4j7qx1by2-recode-3.7.14' from 'https://cache.nixos.org'...
copying path '/nix/store/2329271b42wh6b6yhl7jmjyi0cs4428b-update-autotools-gnu-config-scripts-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/zix67r268ihi4c362zw7c0989z12jmy7-stdenv-linux' from 'https://cache.nixos.org'...
copying path '/nix/store/77cdqhqprqbciyhzsnzmsk7azbk2xv6r-fortune-mod-3.20.0' from 'https://cache.nixos.org'...
building '/nix/store/vg4zmghqcnhjbs8kqhx04xixvm36d3ik-pokefortune.drv'...
/nix/store/vsv2spw517cwq791fl3f8iymm6hshhyq-pokefortune
</code></pre>
<p>Nix fetched the packages we specified in our <code>.nix</code> file: <code>pokemonsay</code>, <code>fortune</code>, and some we didn’t specify: such as <code>file</code>, <code>patchelf</code>, and <code>recode</code>, which one or both of the other two packages depends on. Then it copied them locally, built a binary, and placed it at <code>/nix/store/vsv2spw517cwq791fl3f8iymm6hshhyq-pokefortune/bin</code>. We can confirm this by running it:</p>
<pre><code class="language-sh">/nix/store/vsv2spw517cwq791fl3f8iymm6hshhyq-pokefortune/bin
</code></pre>
<p>You should see something like this:</p>
<img src="/images/blog/nix-programs-as-legos/img_2_pokefortune.webp" alt="pokefortune result" width="800" height="1240" loading="lazy">
<p>To be reproducible, Nix ensures that it knows about every single dependency needed to create a package at all times. Because of that, you can do fun things like this:</p>
<pre><code class="language-sh"># Quickly enter a shell with the dependencies to create and display images.
nix-shell -p graphviz chafa

# Query the derivation's dependency graph, create a .png from it and display it:
    nix-store --query --graph $(nix-build pokefortune.nix) | \
    dot -Tpng -o pokefortune-dependency-graph.png &amp;&amp; chafa pokefortune-dependency-graph.png
</code></pre>
<p>Resulting in a view of every single dependency (the “closure”) that our <code>pokefortune</code> program requires:</p>
<!-- <div style="text-align: center;"> -->
<img src="/images/blog/nix-programs-as-legos/img_3_pokefortune_dependency_graph.webp" alt="pokefortune dependency graph" width="800" height="634" loading="lazy">
<!--   <img src="assets/introduction/intro_img_3_pokefortune_dependency_graph.png" alt="pokefortune result"  height="600"> -->
<!-- </div> -->
<p>How cool is that! We can see the whole dependency tree for anything packaged with Nix!</p>
<p>You have just done something very powerful with Nix: You’ve created a reproducible derivation that anyone who has the package manager installed on their system can use, which they couldn’t before.</p>
<p>This is just a taste of what Nix can do, but I hope that the potential is clear. As Farid Zakaria says in his blog post “Learn Nix the Fun Way”:</p>
<blockquote>
<p>Hopefully, seeing the fun things you can do with Nix might inspire you to push through the hard parts.</p>
<p>There is a golden pot 💰 at the end of this rainbow 🌈 awaiting you.</p>
<ul>
<li><a href="https://fzakaria.com/2024/07/05/learn-nix-the-fun-way">https://fzakaria.com/2024/07/05/learn-nix-the-fun-way</a></li>
</ul>
</blockquote>
<hr />
<p><em>This article is directly inspired by Farid Zakaria’s blog post <a href="https://fzakaria.com/2024/07/05/learn-nix-the-fun-way"><strong>Learn Nix the Fun Way</strong></a>. Check out his excellent blog <a href="https://fzakaria.com/">here</a>.</em></p>
<p><em>Special thanks to <a href="https://github.com/russweas">Russell Weas</a> and <a href="https://veracius.dev">veracius</a> for their input to this article and code</em></p>
<hr />
<p>References:</p>
<ul>
<li><a href="https://edolstra.github.io/pubs/phd-thesis.pdf">https://edolstra.github.io/pubs/phd-thesis.pdf</a></li>
<li><a href="https://web.archive.org/web/20171017151526/http://aptitude.alioth.debian.org/doc/en/pr01s02.html">https://web.archive.org/web/20171017151526/http://aptitude.alioth.debian.org/doc/en/pr01s02.html</a></li>
<li><a href="https://fzakaria.com/2024/07/05/learn-nix-the-fun-way">https://fzakaria.com/2024/07/05/learn-nix-the-fun-way</a></li>
<li><a href="https://zero-to-nix.com/start/nix-run/">https://zero-to-nix.com/start/nix-run/</a></li>
</ul>
]]></content:encoded></item>
<item><title>&lt;bitcoin-qr/&gt; - A Zero-Dependency Web Component for Stylish BIP-21 Payments</title><link>https://blu.cx/posts/blog/2025-02-21-bitcoin-qr/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-02-21-bitcoin-qr/</guid><pubDate>Fri, 21 Feb 2025 12:00:00 +0000</pubDate><description>A QR code web component for Bitcoin on-chain, Lightning, and unified BIP-21 payments</description><content:encoded><![CDATA[<span class="flex justify-center w-[100px]">
<img src="/images/blog/bitcoin-qr/qr.webp" alt="Bitcoin QR Example" width="594" height="596" loading="lazy">
</span>
<p>When developing a Bitcoin payment flow, there are multiple ways a user can expect to be able to pay. They might want to pay an on-chain address or Lightning invoice, they may be scanning a QR Code from their phone, copy/pasting from a wallet, or using a <a href="https://www.webln.guide/">WebLN</a> browser extension. Creating an intuitive interface that also captures all the possible ways a user can pay is one of the fundamental UX challenges of developing an application that can receive payments in Bitcoin.</p>
<p>This flexibility opens up many <a href="https://blu.cx/articles/bitcoin/micropayments">exciting use cases</a>, but often comes at the cost of being able to easily develop a smooth experience for the user. The greater the developer’s cognitive load, the more difficult it is to create intuitive UX.</p>
<p>This project aims to provide everything needed to allow standard Bitcoin &amp; Lightning Network payments out of the box. It handles creating the proper <a href="https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki">URIs</a> from just an address or invoice, and favors creating unified URIs whenever possible. Styles are highly customizable and images can be embedded. It also includes polling functionality – a callback can be passed as a property of the element to periodically check for payment.</p>
<p>Check it out on <a href="https://github.com/thebrandonlucas/bitcoin-qr">Github</a> and feel free to play around with the options and create your own <a href="https://bitcoin-qr.blu.cx">here</a>.</p>
<p>In addition, because it’s a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components">web component</a>, you should just be able to drop it into any framework and have it work, whether it’s pure HTML, Sveltekit, React, making it very versatile. Examples are included in the Github repo.</p>
<p>Here’s a quick demo of how to use it in Sveltekit:</p>
<p>Install:</p>
<pre><code class="language-sh">yarn add bitcoin-qr
</code></pre>
<p>Then:</p>
<pre><code class="language-svelte">&lt;script lang=&quot;ts&quot;&gt;
  import { defineCustomElements } from 'bitcoin-qr/loader';

  defineCustomElements();
&lt;/script&gt;

&lt;bitcoin-qr
 id=&quot;qr&quot;
 width=&quot;300&quot;
 height=&quot;300&quot;
 bitcoin=&quot;bc1p4mqqpxdyg3l0tvpv9xaesw5rsqv7fqpcn9ydawx3e8yr4enmc3qq7m59vd&quot;
 lightning=&quot;lno1zrxq8pjw7qjlm68mtp7e3yvxee4y5xrgjhhyf2fxhlphpckrvevh50u0q2a8y2qt9jeu3pj7p3u58rxs98yu93dxjlmy3eqp24qze09anfr6cqszm40686ujqq7t9jsjjf42tl2pryv3ds9f4hm6hysk7lvswdm70ntsqvlgc5nm4px6k3q2wmj4xun784sss2jn00q0w4dhydmln92wvash6jckffu0wmetwptj38f5g09k8pznuk4wq2df046yv0c5m3dakwgfz5ths2ymm3z6vnehvxj6urcarufa7uecwqqst9x4063hdpxq4frmupnsam9ahg&quot;
 parameters=&quot;amount=0.00001&amp;label=bitcoin-qr.blu.cx&amp;message=bitcoin-qr.blu.cx&quot;
 image=&quot;./assets/bitcoin.svg&quot;
 is-polling=&quot;false&quot;
 poll-interval=&quot;1000&quot;
 type=&quot;svg&quot;
 corners-square-color=&quot;#000000&quot;
 corners-dot-color=&quot;#000000&quot;
 corners-square-type=&quot;extra-rounded&quot;
 dots-type=&quot;classy-rounded&quot;
 dots-color=&quot;#000000&quot;
 debug=&quot;true&quot;
 poll-callback={callbackExample}
/&gt;
</code></pre>
<p>I built this about a year ago but didn’t post about it because there was more I wanted to do and test before putting it out there. But there’s always something else to do, isn’t there?</p>
<p>If you find any issues, feature requests, or suggestions for improvement, feel free to <a href="https://github.com/thebrandonlucas/bitcoin-qr/issues/new">create an issue</a> in Github.</p>
<p>Hope this saves you some time!</p>
]]></content:encoded></item>
<item><title>Automating Site Deployment for an `nb` -&gt; Github -&gt; VPS Setup</title><link>https://blu.cx/posts/blog/2025-02-13-automate-site-deploy/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-02-13-automate-site-deploy/</guid><pubDate>Thu, 13 Feb 2025 12:00:00 +0000</pubDate><description>As mentioned in the blog post on syncing my nb notebook across devices using Syncthing, I wanted a way to auto-publish to my site after finishing a piece of writing. What I ended up coming up with was…</description><content:encoded><![CDATA[<p>As mentioned in the blog post on <a href="../blog/syncthing-nb.md">syncing my <code>nb</code> notebook across devices using Syncthing</a>, I wanted a way to auto-publish to my site after finishing a piece of writing. What I ended up coming up with was having two notebooks: <em>draft</em> and <em>final</em>, which were structurally the same as the markdown folder in the actual website code. When done with a piece in <em>draft</em>, I <code>cp</code> it to the appropriate place in <code>final</code>, then run a bash syncing script which copies all files from <em>final</em> to the corresponding markdown folder in my Sveltekit website repo, <code>git commit</code>‘s the results, and pushes it to the remote repository. Here is the bash script I’m using, in case anyone else finds it useful. Note the environment variables which must be defined before running. It’s really just a directory copying + <code>git commit</code> script:</p>
<pre><code class="language-bash">#!/bin/bash

# Script to copy files from nb drafts to site code, then commit and push

# --- Check environment variables ---
if [ -z &quot;$SITE_GIT_REPO_DIR&quot; ]; then
  echo &quot;ERROR: SITE_GIT_REPO_DIR is not set.&quot;
  exit 1
fi
if [ -z &quot;$NB_FINAL_DRAFT_DIR&quot; ]; then
  echo &quot;ERROR: NB_FINAL_DRAFT_DIR is not set.&quot;
  exit 1
fi

if [ -z &quot;$NB_FINAL_DRAFT_IMAGES_DIR&quot; ]; then
  echo &quot;ERROR: NB_FINAL_DRAFT_IMAGES_DIR is not set.&quot;
  exit 1
fi

if [ -z &quot;$SITE_CODE_MD_DIR&quot; ]; then
  echo &quot;ERROR: SITE_CODE_MD_DIR is not set.&quot;
  exit 1
fi

if [ -z &quot;$SITE_CODE_MD_IMAGES_DIR&quot; ]; then
  echo &quot;ERROR: SITE_CODE_MD_IMAGES_DIR is not set.&quot;
  exit 1
fi

# --- Copy files ---

# Copy markdown files
echo &quot;Copying files from $NB_FINAL_DRAFT_DIR to $SITE_CODE_MD_DIR...&quot;
cp -r &quot;$NB_FINAL_DRAFT_DIR&quot;/* &quot;$SITE_CODE_MD_DIR&quot;/

# Check if the copy command was successful.
if [ $? -ne 0 ]; then
  echo &quot;ERROR: Failed to copy files from $NB_FINAL_DRAFT_DIR to $SITE_CODE_MD_DIR.&quot;
  exit 1
fi

# Copy image files
echo &quot;Copying files from $NB_FINAL_DRAFT_IMAGES_DIR to $SITE_CODE_MD_IMAGES_DIR...&quot;
cp -r &quot;$NB_FINAL_DRAFT_IMAGES_DIR&quot;/* &quot;$SITE_CODE_MD_IMAGES_DIR&quot;/

# Check if the copy command was successful.
if [ $? -ne 0 ]; then
  echo &quot;ERROR: Failed to copy files from $NB_FINAL_DRAFT_IMAGES_DIR to $SITE_CODE_MD_IMAGES_DIR.&quot;
  exit 1
fi

# --- Git Commit and Push ---

# Navigate to the Git repository directory
cd &quot;$SITE_GIT_REPO_DIR&quot;

# Check if it's a git repository
if [ ! -d &quot;.git&quot; ]; then
  echo &quot;ERROR: $SITE_GIT_REPO_DIR is not a git repository.&quot;
  exit 1
fi

# Add the changed files (only the md and images directories)
echo &quot;Adding files to git...&quot;
git add &quot;$SITE_CODE_MD_DIR&quot; &quot;$SITE_CODE_MD_IMAGES_DIR&quot;

# Check if there are any changes to commit
if ! git diff --cached --quiet --exit-code; then
  echo &quot;Committing changes to git...&quot;
  git commit -m &quot;Update content&quot;

  # Push the changes to the remote repository
  echo &quot;Pushing changes to remote origin...&quot;
  git push origin master

  # Check if the push command was successful.
  if [ $? -ne 0 ]; then
    echo &quot;ERROR: Failed to push changes to remote origin.&quot;
    exit 1
  fi

  echo &quot;Successfully updated remote repository.&quot;
else
  echo &quot;No changes to commit.&quot;
fi

echo &quot;Script completed.&quot;
exit 0

</code></pre>
<h2 id="automating-deployments-to-vps">Automating Deployments to VPS<a href="#automating-deployments-to-vps" aria-label="Link to heading 'Automating Deployments to VPS'" data-heading-content="Automating Deployments to VPS" class="anchor"></a></h2>
<p>I also wanted to automate deployments to the VPS I was using on every push. So essentially, my website would update every time the script ran. So I put this <code>deploy.yml</code> in <code>.github/workflows</code>:</p>
<pre><code class="language-yml">name: Deploy to VPS

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        run: npm install

      - name: Build SvelteKit app
        run: npm run build

      - name: Deploy to VPS
        uses: appleboy/scp-action@v0.1.7
        with:
          host: ${{ secrets.VPS_HOST }}
          username: ${{ secrets.VPS_USER }}
          password: ${{ secrets.VPS_PASSWORD }}
          source: &quot;build/*&quot;
          target: &quot;/var/www/blu&quot;
          rm: true
          strip_components: 1
</code></pre>
<p>Note that the <code>VPS_HOST</code>, <code>VPS_USER</code>, and <code>VPS_PASSWORD</code> must be defined repository/environment secrets in Github. Also note the action we’re using at the end to do the actual deploy, <code>appleboy/scp-action</code>. Two parameters were important for what I was trying to do. First, <code>rm: true</code>, which deletes the target folder (<code>/var/www/blu</code> in this case) before uploading the data. In the scenario where I delete or move a file in the new build, the old file would’ve remained present without that parameter set, which I didn’t want.</p>
<p>Second, the <code>strip_components: 1</code> is also important here. Without it, the <code>build</code> directory was getting placed inside <code>/var/www/blu</code>, instead of the <em>contents</em> of the build directory moving into <code>blu</code>. So <code>strip_components</code> specifies that while I want to use <code>build/*</code> as the <em>source</em> of my files, I only want <em>what’s in it</em>, i.e. <code>build/*</code>, so don’t put anything after the first slash (e.g. <code>build</code>) into <code>/var/www/blu</code>.</p>
<p>That’s it! Now every time I update the content of the site (such as with this post), I just copy it over to <em>final</em>, then run the sync script, and voila!</p>
]]></content:encoded></item>
<item><title>Hard Reset Asahi Linux After Boot Error and Data Backup</title><link>https://blu.cx/posts/blog/2025-02-12-asahi-boot-fix/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-02-12-asahi-boot-fix/</guid><pubDate>Wed, 12 Feb 2025 12:00:00 +0000</pubDate><description>dnf update may cause a boot into a black screen. Here's how you can reset your computer.</description><content:encoded><![CDATA[<p><a href="https://asahilinux.org/">Asahi Linux</a> is a port of Linux on Apple Silicon (the M-series chips).</p>
<p>I’ve been using it fairly happily for awhile, but it booted into a black screen recently. I had a flash drive plugged in and I had also installed new programs using <code>dnf</code> (The Fedora package manager, which is the distro Asahi uses), and after some reddit searching it appears that the problem was caused by something having to do with <code>dnf update</code>. After restarting the computer, it showed the Apple logo, Asahi logo, and Fedora logo in sequence as usual, and then never booted past a black screen. Unfortunately I wasn’t really able to “fix” it, but I was at least able to get into a terminal screen, mount a flash drive, backup my data, and then do a hard reset.</p>
<p>On boot, press and hold FN + CTRL + OPTION + F2. This should take you into a terminal-based login screen. Login with your normal user credentials. Then plugin a flash drive. Identify the device name by typing <code>lsblk</code>. It should appear as <code>/dev/sda</code> or something of the like. You should be able to identify it by its’ file size (e.g. 32GB, etc.). Then, mount the device. First, you should create a mount point using <code>mkdir</code>, such as in <code>/mnt</code>:</p>
<p>Create a mount point:</p>
<pre><code>sudo mkdir `/mnt/mydrive`
</code></pre>
<p>Mount the device:</p>
<pre><code>sudo mount /dev/sda /mnt/mydrive
</code></pre>
<p>Copy files from your <code>home</code> directory (or wherever you have data stored you want to keep) to the flashdrive:</p>
<pre><code>cp -r ~/* /mnt/mydrive
</code></pre>
<p>Unmount and eject the drive when done:</p>
<pre><code>sudo umount /mnt/mydrive
sudo eject /dev/sda
</code></pre>
<h3 id="repartition-the-hard-drive">Repartition the Hard Drive<a href="#repartition-the-hard-drive" aria-label="Link to heading 'Repartition the Hard Drive'" data-heading-content="Repartition the Hard Drive" class="anchor"></a></h3>
<p>Now, you’ll need to do a complete uninstall/reinstall of Asahi Linux by repartitioning the hard drive on your Mac.</p>
<p>I followed <a href="https://www.youtube.com/watch?v=nMnWTq2H-N0&amp;t=7s">this tutorial video</a> to help me repartition the Mac properly, and it worked like a charm. Then, I was able to go through the same process of reinstalling Asahi again and using my Apple Silicon machine with Linux.</p>
]]></content:encoded></item>
<item><title>File Synchronization For All Your Devices with Syncthing</title><link>https://blu.cx/posts/blog/2025-02-12-syncthing-nb/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-02-12-syncthing-nb/</guid><pubDate>Wed, 12 Feb 2025 12:00:00 +0000</pubDate><description>How to synchronize files across many devices automagically</description><content:encoded><![CDATA[<p>I use the <a href="https://en.wikipedia.org/wiki/Text-based_user_interface">TUI</a>-based tool <a href="https://github.com/xwmx/nb">nb</a> for writing things. But I have a few problems:</p>
<ol>
<li>I use it on a lot of different computers and often want to add to notes that only exist on computer A while I’m on computer B.</li>
<li>Since everything I write on my website is in Markdown, I want to have the ability to have what I place in that notebook automatically update the website (or at least update it after running some command)</li>
</ol>
<p>Solving Problem 1 will be the focus in this article. In a subsequent post, I plan to detail solving problem 2.</p>
<h2 id="requirements">Requirements<a href="#requirements" aria-label="Link to heading 'Requirements'" data-heading-content="Requirements" class="anchor"></a></h2>
<p>I want a system that <em>automatically</em> syncs files across devices that have it installed on and connected to at an interval I define when the machine comes online.</p>
<h2 id="syncthing">Syncthing<a href="#syncthing" aria-label="Link to heading 'Syncthing'" data-heading-content="Syncthing" class="anchor"></a></h2>
<p>After prompting <a href="https://www.perplexity.ai/">Perplexity.ai</a> about the issue, two methods which appealed to me are <a href="https://syncthing.net/">Syncthing</a> and Git. Using Git would’ve been more manual and time-consuming, and since Syncthing is a very popular tool and fully open source, I went with that option.</p>
<h2 id="installing">Installing<a href="#installing" aria-label="Link to heading 'Installing'" data-heading-content="Installing" class="anchor"></a></h2>
<p>Syncthing has a great <a href="https://docs.syncthing.net/intro/getting-started.html">“Getting Started”</a> page that gave me everything I needed to know to use it. Just download the app on two devices. Select the architecture you’re using from their releases page <a href="https://github.com/syncthing/syncthing/releases">here</a>. Follow their Getting Started page and you should have all the basics to get up and running.</p>
<h2 id="helpful-notes">Helpful Notes<a href="#helpful-notes" aria-label="Link to heading 'Helpful Notes'" data-heading-content="Helpful Notes" class="anchor"></a></h2>
<h3 id="use-cases">Use Cases<a href="#use-cases" aria-label="Link to heading 'Use Cases'" data-heading-content="Use Cases" class="anchor"></a></h3>
<p>Syncthing is not really meant to be a backup software like <a href="https://linux.die.net/man/1/rsync">rsync</a>, because changes made on one machine will synchronize to the other machines, and therefore if one machine deletes a file it will also be deleted on the other machine. It’s meant to be a <em>sharing</em> software keep documents on different computers synchronized, as the name suggests. Which means that it should really be used for things like media libraries or as an alternative to cloud storage solutions like Box or Google Drive, or when needing to edit documents on multiple machines, as in my case with <code>nb</code>.</p>
<h3 id="mobile-devices">Mobile Devices<a href="#mobile-devices" aria-label="Link to heading 'Mobile Devices'" data-heading-content="Mobile Devices" class="anchor"></a></h3>
<p>I wanted one of my devices to be my phone, so just note that for mobile (i.e. by mobile I mean <em>Android</em> or a security-hardened derivative like <a href="https://grapheneos.org/">GrapheneOS</a> — sorry iPhone fans, but their anti open source ethos precludes you from using this one) you have to use a <a href="https://github.com/Catfriend1/syncthing-android">fork</a> of their <a href="https://github.com/syncthing/syncthing-android">now deprecated Android app</a>. You can download the apk file <a href="https://github.com/Catfriend1/syncthing-android/releases">here</a>.</p>
<h3 id="folder-types">Folder Types<a href="#folder-types" aria-label="Link to heading 'Folder Types'" data-heading-content="Folder Types" class="anchor"></a></h3>
<p>There are <a href="https://docs.syncthing.net/users/foldertypes.html">three types</a> of folders:</p>
<ul>
<li>Send Only</li>
<li>Receive Only</li>
<li>Send and Receive</li>
</ul>
<p>This is useful for sharing files while still setting some basic permissions for them. Send Only is great for sharing with people/devices that you don’t want to be able to modify your local copy via their modifications; Receive Only is the opposite — it can only <em>be shared with</em>, and yet changes from the sending folder will not modify changes in the receiving folder.</p>
<h3 id="the-faq-is-very-helpful">The FAQ is Very Helpful<a href="#the-faq-is-very-helpful" aria-label="Link to heading 'The FAQ is Very Helpful'" data-heading-content="The FAQ is Very Helpful" class="anchor"></a></h3>
<p>Initially when using Syncthing I was confused about a few things (Should I use this for backups? Why does syncing take so long? How does it work? Will it ever connect to anything other than my own machines and can they see my data?). The <a href="https://docs.syncthing.net/users/faq.html#what-is-syncthing">FAQ</a> answered all my questions very nicely and in detail, so be sure to give that a read.</p>
<h3 id="note-for-obsidian-users">Note For Obsidian Users<a href="#note-for-obsidian-users" aria-label="Link to heading 'Note For Obsidian Users'" data-heading-content="Note For Obsidian Users" class="anchor"></a></h3>
<p><a href="https://obsidian.md/">Obsidian</a> is an (unfortunately closed-source) note-taking app that pairs nicely with <code>nb</code>. I use <code>nb</code> on all my desk/laptop machines and use Obsidian on mobile since trying to use a terminal on mobile would be a terrible experience. After installing Syncthing-Fork on your mobile device and syncing the relevant folder, you can open that folder as your Vault in Obsidian. Before making any changes in Obsidian, however, you should disable a setting in Syncthing. Click on the synced folder, scroll down to “Watch for changes”, and disable it. This will make it so changes to that synced directory will only attempt to sync changes to the others on an hourly basis. Obsidian saves files to disk extremely frequently, basically on every keystroke, and this caused Syncthing to behave strangely or simply not sync any changes made from Obsidian to the other devices. This is a bit unfortunate because there’s a possibility that you could update the same file on your mobile device and another machine within that hour, causing a conflict. But fortunately Syncthing will save both versions of the file in a “conflict” file and you will have both versions so that there’s no content loss.</p>
]]></content:encoded></item>
<item><title>Toward A Better Site</title><link>https://blu.cx/posts/blog/2025-01-29-blog-revamped/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2025-01-29-blog-revamped/</guid><pubDate>Wed, 29 Jan 2025 12:00:00 +0000</pubDate><description>A more thoughtful approach to personal site development</description><content:encoded><![CDATA[<blockquote>
<p>We shall not cease from exploration<br />
And the end of all our exploring<br />
Will be to arrive where we started<br />
And know the place for the first time.</p>
</blockquote>
<ul>
<li><a href="https://www.columbia.edu/itc/history/winter/w3206/edit/tseliotlittlegidding.html">T.S. Eliot, from “Little Gidding,” Four Quartets. Originally published 1943.</a></li>
</ul>
<p>This past year, I’ve experimented with several different methods of creating and managing a personal website. I didn’t merely want the most convenient solution, or the solution most likely to buy popularity more easily via its platform or network effects. I wanted a solution that was in line with:</p>
<ul>
<li>
<ol>
<li>A growing set of principles I want to practice see more of in software I use and create.</li>
</ol>
</li>
<li>
<ol start="2">
<li>A set of very unique and specific features I desired.</li>
</ol>
</li>
</ul>
<p>The pursuit of principles and features, of course, give way to the brutal constraints of reality to some degree. I don’t have infinite time. And so the desire to obtain the features I want while maintaining those principles must be balanced with the constraints of time and effort. After experimenting with several iterations of website-building, I have in many ways “arrived where I started”, but now feel more confident, more sure-footed, more “aligned”, and more excited about what even a simple little personal website could be.</p>
<h3 id="first-site--a-diy-compromise">First Site — A DIY Compromise<a href="#first-site--a-diy-compromise" aria-label="Link to heading 'First Site — A DIY Compromise'" data-heading-content="First Site — A DIY Compromise" class="anchor"></a></h3>
<p>I started out as most Gen-Z developers start, I think. You want to be a developer, you need a portfolio. You want to be a <em>web developer</em>? Your portfolio is your website. And so my first website was just that. I built it during many skipped classes in college, while I was still painstakingly and inefficiently learning HTML, CSS, and Javascript. It was designed to be artsy and beautiful and to get me a job as a web developer. And so I didn’t post or write about anything, just listed what I felt would be most impressive to recruiters. But, after proving to yourself that you can indeed get a job and you can indeed make enough to pay your rent and not be a broke college kid forever, you start to realize there’s more important things in life than just trying to impress recruiters. You realize that a personal website can be so much more. It can be a <em>reflection of yourself</em>.</p>
<p>And so, with that in mind, I built my first “real” attempt at a personal site. I built it in <a href="https://svelte.dev/">Sveltekit</a> (which was in unstable version 3 at the time), used the <a href="https://github.com/pngwn/MDsveX">MDSveX</a> library so I could write my articles in <a href="https://en.wikipedia.org/wiki/Markdown">Markdown</a>. This was a proper blogging site that also listed projects and “About Me” and “Contact” and whatnot, however there were several problems:</p>
<ul>
<li><strong>Hosting</strong>: It was hosted on Netlify, which meant that there were often cold starts when visiting it. This also meant that I wasn’t hosting the site myself, which wasn’t a big deal to me at the time, but developed into one over the course of the year.</li>
<li><strong>Features</strong>: The site was low on features and bells and whistles, but this was mainly because I just didn’t take the time to implement them. The fact that everything was written in Sveltekit meant that I could have, but I wasn’t taking the time to really think about what I wanted implemented and then come up with a good plan to do it.</li>
<li><strong>Preprocessing the Markdown</strong>: I didn’t quite understand how to set up the preprocessor in MDSveX properly, which does the job of converting the Markdown to HTML when building the site. What I <em>think</em> was happening was this resulted in pages having to convert the Markdown to HTML on the fly during runtime, and so the bigger the article, the slower the page load, but I never truly investigating this since I decided to redo the website from the ground up anyway. To the end user, this just felt like the page was frozen for awhile, which was really annoying UX.</li>
<li><strong>Content and Organization</strong>: I wasn’t sure of how I wanted things organized, and I only had a few articles, blogs, and quotes on there. The way I would write my content was by writing the article in Markdown directly on the site and then just committing and pushing the code to Github, and from there it would build and deploy to Netlify automagically. That was nice, but I would prefer to be able to write the article in another program (so that I could have “draft” versions of it and whatnot) and then just commit + push when ready in a single command/click sort of way.</li>
</ul>
<p>All these problems contributed to a year of experimentation that left my actual ability to write things a bit in limbo.</p>
<h3 id="substack">Substack<a href="#substack" aria-label="Link to heading 'Substack'" data-heading-content="Substack" class="anchor"></a></h3>
<p>I started out by just wanting something that worked, and worked well, for <em>writing</em>, without having to worry about anything else. Substack is the obvious choice for this. It’s famously anti-censorship, has an intuitive UI, a large audience, most of my own subscriptions worth reading are from Substack, easy subscription tiers and connection to Stripe for payments, easy email subscriptions. What’s not to like?</p>
<p>There was one thing that just ended up being a deal breaker for me. Probably a bizarre requirement to most people, but I just couldn’t in good conscience do it. At the time, I was considering requiring subscriptions and payments for some of the articles I wrote, and on Substack, there’s <em>no option for bitcoin payments</em>. The saddest thing of all is, it appears that there <em>was</em> a way to pay with bitcoin while <a href="https://opennode.com/blog/bitcoin-payments-with-substack/">Substack was using OpenNode’s API</a>, but don’t any longer. I suppose that’s a price of vendor lock-in. It is now Substack’s <a href="https://support.substack.com/hc/en-us/articles/360037862551-I-can-t-use-Stripe-Do-you-accept-PayPal-crypto-clamshells-etc">official policy</a> to <em>not</em> support any bitcoin/crypto payments. I work in the Lightning Network <em>because</em> the payments use case of bitcoin is one of if not it’s most exciting aspect. It’s probably one of the strongest ways bitcoin can positively influence how we use the internet. To only allow credit card subscriptions, and not bitcoin lightning micropayments, for paywalled articles if I did any would be sad and hypocritical of me. There are other reasons of course, like the fact that Substack isn’t open source and that I wouldn’t actually own my own data. The idea that my blog dies when the company dies was another major negative.</p>
<p>So what other options were there that fit my increasingly stringent criteria?</p>
<h3 id="ghost">Ghost<a href="#ghost" aria-label="Link to heading 'Ghost'" data-heading-content="Ghost" class="anchor"></a></h3>
<p>Enter <a href="https://ghost.org">Ghost</a>, a website which markets itself as essentially the more <a href="https://ghost.org/vs/substack/">principled and feature-rich version of Substack</a> (which I believe they are). They are fully open source and you can run the blog software locally yourself, deploy it on a VPS of your choice, setup your own email provider, etc. If you choose to pay for them to host it for you, it’s only $9 a month and that includes the ability to bring your own domain, email subscriptions, etc. A huge improvement to me, and a project and team that I was (and still am) very excited about.</p>
<p>They even have a marketplace of templates and integrations, and given their open-source spirit I was hopeful they’d have some sort of bitcoin integration on there — and there is one…that you have to pay for. It’s called <a href="https://scribsat.com/">Scribsat</a>; here’s the Ghost Forum <a href="https://forum.ghost.org/t/a-new-bitcoin-payments-integration-scrib/36125/4">post</a> about it. They charge a monthly fee steeper than Ghost’s hosting fees itself to allow you to accept bitcoin lightning payments on Ghost. That didn’t really fit the bill for me, either, and I don’t want to be forced to depend on another service to accept the payments for me. For what it’s worth, this does seem to be a <a href="https://forum.ghost.org/t/bitcoin-payments/10514/37">hot topic</a> on the Ghost Forum, and I hope that someone will take up the call of developing something people can use for this. Ghost is a great tool and company, <a href="https://blog.lopp.net/">used by Bitcoiners</a>, and would be powerful to many if properly combined with bitcoin payments.</p>
<p>I considered working on this myself, but there is significant overhead that I just didn’t and don’t have the time (for now) to take up.</p>
<p>For awhile, the lack of bitcoin-based payment options was worth it, and I paid for a full year’s subscription even though I wasn’t sure if I’d use it for long (I didn’t, but I consider it a tithe to open-source software). I loved the writing and publishing experience, which was extremely simple, and there were a good number of default themes to choose from. However, none that I <em>loved</em>, and I found myself longing for more customizability. For most bloggers who can pay a few bucks a month or have the wherewithal to self-host, I would definitely recommend Ghost.</p>
<h3 id="inspiration-draws-from-disparate-sources">Inspiration Draws From Disparate Sources<a href="#inspiration-draws-from-disparate-sources" aria-label="Link to heading 'Inspiration Draws From Disparate Sources'" data-heading-content="Inspiration Draws From Disparate Sources" class="anchor"></a></h3>
<blockquote>
<p>Shall I tell you the secret of the true scholar? It is this: Every man I meet is my master in some point, and in that I learn of him.</p>
</blockquote>
<ul>
<li><a href="https://wist.info/emerson-ralph-waldo/65482/">Ralph Waldo Emerson, <em>Greatness</em></a></li>
</ul>
<p>My website was hosted on Ghost for a couple months, and it actually allowed me to write an article or two and post a quote here and there, and I was starting to give up on monetizing it (was I ever really doing it for that anyway?).</p>
<p>But around this time I was coming into greater contact with online presences that helped me to think differently, and though they all differ radically in occupation, style, and personal beliefs, they share an energy for creating good things meant to <em>last</em>; a passion for thinking long-term and for following their hearts over easy money and fame. A desire to achieve greatness in some form or other, and to have the revenues of their considerable efforts paid in something deeper than cash.</p>
<p>One of those I stumbled across was <a href="https://lukesmith.xyz/">Luke Smith</a>, a thoroughly original person, whose unique admixture of Twitter-like meme humor, dead-serious power usage of FOSS-only tech, deep historical, philosophical, and linguistic knowledge, and opinionated take on Christianity fascinated me, even if I didn’t agree with many of his opinions and means of presenting that information. It’s rare to find a person occupying all those particular spheres simultaneously, particularly in technology. From him I learned to ask for more from my software, to seek and value the right to and practice of <em>ownership</em>, whether that’s in owning your own land, owning your own money (bitcoin, being debt-free), or owning your own technology to the highest degree possible. He even <a href="https://lukesmith.xyz/updates/retiring-fiat-donation-portal/">removed all credit card-based ways to donate to him</a> on his website, as they weren’t in keeping with his principles. I used his tutorial website on becoming an <a href="https://landchad.net/">Internet Landlord</a> by self-hosting a website on your own DNS, for example, to build and host the version of this site at the time of writing. Another thing that is important to him is to have technology be a <em>tool you use</em>, rather than you be <em>its’ tool</em>. To that end, he helped encourage me to try to build and use software that will last, and focus less on the ephemeral. Not an easy pursuit in the software world, open source or otherwise!</p>
<p>Another figure who influenced this blog is <a href="https://www.henrikkarlsson.xyz/">Henrik Karlsson</a>, whose article <a href="https://www.henrikkarlsson.xyz/p/search-query"><em>A blog post is a very long and complex search query to find fascinating people and make them route interesting stuff to your inbox</em></a> had a deep impact on me and the direction of my thinking about how a blog should be made. It is excellent, both the idea and the read.</p>
<p><a href="https://ziglang.org/">Zig</a> creator Andrew Kelley, also comes to mind, whose article <a href="https://andrewkelley.me/post/why-we-cant-have-nice-software.html"><em>Why We Can’t Have Nice Things</em></a> helped me realize the incredible waste that often goes into making products worse when money alone is the goal.</p>
<p><a href="https://visakanv.com/">Visakan Veerasamy</a>’s article <a href="https://visakanv.substack.com/p/we-were-voyagers"><em>We Were Voyagers</em></a> is also an amazing and deeply encouraging read, and while it didn’t directly influence how I built this website, it further influenced the “do something useful to others with your life in a spirit of gratitude” approach I’m trying to take to life in general, and will have an effect on the prose and content of the site if nothing else.</p>
<p>But the final major influence was <a href="https://gwern.net/">gwern.net</a>, whose beautiful and carefully crafted website design is matched by its rich content and elegant prose. It’s filled with a hundred little features, optimizations, and design decisions that make it a joy to use. For example, it has custom <a href="https://www.mediawiki.org/wiki/Page_Previews">page previews</a> which allow you to see a preview of where a link will take you when hovering over it. It has tables of contents and footnotes for each article, and the footnotes become sidenotes on wide screens for convenience. He takes the time to design artsy <a href="https://en.wikipedia.org/wiki/Initial">dropcaps</a> for each article. And something I found very interesting that I’ve never seen before, is his extensive use of local archives to fight against <a href="https://en.wikipedia.org/wiki/Link_rot">linkrot</a>, which is an important problem if we wish to preserve something of ourselves for the future. Read his <a href="https://gwern.net/about">about page</a> for the site to learn more.</p>
<p>All told, Gwern’s website appears to me an exercise in how to create an optimal personal website for the long-run. He summarizes the fundamental question of building a site from the link above:</p>
<blockquote>
<p>What does it take to present, for the long-term, complex, highly-referenced, link-intensive, long-form text online as effectively as possible, while conserving the reader’s time &amp; attention?</p>
</blockquote>
<p>This version of my site, though still nascent, is based on a fuzzy mesh of these influences, and I will make the attempt to improve it and make it more resilient and higher quality over time.</p>
<h3 id="knowing-the-place-for-the-first-time">Knowing the Place for the First Time<a href="#knowing-the-place-for-the-first-time" aria-label="Link to heading 'Knowing the Place for the First Time'" data-heading-content="Knowing the Place for the First Time" class="anchor"></a></h3>
<p>Who was I kidding? I’m a <em>web developer</em>. I should’ve known from the beginning it would feel wrong to me to outsource that task, despite the work it may have taken. So after a year of exploration, I’m back at doing the same thing I did before — building the website in Sveltekit and MDsveX. But hopefully this time better, and having learned a lot about how to practically achieve that in addition to learning my own reasons for trying to do so in the first place.</p>
<p>Before, building my own website was a cool thing to put on my resume. But this time I have my <em>reasons</em>.</p>
<h3 id="what-now">What Now?<a href="#what-now" aria-label="Link to heading 'What Now?'" data-heading-content="What Now?" class="anchor"></a></h3>
<p>My primary reason for building this site is to document everything I do that I think might be of use to someone else (or my future self). I want something that I built myself and which I have full control over, whose format I have the freedom to modify or restructure at any time (which I couldn’t do in my previous methods). I want something that allows me to publish articles, blogs, daily journals, quotes I find interesting, projects I’m working on, what have you, in as frictionless a manner as possible while still retaining maximum expressive possibilities. Which, in essence, means I have to build things myself, and that there will be a high up-front cost to doing so.</p>
<p>So be it!</p>
]]></content:encoded></item>
<item><title>Reading, Writing, and Civilization</title><link>https://blu.cx/posts/blog/2023-09-26-reading-writing-civilization/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2023-09-26-reading-writing-civilization/</guid><pubDate>Tue, 26 Sep 2023 12:00:00 +0000</pubDate><description>Gibbon on the importance of reading and writing to civilization, and what distinguished the Romans from the 'barbarians', i.e. the Germans</description><content:encoded><![CDATA[<p>The importance of reading seems to need more and more explaining these days as people convince themselves they have no need for it (or because they simply have a hard time sitting still). Every once in awhile I’ll stumble across yet another explanation for why reading, and by reading I mean reading <em>great books</em>, is so important.</p>
<p>Here’s Gibbon on the importance of reading and writing to civilization, and what distinguished the Romans from the “barbarians”, i.e. the Germans:</p>
<blockquote>
<p>The Germans, in the age of Tacitus, were unacquainted with the use of letters; and the use of letters is the principal circumstance that distinguishes a civilized people from a herd of savages incapable of knowledge or reflection. Without that artificial help, the human memory soon dissipates or corrupts the ideas intrusted to her charge; and the nobler faculties of the mind, no longer supplied with models or with materials, gradually forget their powers; the judgement becomes feeble and lethargic, the imagination languid or irregular. Fully to apprehend this important truth, let us attempt, in an improved society, to calculate the immense distance between the man of learning and the <em>illiterate</em> peasant. The former, by reading and reflection, multiplies his own experience, and lives in distant ages and remote countries; whilst the latter, rooted to a single spot, and confined to a few years of existence, surpasses, but very little, his fellow-labourer the ox in the exercise of his mental faculties. The same, and even a greater, difference will be found between nations than between individuals; and we may safely pronounce that, without some species of writing, no people has ever preserved the faithful annals of their history, ever made any considerable progress in the abstract sciences, or ever possessed, in any tolerable degree of perfection, the useful and agreeable arts of life.</p>
</blockquote>
<p>– <em>Decline and Fall of the Roman Empire, Ch. IX, p. 242</em></p>
]]></content:encoded></item>
<item><title>The First Monotheist</title><link>https://blu.cx/posts/blog/2023-09-21-worlds-first-monotheist/</link><guid isPermaLink="true">https://blu.cx/posts/blog/2023-09-21-worlds-first-monotheist/</guid><pubDate>Thu, 21 Sep 2023 12:00:00 +0000</pubDate><description>Zoroaster founded the world's first monotheistic religion, thereby opening a new chapter in world history.</description><content:encoded><![CDATA[<p>I’m continuing to read <a href="https://www.amazon.com/Decline-Empire-Volumes-Everymans-Library/dp/0307700763/ref=sr_1_5?crid=1G5JJM2BIH17N&amp;keywords=decline+and+fall+of+the+roman+empire&amp;qid=1695350465&amp;sprefix=decline+and+%2Caps%2C85&amp;sr=8-5&amp;ufe=app_do%3Aamzn1.fos.f5122f16-c3e8-4386-bf32-63e904010ad0"><em>Decline and Fall of the Roman Empire</em></a> by Edward Gibbon, and I learned another fun series of facts I thought worth writing about. I’d heard of <a href="https://en.wikipedia.org/wiki/Zoroastrianism">Zoroastrianism</a>, and knew that it had something to do with Persia, but I’d failed to remember from World History class (shocker!) that it was <em>the first</em> monotheistic religion. Given that most people today, if they believe (or more likely, <em>claim to believe</em>, in God) they tend to believe there’s only <em>one</em>. This is an extremely important development in the history of human thought, and may be owed to Zoroaster.</p>
<p>He’s an extremely ancient figure, so much so that no one really knows when he lived, typically placing him somewhere between 1500 to 1000 BC. Zoroastrianism was the religion of the ancient Persians, and dominated much of the Middle East for a millennium, until being overtaken by Islam.</p>
<p>Aside from many of its very interesting ideas about free will, heaven and hell, creation and anti-creation, etc., one idea I found especially refreshing to find in minds that <em>long</em> predate Jesus, Socrates, Confucius, and even the <a href="https://en.wikipedia.org/wiki/Thales_of_Miletus">first philosopher</a> – was the rejection of asceticism; the abstinence of sensual pleasures which often also leads to the withdrawal of societal participation and sense of social responsibility. Zoroastrianism apparently differs directly with the founders of many of our modern religions in this regard. To quote Gibbon:</p>
<blockquote>
<p>But there are some remarkable instances, in which Zoroaster lays aside the prophet, assumes the legislator, and discovers a liberal concern for private and public happiness, seldom to be found among the grovelling or visionary schemes of superstition. Fasting and celibacy, the common means of purchasing the Divine favour, he condemns with abhorrence, as a criminal rejection of the best gifts of Providence. The saint, in the Magian religion, is obliged to beget children, to plant useful trees, to destroy noxious animals, to convey water to the dry lands of Persia, and to work out his salvation by pursuing all the labours of agriculture.</p>
</blockquote>
<p>One may wonder how much pointless human suffering was caused by the elevation of self-inflicted pain to an act smiled upon by God. This isn’t to diminish the merits of well-directed sacrifice – a sacrifice to some social purpose – just sacrifice <em>for sacrifice’s sake</em>.</p>
<p>Continuing with Gibbon:</p>
<blockquote>
<p>We may quote from the Zendavesta a wise and benevolent maxim, which compensates for many an absurdity. ‘He who sows the ground with care and diligence, acquires a greater stock of religious merit, than he could gain by the repetition of ten thousand prayers.’</p>
</blockquote>
<p>While the rejection of asceticism doesn’t exist without the opposing danger of hedonism, and while I’m sure a closer look at Zoroastrianism would reveal many strange features, it is interesting to see a religion that <em>explicitly</em> celebrates the application of our efforts toward positive social utility. If you’re going to be judged by God, it’s nice to be <em>judged by whether you do good in the world</em>, instead of being judged simply by the degree to which you abstain from participating in its evils.</p>
]]></content:encoded></item>
</channel>
</rss>
