<p>Yesterday I showed <a href="/daily/2025/04/07/nix-rst2pdf">how I'm using Nix to build my presentation slide decks</a> with rst2pdf.</p>
<p>This allows me to run a simple command like <code>nix build .#test-driven-drupal</code> to build the slides for the given presentation.</p>
<p>But I can use other tools to make this even easier.</p>
<p>What if I wanted to have a list of the available presentations to select from, and selecting one would build it?</p>
<p>Following the UNIX philosophy, I can use multiple tools together to achieve this.</p>
<p>Firstly, I can run <code>nix flake show --json</code> to show the output from my flake.nix file, which looks something like this:</p>
<pre><code class="json">{
"devShells": {... },
"formatter": {... },
"packages": {
"x86_64-linux": {
"build-configs": {... },
"sculpin": {... },
"shared": {... }
}
}
}
</code></pre>
<p>The package names - a.k.a. the presentation names - are what I want to select from.</p>
<p>I can parse the JSON object with <code>jq</code>, remove any unwanted options with <code>grep -v</code> and use <code>fzf</code> to give me a list I can fuzzy search in.</p>
<p>In a Bash script, I can assign this to a variable:</p>
<p>Once I have selected a name, I can call <code>nix build</code> on it.</p>
<pre><code class="bash">nix build .#"$selected"
</code></pre>
<p>This is a simple example, but it shows how programs can be used together and output can be passed through each program to get the result you want.</p>
<p>This allows me to run a simple command like <code>nix build .#test-driven-drupal</code> to build the slides for the given presentation.</p>
<p>But I can use other tools to make this even easier.</p>
<p>What if I wanted to have a list of the available presentations to select from, and selecting one would build it?</p>
<p>Following the UNIX philosophy, I can use multiple tools together to achieve this.</p>
<p>Firstly, I can run <code>nix flake show --json</code> to show the output from my flake.nix file, which looks something like this:</p>
<pre><code class="json">{
"devShells": {... },
"formatter": {... },
"packages": {
"x86_64-linux": {
"build-configs": {... },
"sculpin": {... },
"shared": {... }
}
}
}
</code></pre>
<p>The package names - a.k.a. the presentation names - are what I want to select from.</p>
<p>I can parse the JSON object with <code>jq</code>, remove any unwanted options with <code>grep -v</code> and use <code>fzf</code> to give me a list I can fuzzy search in.</p>
<p>In a Bash script, I can assign this to a variable:</p>
<p>Once I have selected a name, I can call <code>nix build</code> on it.</p>
<pre><code class="bash">nix build .#"$selected"
</code></pre>
<p>This is a simple example, but it shows how programs can be used together and output can be passed through each program to get the result you want.</p>