<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Cat in a Shell</title><link>https://catinashell.de/posts/</link><description>Recent content in Posts on Cat in a Shell</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 18 Oct 2026 18:30:00 +0200</lastBuildDate><atom:link href="https://catinashell.de/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Your Weather Is a Unique Fingerprint</title><link>https://catinashell.de/posts/your-weather-is-a-unique-fingerprint/</link><pubDate>Sun, 18 Oct 2026 18:30:00 +0200</pubDate><guid>https://catinashell.de/posts/your-weather-is-a-unique-fingerprint/</guid><description>&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#why-youre-unique" class="heading"&gt;
&lt;h2 id="why-youre-unique"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Why you&amp;rsquo;re unique
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;Most people I know have in their phone a whole bunch of locations for weather data, often even 10 or more &amp;hellip;&lt;/p&gt;</description><content type="html"><![CDATA[<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#why-youre-unique" class="heading">
<h2 id="why-youre-unique">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Why you&rsquo;re unique

</h2>
</a>
<p>Most people I know have in their phone a whole bunch of locations for weather data, often even 10 or more &hellip;</p>
<p>So lets say your first location is your hometown 200k inhabitions, next you have a bigger city you once traveled to, lets say new york.
Who even has both cities in their weather app, the residents of your hometown and of new york, as well as a bunch of people who did a trip to either of these. Your hometown probably didnt get soo many visitors who added it, so lets be generous and say 1mio people have it, New York is sth else. Ig maybe 100mio have it. But the pools dont overlap really much, so basically 100mio are 1.25% of the world population. And your hometown pool doesnt have any higher odds to be in the same pool as the new york people.</p>
<p>So this reduces your pool to 100k * 0.0125, so 1250 people &hellip; Thats pretty bad.</p>
<p>Now who has the same weather provider as you, lets say you&rsquo;re even a total mainstream person using either Apple or Google&rsquo;s OS on your phone -&gt; ig both have probably 45% of weather request share on mobile. So lets take 45% of your pool again. ~560 people left &hellip;</p>
<p>Now add a third location, lets say a big city in your country, who has it in your pool, probabily not soo little actually. Since your pool already fullfills the condition of being in the same country, so lets assume 30% have -&gt; ~170 ppl.</p>
<p>Now add a forth city, one you did a trip to once, e.g. Osaka, well the overlap this time isn&rsquo;t as big, bigger than the default group though, as people who once traveled to another continent, have higher odds of having traveled to another one than the average &hellip;</p>
<p>But it wont exceed 20% &hellip;</p>
<p>So now you&rsquo;re one out of 34 persons &hellip;</p>
<p>Now another smaller city again and you&rsquo;re probably unique, or 2-3 bigger ones &hellip;</p>
<p>Even if you want to assume bigger numbers each time, higher overlap etc. with 10+ locations you&rsquo;re unique (even less ig realistically)</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#why-this-matters" class="heading">
<h2 id="why-this-matters">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Why this matters

</h2>
</a>
<p>Basically if you switch your IP or use a VPN, you end up exposing your identity. Like as talked above, only you make that exact connection pattern, so if it reappears one can basically be certain its you. So basically your ISP saw you once connect to all 10 locations without vpn.</p>
<p>So basically your identity is bound to this pattern, now you turn on a vpn, dont login anywhere, browse the web, your weather app fetches its updates in the background. And tada, the unique pattern again, this time caught by the vpn&rsquo;s exit points isp. They get matched via some automatic traffic analysis (and tbh i think we are in a world where this might very well be done &hellip;). Now they can correlate this new vpn request with your real ip, just ask who it is by your isp and have your clear name, associated with whatever request you made earlier &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#what-you-can-do" class="heading">
<h2 id="what-you-can-do">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    What you can do

</h2>
</a>
<p>I personally use the FOSS App Breezy Weather, it has the big advantage, that it fetches only one weather location periodically, and all other locations only on demand. So you can avoid making x periodic requests each time</p>
<p>Also delete the weather locations you dont need anymore &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#where-this-also-applies-to" class="heading">
<h2 id="where-this-also-applies-to">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Where this also applies to

</h2>
</a>
<p>Ig your apps might also form a unique fingerprint, or at least put you in a pretty small pool &hellip; Your RSS Feed is the same.</p>
]]></content></item><item><title>Graphene Os App Stores Comparision</title><link>https://catinashell.de/posts/graphene-os-app-stores/</link><pubDate>Sun, 11 Oct 2026 15:54:43 +0200</pubDate><guid>https://catinashell.de/posts/graphene-os-app-stores/</guid><description>&lt;p&gt;Graphene OS, the secure Android without Google (the system on a phone you should use &amp;hellip;, its by far the best mobile os out there), ships by default its own Graphene OS App Store. In there aren&amp;rsquo;t many apps, basically only the GrapheneOS Apps, some google play shit, for the poor people who need it for compatability and &lt;strong&gt;Accrescent&lt;/strong&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="graphene-app-store-1.webp" alt="some screenshot of the graphene os app store"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="graphene-app-store-2.webp" alt="another screenshot of the graphene os app store"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Since this app store is preinstalled and required for sys app updates, I&amp;rsquo;m gonna exclude it. Also like you can see above, its not intended for normal apps.&lt;/p&gt;</description><content type="html"><![CDATA[<p>Graphene OS, the secure Android without Google (the system on a phone you should use &hellip;, its by far the best mobile os out there), ships by default its own Graphene OS App Store. In there aren&rsquo;t many apps, basically only the GrapheneOS Apps, some google play shit, for the poor people who need it for compatability and <strong>Accrescent</strong>.</p>
<table>
	<thead>
			<tr>
					<th></th>
					<th></th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><img src="graphene-app-store-1.webp" alt="some screenshot of the graphene os app store"></td>
					<td><img src="graphene-app-store-2.webp" alt="another screenshot of the graphene os app store"></td>
			</tr>
	</tbody>
</table>
<p>Since this app store is preinstalled and required for sys app updates, I&rsquo;m gonna exclude it. Also like you can see above, its not intended for normal apps.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#accrescent" class="heading">
<h3 id="accrescent">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Accrescent

</h3>
</a>
<blockquote>
<p>Accrescent is a private and secure Android app store built with modern features in mind. It aims to provide a developer-friendly platform and pleasant user experience while enforcing modern security and privacy practices and offering robust validity guarantees for installed apps.</p>
</blockquote>
<p>this is how Accrescent describes itself. Well and Ig they really have a bunch of cool security features (<a href="https://accrescent.app/features/" target="_blank" rel="noopener">see their features page</a>). But I have <strong>one big issue</strong>, which some people might see as a boon, but I don&rsquo;t. They have a <strong>central app repository</strong>, not allowing 3rd party app repos. And thats for security reasons, well I get that, if you have only one small catalogue of apps, its easier to enforce high quality standards &hellip;
But the whole store becomes easy to target for regulations etc. like lets say a gov decided to ban vpn&rsquo;s, to avoid legal consequences, Accerescent might comply.</p>
<p>So if you want to use Accrescent (I use it myself for a few apps), you can do so, and it&rsquo;s pretty solid, but I recommend you also keep a second store which doesnt follow this central approach.</p>
<p>Also note that the <strong>app catalogue is pretty limited</strong>, like overall ig less than 30 apps (or maybe slightly over), but don&rsquo;t expect to find everything you want there &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#aurora-store" class="heading">
<h3 id="aurora-store">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Aurora Store

</h3>
</a>
<p>The Aurora Store is basically a different front-end for the google play store, one where you <strong>don&rsquo;t require a google account</strong>. This is pretty useful if you need a particular app that is only in googles store (mostly some proprietary slop apps). And yep I get that you might need some e.g. for banking.</p>
<p>So my recommendation here is: make yourself a second user profile on your graphene os phone, and in there install the aurora store. Then use it to install your banking and other proprietary apps that you really need. I prefer setting the profile also so that it can&rsquo;t run in the background, this improves also the security of it, since this profile is basically always in the <strong>before first unlock state</strong> when you switch to your every-day profile back, additionally it prevents these proprietary apps from being too noise, as they only run a short amount of time (in my case mostly like ig, a few min once / week &hellip;).</p>
<p>I also heard that in countries where some apps are geo blocked, you might be able to get them from the Aurora Store, like in china etc.</p>
<p>But overall I recommend you <strong>use anyway FOSS Apps as much as possible</strong>, they are available basically everywhere in the world (at most their networking is blocked, but the code is basically impossible to be blocked). I might write for this also a small write-up in the future, with my favorite foss apps that do everything I need for my everyday life.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#f-droid" class="heading">
<h3 id="f-droid">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    F-Droid

</h3>
</a>
<p>This is probably the most popular store for free software, every app in here is open source, this store is by far more secure than the google play store and you can basically find apps for everything &hellip;</p>
<p>I recommend this to people who just want a working app store without searching sources in the internet.</p>
<p>Also there can be 3rd-party F Droid repos, which makes it decentral, earning from me a big +. And their v2.0 redesign also looks pretty cool</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#obtainium" class="heading">
<h3 id="obtainium">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Obtainium

</h3>
</a>
<p>Now to the one store I use myself the most, Obtainum lets you basically just link the release pages of apks and then pull from there the newest ones regularly. Like lets say you have an app that is on github and publishs its apks under each release. Then just point Obtainium there and it will always get you the newest version of the app.</p>
<p>Or even better an app that is on codeberg or a private forgejo instance, also easy to get. You can also give it an f-droid store link and it&rsquo;ll pull it from there. Or just a plain website to pull the apk from there. That is useful for e.g. the Proton Calendar app &hellip; kinda sad that they can&rsquo;t manage to publish their builds on github (where their code lives) &hellip;</p>
<p>Anyway Obtainium is great since it supports tons of sources and lets you even define custom search regex to find the download link on a website &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#my-recommendation" class="heading">
<h2 id="my-recommendation">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    My recommendation

</h2>
</a>
<p>Use Obtainium if you want to be the most in control and don&rsquo;t mind searching for builds yourself on github etc. If you want it easier then use F-Droid.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#quick-note-to-google-making-android-less-free" class="heading">
<h2 id="quick-note-to-google-making-android-less-free">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Quick Note to Google Making Android less free

</h2>
</a>
<p>Google is currently about to roll out that every app developer needs to verify themselves in their portal with government issued id (basically total surveillance and control), like apple is already doing. After this you need to go through some really annoying procedues to get unverified apps running on your phone (a ton of foss apps won&rsquo;t be verified). On Graphene OS you won&rsquo;t have this problem, so I recommend anyone of you who&rsquo;s still on stock android to switch and tell your friends etc. too to switch. GOS is anyway the far superior OS, giving you way more control &hellip;</p>
]]></content></item><item><title>My Anki Logback Cleaning Method</title><link>https://catinashell.de/posts/my-anki-logback-cleaning-method/</link><pubDate>Mon, 28 Sep 2026 07:45:00 +0200</pubDate><guid>https://catinashell.de/posts/my-anki-logback-cleaning-method/</guid><description>&lt;p&gt;&lt;em&gt;This is just my personal strategy for handling this&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I sometimes add a bunch of new anki cards to my decks (activate them), then it works a few days, sth happens that gets me out of that learning routine, I skip a few days and I end up with a backlog of 1000-2000 cards &amp;hellip; This actually happens quite often for me :S&lt;/p&gt;
&lt;p&gt;And honestly doing 2000 reviews or so in one day is just too much for me, like if its really just 7 days or so its often quite okay, but lets say you go on a trip and it becomes 30d, a ton of cards will be crazy hard to get, its basically relearning half the stack of due cards.&lt;/p&gt;</description><content type="html"><![CDATA[<p><em>This is just my personal strategy for handling this</em></p>
<p>I sometimes add a bunch of new anki cards to my decks (activate them), then it works a few days, sth happens that gets me out of that learning routine, I skip a few days and I end up with a backlog of 1000-2000 cards &hellip; This actually happens quite often for me :S</p>
<p>And honestly doing 2000 reviews or so in one day is just too much for me, like if its really just 7 days or so its often quite okay, but lets say you go on a trip and it becomes 30d, a ton of cards will be crazy hard to get, its basically relearning half the stack of due cards.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#my-strategy" class="heading">
<h3 id="my-strategy">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    My strategy

</h3>
</a>
<p>What I do in this case is pretty easy tbh, I just clear the small decks that have below 100 cards right away, as thats usually acceptable. Then for the few remaining big decks I create filtered decks on them wit</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><pre tabindex="0"><code>deck:Japanese is:due prop:due=0</code></pre>
    </div>
</div>
<p>this creates a deck with only the cards that would be due for today, not the overdue ones, which often makes it quite a small &amp; doable deck i.e. less than 100 cards. After clearing this deck I often go and change the filter to sth like</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><pre tabindex="0"><code>deck:Japanese is:due prop:due&gt;-1</code></pre>
    </div>
</div>
<p>this lets me clear the cards that were due yesterday, then set it to <code>prop:due&gt;-2</code> etc. etc. when I&rsquo;m done for today I just quit. And the next day I continue where I left of just with <code>-1</code> added to it, since one more day passed. That <strong>prevents new cards from piling up</strong> and you can slowly clear your backlog without having to do everything at once.</p>
<p><img src="anki-filtered-deck.webp" alt="creating a filtered deck"></p>
]]></content></item><item><title>Wikipedia Offline - Short Note</title><link>https://catinashell.de/posts/wikipedia-offline/</link><pubDate>Sat, 26 Sep 2026 17:45:00 +0200</pubDate><guid>https://catinashell.de/posts/wikipedia-offline/</guid><description>&lt;p&gt;&lt;em&gt;Just some small info, not really a guide, just letting you know&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I recently learned that there are Wikipedia Database Dumps and the whole english wikipedia including images is only around 110GB, thats as much as the newly released games lol. Kinda okay, for having one of the biggest sources of knowledge with you offline.&lt;/p&gt;
&lt;p&gt;For this you can download a wikipedia dump in the ZIM format, its some special archive format, the recommended way of accessing it is via a software called &lt;a href="https://get.kiwix.org/en/solutions/applications/download-options/" target="_blank" rel="noopener"&gt;Kiwix&lt;/a&gt;, which is actually open source. You can also download the wikipedia dump directly in kiwix, although tbh the interface looks kinda old :S But only the download section, once you open the archive, Wikipedia looks pretty much like usual.&lt;/p&gt;</description><content type="html"><![CDATA[<p><em>Just some small info, not really a guide, just letting you know</em></p>
<p>I recently learned that there are Wikipedia Database Dumps and the whole english wikipedia including images is only around 110GB, thats as much as the newly released games lol. Kinda okay, for having one of the biggest sources of knowledge with you offline.</p>
<p>For this you can download a wikipedia dump in the ZIM format, its some special archive format, the recommended way of accessing it is via a software called <a href="https://get.kiwix.org/en/solutions/applications/download-options/" target="_blank" rel="noopener">Kiwix</a>, which is actually open source. You can also download the wikipedia dump directly in kiwix, although tbh the interface looks kinda old :S But only the download section, once you open the archive, Wikipedia looks pretty much like usual.</p>
<p>Also you can use Kiwix as a Server, so e.g. you can put it on your home server, with some drive to it, have the server run and every device on your local network can access it.</p>
<p>And there are a lot of other Wiki Dumps available, like of the Arch Linux Wiki etc. So just experiment with it ;P</p>
]]></content></item><item><title>Fail2Ban on NixOS</title><link>https://catinashell.de/posts/nixos-fail2ban/</link><pubDate>Tue, 15 Sep 2026 09:30:00 +1000</pubDate><guid>https://catinashell.de/posts/nixos-fail2ban/</guid><description>&lt;p&gt;Fail2Ban allows you to easily temp ban ips if they do a certain action, like visiting a specific path, sending too many requests etc. This helps you protect your server from random crawlers trying to find vulnerable servers and just list your server at all. Although the best thing is still to have a server thats up to date and hardened, its still not bad to also just block malicious ips.&lt;/p&gt;</description><content type="html"><![CDATA[<p>Fail2Ban allows you to easily temp ban ips if they do a certain action, like visiting a specific path, sending too many requests etc. This helps you protect your server from random crawlers trying to find vulnerable servers and just list your server at all. Although the best thing is still to have a server thats up to date and hardened, its still not bad to also just block malicious ips.</p>
<p><img src="env_probe.webp" alt="some probes bots made on this blog"></p>
<p>One example for this is if someone is visiting on your blog <code>catinashell.de/.env</code>, I don&rsquo;t have a <code>.env</code> file, and I never linked on it. These type of files often contain some secrets, which here apparently some opportunistic bot tried to find, and on hit probably report to the script kiddie running these bots, so they can try stealing some random API Keys.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#getting-started" class="heading">
<h2 id="getting-started">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Getting started

</h2>
</a>
<p>This is just a pretty default fail2ban config for nixos, shipping with the build in ssh jail, using the defaults we se, so if someone fails to connect via ssh 5 times, they get banned for 24h now, after that if they fail again, double that etc. etc.</p>
<p>The only thing to note here is the <code>vars</code>, which isn&rsquo;t the default, if you want you can just remove the import and just write your public ip (of the server (and if you have a static one of yourself)) there. This prevents the server from getting itself banned lol, which would be really stupid and might happen if you have e.g. sth misconfigured or so</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ vars<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>fail2ban <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># IPs that can never be banned</span>
</span></span><span style="display:flex;"><span>    ignoreIP <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;127.0.0.1/8&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;::1&#34;</span>
</span></span><span style="display:flex;"><span>      vars<span style="color:#f92672">.</span>publicIP
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># defaults</span>
</span></span><span style="display:flex;"><span>    maxretry <span style="color:#f92672">=</span> <span style="color:#ae81ff">5</span>;
</span></span><span style="display:flex;"><span>    bantime <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;24h&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    bantime-increment <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      multipliers <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;1 2 4 8 16 32 64&#34;</span>;
</span></span><span style="display:flex;"><span>      maxtime <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;168h&#34;</span>; <span style="color:#75715e"># never ban an ip for more than 1 week</span>
</span></span><span style="display:flex;"><span>      overalljails <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#first-custom-jail---ban-dirbusts" class="heading">
<h2 id="first-custom-jail---ban-dirbusts">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    First Custom Jail - Ban Dirbusts

</h2>
</a>
<p>So lets add our first jail now. Dirbusts are basically just some scanners probing if certain files / directories exist on the server or not, and usually they aren&rsquo;t gentle but just scan as fast as possible, like trying out 1000 paths in 1min or so. Tools that do this are like <code>gobuster</code>, <code>ffuf</code> etc.</p>
<p>And that gives them aways pretty easily, like you can just say, if some ip get&rsquo;s X 404&rsquo;s in 1 or 2min -&gt; ban, since this is certainly not a human using your website.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ vars<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }:
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">...</span> <span style="color:#75715e"># stuff from above</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>fail2ban<span style="color:#f92672">.</span>jails <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    caddy-dirbust<span style="color:#f92672">.</span>settings <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      filter <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;caddy-dirbust&#34;</span>;
</span></span><span style="display:flex;"><span>      backend <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;auto&#34;</span>;
</span></span><span style="display:flex;"><span>      logpath <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/var/log/caddy/access-*.log&#34;</span>;
</span></span><span style="display:flex;"><span>      maxretry <span style="color:#f92672">=</span> <span style="color:#ae81ff">30</span>;
</span></span><span style="display:flex;"><span>      findtime <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;2m&#34;</span>;
</span></span><span style="display:flex;"><span>      bantime <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;1d&#34;</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  environment<span style="color:#f92672">.</span>etc <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fail2ban/filter.d/caddy-dirbust.conf&#34;</span><span style="color:#f92672">.</span>text <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      [Definition]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      datepattern = &#34;ts&#34;:\s*(\d+(?:\.\d+)?)
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      failregex = ^.*&#34;remote_ip&#34;:&#34;&lt;HOST&gt;&#34;.*&#34;status&#34;:404.*$
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      ignoreregex = ^.*&#34;uri&#34;:&#34;[^&#34;]*(?:/favicon\.ico|/favicon-.*\.png|/apple-touch-icon.*|/browserconfig\.xml|/mstile-.*|/manifest\.json|/site\.webmanifest|/robots\.txt|/sitemap\.xml|/\.well-known/(?:acme-challenge|security\.txt|apple-app-site-association|assetlinks\.json|apple-developer-merchantid-domain-association))[^&#34;]*&#34;.*$
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>This means effectivly, that if we get <strong>30 hits in 2m</strong>, we ban the ip for 1d. And below is the definition of the filter. This will read the caddy logs and then match them with the <code>failregex</code>, so all 404 errors will be matched and counted, if too many accumulate -&gt; ban.</p>
<p>Also notice the <code>ignoreregex</code>, this excludes some of these results from being counted, like missing resources that browsers might just request on default, acme stuff etc. These might often be legit requests, so don&rsquo;t ban them.</p>
<p>Also you might need to <strong>adjust these filters</strong>, like my site gets super rarely 404&rsquo;s that are legitime since I often check the error logs to see what gets hit often and then add it if it&rsquo;s valid. If you don&rsquo;t do this and clients fetch an article with lets say 20 images that are missing, they will get instantly 20 requests counted to them -&gt; on the second reload of the article they are banned basically. So you might consider excluding <code>.webp</code>, <code>.jpg</code>, <code>.png</code> etc. from this as well via the ignoreregex, if you have stuff on your website with broken resources.</p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#jail-against-the-opportunistic-credential-crawlers" class="heading">
<h2 id="jail-against-the-opportunistic-credential-crawlers">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Jail against the opportunistic Credential Crawlers

</h2>
</a>
<p>Now we have a jail against the aggressive bots, that try to enumerate your site, but still we want one as well against bots probing for certain paths, like <code>.env</code>, <code>.git/*</code> etc. etc.</p>
<p>For this I wrote a small abstraction function that builds be the regex automatically just based on 3 lists I give it, these lists contain:</p>
<ol>
<li>prefixes in uris that should result in a ban: e.g. <code>.git/</code></li>
<li>exact matches that should result in a ban: e.g. <code>.env</code></li>
<li>suffiexes in uris that should result in a ban: e.g. <code>.DS_Store</code></li>
</ol>
<p>all of these requests are basically always malicious, like in my forgejo instance, the pathes don&rsquo;t start with <code>.git/</code>, or <code>.env</code>, even if I have a <code>.env</code> file I wanna share in any of my repos, it would not be at the root of the uri, but instead at the end, so it should always be banned. And there are bunch more of such requests, that can be easily identified as malicious.</p>
<p>So here is the rule:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  vars<span style="color:#f92672">,</span>
</span></span><span style="display:flex;"><span>  lib<span style="color:#f92672">,</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">...</span>
</span></span><span style="display:flex;"><span>}:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">let</span>
</span></span><span style="display:flex;"><span>  exactBans <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.env&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;secrets.yml&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;credentials&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;phpinfo.php&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;wp-login.php&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;xmlrpc.php&#34;</span>
</span></span><span style="display:flex;"><span>  ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  prefixBans <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.git/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.ssh/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.config/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.aws/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.svn/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;vendor/&#34;</span>
</span></span><span style="display:flex;"><span>  ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  suffixBans <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;.DS_Store&#34;</span>
</span></span><span style="display:flex;"><span>  ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  uriBanRegex <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">let</span>
</span></span><span style="display:flex;"><span>      parts <span style="color:#f92672">=</span> map (p: <span style="color:#e6db74">&#39;&#39;/</span><span style="color:#e6db74">${</span>lib<span style="color:#f92672">.</span>escapeRegex p<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;&#39;&#39;</span>) exactBans <span style="color:#f92672">++</span> map (p: <span style="color:#e6db74">&#39;&#39;/</span><span style="color:#e6db74">${</span>lib<span style="color:#f92672">.</span>escapeRegex p<span style="color:#e6db74">}</span><span style="color:#e6db74">[^&#34;]*&#39;&#39;</span>) prefixBans <span style="color:#f92672">++</span> map (p: <span style="color:#e6db74">&#39;&#39;[^&#34;]*</span><span style="color:#e6db74">${</span>lib<span style="color:#f92672">.</span>escapeRegex p<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;&#39;&#39;</span>) suffixBans;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">in</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;(?:</span><span style="color:#e6db74">${</span>lib<span style="color:#f92672">.</span>concatStringsSep <span style="color:#e6db74">&#34;|&#34;</span> parts<span style="color:#e6db74">}</span><span style="color:#e6db74">)&#34;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">in</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>fail2ban<span style="color:#f92672">.</span>jails <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    caddy-dirbust<span style="color:#f92672">.</span>settings <span style="color:#f92672">=</span> <span style="color:#f92672">...</span>  <span style="color:#75715e"># caddy dirbust part like shown above</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    caddy-probes<span style="color:#f92672">.</span>settings <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      filter <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;caddy-probes&#34;</span>;
</span></span><span style="display:flex;"><span>      backend <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;auto&#34;</span>;
</span></span><span style="display:flex;"><span>      logpath <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/var/log/caddy/access-*.log&#34;</span>;
</span></span><span style="display:flex;"><span>      maxretry <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;
</span></span><span style="display:flex;"><span>      bantime <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;1d&#34;</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  environment<span style="color:#f92672">.</span>etc <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fail2ban/filter.d/caddy-dirbust.conf&#34;</span><span style="color:#f92672">.</span>text <span style="color:#f92672">=</span> <span style="color:#f92672">...</span> <span style="color:#75715e"># already shown above</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fail2ban/filter.d/caddy-probes.conf&#34;</span><span style="color:#f92672">.</span>text <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      [Definition]
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      datepattern = &#34;ts&#34;:\s*(\d+(?:\.\d+)?)
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      # generated from the exactBans/prefixBans/suffixBans lists above
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      failregex = ^.*&#34;remote_ip&#34;:&#34;&lt;HOST&gt;&#34;.*&#34;uri&#34;:&#34;</span><span style="color:#e6db74">${</span>uriBanRegex<span style="color:#e6db74">}</span><span style="color:#e6db74">.*$
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      ignoreregex =
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>obviously you can add more paths here etc. I recommend you just go through your caddy logs and search for the most requests 404&rsquo;s, check if they are missing or malicious, and depending on this add them or not to this list. Also it should provide you with a lot of flexibility without having to write regex stuff yourself.</p>
<p><img src="current_bans.webp" alt="my current jail results in grafana"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#further-ideas" class="heading">
<h2 id="further-ideas">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Further Ideas

</h2>
</a>
<p>You can fail2ban also configure to ban like too many <strong>forgejo auth attempts</strong> which is quite useful</p>
<p>Or you can, if you have a site <strong>bots / crawlers</strong> shouldn&rsquo;t access (so first configure a proper robots.txt, to not ban accidently normal crawlers) where you ban on e.g. accessing the <code>sitemap.xml</code> or other things humans ususally wouldn&rsquo;t.</p>
<p>Basically like well behaved bot reads robots -&gt; they leave, if they ignore it -&gt; ban. Or even adding some links that humans wouldnt click / even see but bots enumerate.</p>
<p>Also you can use fail2ban to <strong>block portscanning attempts</strong> on your server, like if someone is testing 100+ ports in 1m -&gt; ban, as this is almost certainly malicious.</p>
]]></content></item><item><title>Deploy a Project Securely via a Ci Workflow</title><link>https://catinashell.de/posts/deploy-a-project-securely-via-a-ci-workflow/</link><pubDate>Thu, 03 Sep 2026 04:00:00 +0200</pubDate><guid>https://catinashell.de/posts/deploy-a-project-securely-via-a-ci-workflow/</guid><description>&lt;p&gt;&lt;strong&gt;So what does this in the first place?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It allows you to deploy everything you push to a specific branch (e.g. master) (or make a release) automatically. Normally you would need to git pull, build, upload the output to your server, set the permissions and done. Really annoying tbh if you build stuff often.&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#how-it-works" class="heading"&gt;
&lt;h2 id="how-it-works"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
How it works
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;We create a new user on our server and give it the minimum permissions it needs to deploy our site / project (for a static page, just rrsync) and then we let caddy host the thing (if its a static site).&lt;/p&gt;</description><content type="html"><![CDATA[<p><strong>So what does this in the first place?</strong></p>
<p>It allows you to deploy everything you push to a specific branch (e.g. master) (or make a release) automatically. Normally you would need to git pull, build, upload the output to your server, set the permissions and done. Really annoying tbh if you build stuff often.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#how-it-works" class="heading">
<h2 id="how-it-works">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    How it works

</h2>
</a>
<p>We create a new user on our server and give it the minimum permissions it needs to deploy our site / project (for a static page, just rrsync) and then we let caddy host the thing (if its a static site).</p>
<p>The ci workflow gets a secret and a deploy set in which it upload the thing to this new user. So in case of a key compromise the worst thing that could happen is actually just that this site gets replaced (still try not publishing your keys anywhere lol).</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#creating-the-new-user" class="heading">
<h2 id="creating-the-new-user">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Creating the new user

</h2>
</a>
<p><em>since i use nixos, this is written for it&hellip; if you use another distribution, just search which imperative commands do the same stuff. Also I&rsquo;m asuming here you have ssh already configured for normal usage&hellip;</em></p>
<p>First lets create a new user (<code>deployment-usr</code>). The most important part (highlighted), is defining your deployment key (the public key, the private key is the secret in the repo) &amp; the directory where the sites should land in the end.</p>
<p>The middle line restricts the ssh key to a forced command (rrsync) in write only mode to our specified directory. For a deployment of a static site, so in case of a key compromise an attacker should be (except if there there is a vulnerability in rrsync or a misconfiguration with the permissions, etc.) be limited to only being able to change the static pages, which would be annoying but not a server takeover (in case of static sites, if you use this modified to deploy sth and run it via node, it changes the picture completely &hellip; (node project + keycompromise is basically already the user being compromised))</p>
<p>And the lower part hardens it a bit more, by restricting more ssh features that a normal user might have (not that someone malicious should even be able to access them in the first place, just multiple lines of defense so to speak &hellip;).</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>configuration.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="configuration.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ pkgs<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }: <span style="color:#75715e"># and whatever else you need ...</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">let</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>  deployKey <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ssh-ed25519 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA&#34;</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  sitesDir <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/var/www/sites&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  rrsync <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>    pkgs<span style="color:#f92672">.</span>runCommand <span style="color:#e6db74">&#34;rrsync-</span><span style="color:#e6db74">${</span>pkgs<span style="color:#f92672">.</span>rsync<span style="color:#f92672">.</span>version<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        nativeBuildInputs <span style="color:#f92672">=</span> [ pkgs<span style="color:#f92672">.</span>gnutar ];
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        tar -xzf </span><span style="color:#e6db74">${</span>pkgs<span style="color:#f92672">.</span>rsync<span style="color:#f92672">.</span>src<span style="color:#e6db74">}</span><span style="color:#e6db74"> --wildcards &#39;*/support/rrsync&#39; -O &gt; rrsync
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        # sshd runs forced commands with a minimal PATH and NixOS has no
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        # /usr/bin, so the interpreter and the rsync binary must be absolute
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        # store paths
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        substituteInPlace rrsync \
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          --replace-fail &#39;#!/usr/bin/env python3&#39; &#39;#!</span><span style="color:#e6db74">${</span>pkgs<span style="color:#f92672">.</span>python3<span style="color:#e6db74">}</span><span style="color:#e6db74">/bin/python3&#39; \
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          --replace-fail &#34;&#39;/usr/bin/rsync&#39;&#34; &#34;&#39;</span><span style="color:#e6db74">${</span>pkgs<span style="color:#f92672">.</span>rsync<span style="color:#e6db74">}</span><span style="color:#e6db74">/bin/rsync&#39;&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        install -Dm555 rrsync $out/bin/rrsync
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#39;&#39;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">in</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">...</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  users<span style="color:#f92672">.</span>groups<span style="color:#f92672">.</span>deployment-usr <span style="color:#f92672">=</span> { };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  users<span style="color:#f92672">.</span>users<span style="color:#f92672">.</span>deployment-usr <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    isSystemUser <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    group <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;deployment-usr&#34;</span>;
</span></span><span style="display:flex;"><span>    home <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/var/empty&#34;</span>;
</span></span><span style="display:flex;"><span>    createHome <span style="color:#f92672">=</span> <span style="color:#66d9ef">false</span>;
</span></span><span style="display:flex;"><span>    shell <span style="color:#f92672">=</span> pkgs<span style="color:#f92672">.</span>bash;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>    openssh<span style="color:#f92672">.</span>authorizedKeys<span style="color:#f92672">.</span>keys <span style="color:#f92672">=</span> [ <span style="color:#e6db74">&#39;&#39;command=&#34;</span><span style="color:#e6db74">${</span>rrsync<span style="color:#e6db74">}</span><span style="color:#e6db74">/bin/rrsync -wo </span><span style="color:#e6db74">${</span>sitesDir<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;,restrict </span><span style="color:#e6db74">${</span>deployKey<span style="color:#e6db74">}</span><span style="color:#e6db74">&#39;&#39;</span>];
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  environment<span style="color:#f92672">.</span>systemPackages <span style="color:#f92672">=</span> [ rrsync ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>openssh<span style="color:#f92672">.</span>settings<span style="color:#f92672">.</span>AllowUsers <span style="color:#f92672">=</span> [ <span style="color:#e6db74">&#34;deployment-usr&#34;</span> ]; <span style="color:#75715e"># adds the user additionally to the already allowed users for ssh</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>  services<span style="color:#f92672">.</span>openssh<span style="color:#f92672">.</span>extraConfig <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">    Match User deployment-usr
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      AuthenticationMethods publickey
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      DisableForwarding yes
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      PermitTTY no
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      PermitTunnel no
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      PermitUserRC no
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">      MaxSessions 2
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">  &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">...</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p><em>Also note the rsync definition in the let part, here we&rsquo;re defining our own package since in nixpkgs there is only a pythong script under rrsync, not sth we can directly use</em></p>
<p>With this added, you can rebuild (<code>nixos-rebuild switch --flake .#nixos</code>, or with whatever configuration name you have in your flake)</p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#the-ci-workflow" class="heading">
<h2 id="the-ci-workflow">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    The CI Workflow

</h2>
</a>
<p><strong>Configure the Forgejo Repo&rsquo;s secret</strong></p>
<p>You need now a new ssh key-pair (<code>ssh-keygen -t ed25519</code> (or whatever algorithm you wanan use)). The <em>private key</em> (really the private key, ik usually you don&rsquo;t upload it anywhere), gets taken and pasted as a new secret in your forgejo repo that you want to automatically be able to deploy. I named the secret <code>DEPLOY_KEY</code> and gonna reference this in this article, if you use a different name, just use yours &hellip;</p>
<p><img src="secret.webp" alt="creating the secret"></p>
<p>next you create the ci workflow in the repo, for this create a new file (in the project repo you wanna deploy) <code>.forgejo/workflows/deploy.yml</code> (for github ci just replace the <code>.forgejo</code> with <code>.github</code>)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>.forgejo/workflows/deploy.yml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename=".forgejo/workflows/deploy.yml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-yml" data-lang="yml"><span style="display:flex;"><span><span style="color:#f92672">name</span>: <span style="color:#ae81ff">deploy</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">on</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">push</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">branches</span>: [<span style="color:#ae81ff">master]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># never two deploys at once (overlapping rsyncs would interleave)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">concurrency</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">group</span>: <span style="color:#ae81ff">deploy</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">cancel-in-progress</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">jobs</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">deploy</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">runs-on</span>: <span style="color:#ae81ff">nix</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">timeout-minutes</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">steps</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Checkout</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">uses</span>: <span style="color:#ae81ff">actions/checkout@v7</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Build</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: <span style="color:#ae81ff">nix run nixpkgs#hugo -- --minify</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Deploy</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">env</span>:
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">DEPLOY_KEY</span>: <span style="color:#ae81ff">${{ secrets.DEPLOY_KEY }}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: |<span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          mkdir -p ~/.ssh
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          chmod 700 ~/.ssh
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">          echo &#34;[git.catq.de] ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGzKes+Mv/twaUkrjAx+RqkdBk0C8qqR6j8CMmpq/nIj&#34; &gt; ~/.ssh/known_hosts
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          printf &#39;%s\n&#39; &#34;$DEPLOY_KEY&#34; &gt; ~/.ssh/id_ed25519
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          chmod 600 ~/.ssh/id_ed25519
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          rsync -rlptD --delete-after --delay-updates --chmod=D755,F644 \
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">            -e &#34;ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes&#34; \
</span></span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#e6db74">            public/ deployment-usr@git.catq.de:blog/</span></span></span></code></pre></div>
    </div>
</div>
<p><em>Note in my example here I&rsquo;m deploying my hugo blog, change it accordingly to whatever you wanna deploy</em></p>
<p>The first part is just that it doesnt run concurrent, is executed on commits to the <code>master</code> branch (you might wanna use <code>main</code> here, some ppl prefer it). The <code>runs-on</code> is my custom nix image (read more about this in my post about <a href="/posts/setup-your-own-forgejo-runner-on-nixos/">setting up your own forgejo runner on nixos</a>) &hellip; but you could just use here a public one that supports the checkout action (so has node installed) and has hugo (change the step to directly use hugo and not nix run hugo) and rsync.</p>
<p>Next comes the custom rsync step, here you need to change the highlighted lines:</p>
<p>first off is a pinned public key material of the server, you wanna pin this so that it&rsquo;s not trust on first use &hellip; to get yours just run:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-fish" data-lang="fish"><span style="display:flex;"><span><span style="color:#a6e22e">ssh-keyscan</span> git.catq.de <span style="color:#f92672">|</span> <span style="color:#a6e22e">grep</span> ssh-ed25519</span></span></code></pre></div>
    </div>
</div>
<p>obviously with your own domain of the forgejo instance and then replace the thing that gets echoed</p>
<p>and then the last line, here you set the directory you wanna upload and the host (change it again to your domain), here:</p>
<p><code>public</code> gets uploaded to <code>/var/www/sites/blog</code></p>
<p><img src="deploy.webp" alt="deployment ci run successfully"></p>
<p><strong>Confirm up to this step everything worked</strong></p>
<p>Just ssh into your server like normally and run:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-fish" data-lang="fish"><span style="display:flex;"><span><span style="color:#a6e22e">ls</span> /var/www/sites/blog</span></span></code></pre></div>
    </div>
</div>
<p>there should be now the content of the build, if it exists, everything till now works fine.</p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#running-it-with-caddy" class="heading">
<h2 id="running-it-with-caddy">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Running it with Caddy

</h2>
</a>
<p>Lastly we wanna configure caddy to serve this folder for this just set in our nix config (doing it in the caddyfile for non nix systems is also quite straightforward, just google it, you want the file_server option):</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>services<span style="color:#f92672">.</span>caddy <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>  enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>  email <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;yourwebmastermail@local&#34;</span>; <span style="color:#75715e"># &lt;--- change, or you wont get letsencrypt certs</span>
</span></span><span style="display:flex;"><span>  openFirewall <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  virtualHosts<span style="color:#f92672">.</span><span style="color:#e6db74">&#34;catinashell.de&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    extraConfig <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      root * /var/www/sites/blog
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      file_server
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      encode zstd gzip
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>};</span></span></code></pre></div>
    </div>
</div>
<p><em>Also note I didn&rsquo;t add any headers here or caching, thats to keep the example here as minimal as possible, if you wanna learn more about this, <a href="/posts/secure-a-caddy-server-and-best-practices/">read my blog post about this</a></em></p>
]]></content></item><item><title>Rust Replacements for common CLI Tools</title><link>https://catinashell.de/posts/rust-cli-replacements/</link><pubDate>Fri, 21 Aug 2026 20:59:00 +0200</pubDate><guid>https://catinashell.de/posts/rust-cli-replacements/</guid><description>&lt;p&gt;Why would you want to replace these utils in the first place? Some of them are outdated in the sense they were designed for an older area and not modified to the current age accordingly (e.g. using multiple threads etc.). This is also &lt;em&gt;only a short list&lt;/em&gt;, there are a ton of other tools that are also amazing, but these are the ones I think are at least a good start.&lt;/p&gt;</description><content type="html"><![CDATA[<p>Why would you want to replace these utils in the first place? Some of them are outdated in the sense they were designed for an older area and not modified to the current age accordingly (e.g. using multiple threads etc.). This is also <em>only a short list</em>, there are a ton of other tools that are also amazing, but these are the ones I think are at least a good start.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#editor-helix" class="heading">
<h3 id="editor-helix">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Editor: Helix

</h3>
</a>
<p>Instead of neovim, I&rsquo;m recently trying out <strong>helix</strong>, contrary to vim, you make the selection first and then the action e.g. for selection a line you use <code>x</code> (ik weird in the beginning) and then e.g. <code>d</code> to delete it instead of <code>dd</code> in vim, where you first specify the action and then make the selection.</p>
<p>It also has a cool build in file selector you can get via <code>space f</code></p>
<p><img src="helix.webp" alt="showcase of helix selection first"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#terminal--shell-allacritty-fish-starship" class="heading">
<h3 id="terminal--shell-allacritty-fish-starship">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Terminal &amp; Shell: Allacritty, Fish, Starship

</h3>
</a>
<p>Well honestly a lot of terminals nowadays are written in rust, but my favorite so far is <strong>Alacritty</strong>, it&rsquo;s GPU accelerated. I don&rsquo;t know what to compare this to &hellip; ig most modern terminal emulators are actually quite good, so just use whatever feels good. Same with the shell, I use <strong>fish</strong>, but most shells provide built-in batteries. Like interactive completions etc. Additionally I use <strong>starship</strong> to make it look a bit nicer.</p>
<p><img src="fish_starship.webp" alt="fish showing the last command"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#resource-monitoring-bottom" class="heading">
<h3 id="resource-monitoring-bottom">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Resource Monitoring: Bottom

</h3>
</a>
<p>For this you can use <strong>bottom</strong>, it&rsquo;s a nice replacement for htop, providing also some cool widgets with ascii graphs etc. really cool.</p>
<p><img src="htop_bottom.webp" alt="bottom showcase"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#find-replacement-fd" class="heading">
<h3 id="find-replacement-fd">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Find Replacement: Fd

</h3>
</a>
<p>This is honestly my favorite I never figured the <code>find</code> command out, if I searched for a file, I mostly used <code>find . |rg filename</code>. Ik its not that hard to read the man page and jut learn how to use it, but I just want to use my find utility like <code>{cmd} filename</code>, and <strong>fd</strong> just gives me this. Additionally it lets you easily filter for extensions, with regex or even execute a command on all the results in parallel, like below I converted all jpg images in this post folder to webp</p>
<p><img src="find_fd.webp" alt="fd command"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#tree--ls" class="heading">
<h3 id="tree--ls">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Tree &amp; Ls

</h3>
</a>
<p>For this you can use <strong>eza</strong>, it&rsquo;s like ls with icon &amp; color support and at the same time has the tree command builtin. Also there exists <strong>lsd</strong> which is ls with colors &amp; icons</p>
<p><img src="zellij_eza.webp" alt="a split pane with zellij showing eza"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#terminal-multiplexer" class="heading">
<h3 id="terminal-multiplexer">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Terminal Multiplexer

</h3>
</a>
<p><strong>ZelliJ</strong> can be used here, its pretty easy and shows hints at the bottom, making it easier to do the stuff you want without remembering all the tmux shortcuts ;P</p>
<p>The showcase is already in the eza screenshot</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#sudo" class="heading">
<h3 id="sudo">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Sudo

</h3>
</a>
<p>You can replace sudo with <strong>sudo-rs</strong> which is a reimplementation in rust, making it imo a worthy secure upgrade, at least I use sudo quite a lot, and eliminating the whole class of memory safety issues is quite a big chunk.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#grep" class="heading">
<h3 id="grep">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Grep

</h3>
</a>
<p>Instead of <code>grep</code> I use <code>ripgrep</code> (short just <code>rg</code>), its wayyyyyy faster and allows you to even search file content directly etc.</p>
<p><img src="ripgrep.webp" alt="ripgrep as grep replacement"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#further-read" class="heading">
<h3 id="further-read">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Further Read

</h3>
</a>
<p>There is actually a similiar <a href="https://itsfoss.com/rust-alternative-cli-tools/" target="_blank" rel="noopener"><strong>It&rsquo;s Foss Post</strong></a>, if you have the free time, you might also read this if you like rust replacements ;P</p>
]]></content></item><item><title>Switching to Aerc from Thunderbird</title><link>https://catinashell.de/posts/switching-to-aerc/</link><pubDate>Thu, 20 Aug 2026 17:25:00 +0200</pubDate><guid>https://catinashell.de/posts/switching-to-aerc/</guid><description>&lt;p&gt;So why did I switch away from Thunderbird? Mostly because it&amp;rsquo;s kinda slow and comes with many features I don&amp;rsquo;t need / want. I prefer my programs to be rather minimal if possible, so everything I really want is easier to find&lt;/p&gt;
&lt;p&gt;Don&amp;rsquo;t get me wrong, Thunderbird is a great general purpose mail client for most ppl, but for me it&amp;rsquo;s too much, I don&amp;rsquo;t need a GUI &amp;hellip;&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#security" class="heading"&gt;
&lt;h3 id="security"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Security
&lt;/h3&gt;
&lt;/a&gt;
&lt;p&gt;There is an important nouance to this, aerc by default uses to render html mails, &lt;strong&gt;w3m&lt;/strong&gt;, which I &lt;strong&gt;wouldnt consider secure&lt;/strong&gt;, maybe similiar to what thunderbird does. Although it&amp;rsquo;s run sandboxed and without being able to make network connections, there are probably still a lot of Memory Vulnerabilities contained &amp;hellip; So my recommendation here is to use plaintext mails if possible, dont render them if not required. If you viewed a mail in plain text and trust it somewhat you might then pipe it to the &lt;code&gt;html&lt;/code&gt; filter.&lt;/p&gt;</description><content type="html"><![CDATA[<p>So why did I switch away from Thunderbird? Mostly because it&rsquo;s kinda slow and comes with many features I don&rsquo;t need / want. I prefer my programs to be rather minimal if possible, so everything I really want is easier to find</p>
<p>Don&rsquo;t get me wrong, Thunderbird is a great general purpose mail client for most ppl, but for me it&rsquo;s too much, I don&rsquo;t need a GUI &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#security" class="heading">
<h3 id="security">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Security

</h3>
</a>
<p>There is an important nouance to this, aerc by default uses to render html mails, <strong>w3m</strong>, which I <strong>wouldnt consider secure</strong>, maybe similiar to what thunderbird does. Although it&rsquo;s run sandboxed and without being able to make network connections, there are probably still a lot of Memory Vulnerabilities contained &hellip; So my recommendation here is to use plaintext mails if possible, dont render them if not required. If you viewed a mail in plain text and trust it somewhat you might then pipe it to the <code>html</code> filter.</p>
<p>Contrary thunderbird has probably less problems with just parsing html, but it&rsquo;s codebase is way larger and it supports way more stuff, like css in mails etc. which in return probably leads to more vulnerabilities.</p>
<p>So if you want to be secure I recommend, setting the filters to use cat or an equivalent (maybe bat is the better choice here, since its in rust, although I don&rsquo;t know the details of it (like if its just formatting cat output or is doing everything)). Otherwise the sandboxes w3m is probably fairly okay, but probably has no edge over thunderbird or webmail.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#terminal-ui" class="heading">
<h3 id="terminal-ui">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Terminal UI

</h3>
</a>
<p>After using <a href="https://aerc-mail.org/" target="_blank" rel="noopener">Aerc</a> for a while now I noticed I prefer a TUI way more. Usually mails are all formated with tons of colors and images etc. I don&rsquo;t need this, its imo just annoying, I want the information and thats it &hellip;</p>
<p>And Aerc just gives me this, it runs in my terminal, with no mouse support (I prefer this, as it forces one to learn the shortcuts and get faster). Everything works with the usual vim keybindings e.g. <code>jk</code> to go up / down in the mail list etc.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#jmap-support" class="heading">
<h3 id="jmap-support">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    JMAP Support

</h3>
</a>
<p>Also aerc supports jmap, which my mail server (<a href="/posts/setting-up-my-own-mailserver/">Stalwart</a>) also speaks. It has a bunch of advantages compared to IMAP and these old protocols, first off it just runs over https &amp; uses json (thats what the J also stands for ig (only a guess, but would make sense) ;P). I like that approach, one don&rsquo;t need to reinvent the wheel each time and have tons of random protocols. Also this means I can just have 443 open in my firewall and that&rsquo;s it, no imap port (still have it, but guess not long anymore).</p>
<p>Additionally JMAP supports bulk opperations, yeayyyyy. This makes the mail client way faster, as it can just fetch a bunch of mails at once, delete multiple mails at once etc.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#cool-features" class="heading">
<h3 id="cool-features">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Cool Features

</h3>
</a>
<ul>
<li>Uses your default terminal editor for composing a mail, in my case helix. Finally I can use my keybindings for writing mails ;P</li>
<li>pipe command, allows you to pipe your mails through any command you want, you could even cat it and pipe the output to a file if you want, use bat for syntax highlighting in your mails, open it in your editor, so you can quicker navigate or delete stuff even (cant write it, but still cool) etc.</li>
<li>PGP support, its pretty straightforward, also in the config you can set stuff like that it should sign everything etc.</li>
</ul>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#its-fast" class="heading">
<h3 id="its-fast">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Its fast

</h3>
</a>
<p>And lastly, since it runs in the terminal, its blazing fast, I open the application menu entry or run the command and its there, no waiting &hellip; all actions are instant.</p>
]]></content></item><item><title>Setup Your Own Forgejo Runner on Nixos</title><link>https://catinashell.de/posts/setup-your-own-forgejo-runner-on-nixos/</link><pubDate>Thu, 13 Aug 2026 07:51:01 +0200</pubDate><guid>https://catinashell.de/posts/setup-your-own-forgejo-runner-on-nixos/</guid><description>&lt;p&gt;this article is the follow up of &lt;a href="https://catinashell.de/posts/host-your-own-github"&gt;Host your own Github&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;a runner is basically the thing that exercutes the ci workflows you configure e.g. for running tests, like lets say you have a rust project and want each time you push, that it runs e.g. &lt;code&gt;cargo fmt --check&lt;/code&gt;&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#config" class="heading"&gt;
&lt;h3 id="config"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Config
&lt;/h3&gt;
&lt;/a&gt;
&lt;p&gt;so the first step is adding a runner in your config via: (change the url once again to point to your real forgejo instance)&lt;/p&gt;</description><content type="html"><![CDATA[<p>this article is the follow up of <a href="/posts/host-your-own-github">Host your own Github</a></p>
<p>a runner is basically the thing that exercutes the ci workflows you configure e.g. for running tests, like lets say you have a rust project and want each time you push, that it runs e.g. <code>cargo fmt --check</code></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#config" class="heading">
<h3 id="config">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Config

</h3>
</a>
<p>so the first step is adding a runner in your config via: (change the url once again to point to your real forgejo instance)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>virtualisation<span style="color:#f92672">.</span>podman<span style="color:#f92672">.</span>enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>gitea-actions-runner <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    package <span style="color:#f92672">=</span> pkgs<span style="color:#f92672">.</span>forgejo-runner;
</span></span><span style="display:flex;"><span>    instances<span style="color:#f92672">.</span>default <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;runner-1&#34;</span>;
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># you need to generate this token in forgejo, I&#39;m currently still looking how this could be automated maybe</span>
</span></span><span style="display:flex;"><span>      tokenFile <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/etc/forgejoRunnerToken&#34;</span>;
</span></span><span style="display:flex;"><span>      url <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;https://git.catq.de/&#34;</span>;
</span></span><span style="display:flex;"><span>      labels <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;node-26:docker://docker.io/node:26&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;rust:docker://docker.io/rust:latest&#34;</span>
</span></span><span style="display:flex;"><span>      ];
</span></span><span style="display:flex;"><span>      settings <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>        runner <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>          capacity <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;
</span></span><span style="display:flex;"><span>        };
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>  };</span></span></code></pre></div>
    </div>
</div>
<p>also depending on your server capability, you can change the capacity here, it controls how many workflows can run in parallel, since I use my instance only myself, and ususally only work on one project at a time / don&rsquo;t mind waiting, I set it to 1.</p>
<p>the labels are basically just the images you want to run, they use the docker compatibility layer for podman in the end apparently, and it should be <strong><code>your-intern-label:docker://docker-label</code></strong>, where you can then use your intern label inside you ci workflows.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#get-the-runner-token" class="heading">
<h3 id="get-the-runner-token">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Get the runner token

</h3>
</a>
<p>for this open your forgejo dashboard and head to the admin page, in my case: <code>https://git.catq.de/admin</code>, just change it here to match your own domain once again. In the left menu head to <em>Actions &gt; Runners</em></p>
<p><img src="runner_dashboard.webp" alt="runner dashboard"></p>
<p>Here you click on <strong>Show registration token</strong>, we need that method since the nixos option still expects this token instead of the new format.</p>
<p>then go into your server and write the file:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GNU Bash</title><path d="M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z"/></svg></span></span>

        <span>/etc/forgejoRunnerToken</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="/etc/forgejoRunnerToken"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>TOKEN<span style="color:#f92672">={</span>your_token<span style="color:#f92672">}</span></span></span></code></pre></div>
    </div>
</div>
<p>where you replace <code>{your_token}</code> with the thing you just copied.</p>
<p>then set the permissions tigher, I&rsquo;m not sure if the forgejo user even needs to be allowed to have read access, but for now I set it:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo chmod <span style="color:#ae81ff">600</span> /etc/forgejoRunnerToken
</span></span><span style="display:flex;"><span>sudo chown forgejo /etc/forgejoRunnerToken</span></span></code></pre></div>
    </div>
</div>
<p>Now you can rebuild the config <code>sudo nixos-rebuild switch --flake &lt;path to your flake#host&gt;</code></p>
<p>If you head back to your forgejo instance, you should now see your very own runner</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#adding-a-ci-workflow-to-a-project" class="heading">
<h3 id="adding-a-ci-workflow-to-a-project">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Adding a CI Workflow to a project

</h3>
</a>
<p>Now you can head into a random rust project of your choice and add</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>YAML</title><path d="m0 .97 4.111 6.453v4.09h2.638v-4.09L11.053.969H8.214L5.58 5.125 2.965.969Zm12.093.024-4.47 10.544h2.114l.97-2.345h4.775l.804 2.345h2.26L14.255.994Zm1.133 2.225 1.463 3.87h-3.096zm3.06 9.475v10.29H24v-2.199h-5.454v-8.091zm-12.175.002v10.335h2.217v-7.129l2.32 4.792h1.746l2.4-4.96v7.295h2.127V12.696h-2.904L9.44 17.37l-2.455-4.674Z"/></svg></span></span>

        <span>.forgejo/workflows/ci.yml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename=".forgejo/workflows/ci.yml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">name</span>: <span style="color:#ae81ff">tests</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">on</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">push</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">pull_request</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">jobs</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">test</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">runs-on</span>: <span style="color:#ae81ff">rust</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">steps</span>:
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Checkout</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: <span style="color:#ae81ff">git clone &#34;$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git&#34; .</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Check formatting</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: <span style="color:#ae81ff">cargo fmt --check</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Clippy</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: <span style="color:#ae81ff">cargo clippy --all-targets --all-features -- -D warnings</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">Test</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">run</span>: <span style="color:#ae81ff">cargo test --all-features</span></span></span></code></pre></div>
    </div>
</div>
<p>you might need to modify this to your needs</p>
<p>(also this template in that form wasn&rsquo;t tested by me, so not sure if it works, I tested it after creating my own image, see below)</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#you-custom-images" class="heading">
<h3 id="you-custom-images">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    You custom images

</h3>
</a>
<p>also I recommend you create your own podman images via build that include the dependencies you want i.e. create on the server a docker file &amp; build it:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Docker</title><path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg></span></span>

        <span>Dockerfile</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="Dockerfile"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-docker" data-lang="docker"><span style="display:flex;"><span><span style="color:#66d9ef">FROM</span> <span style="color:#e6db74">docker.io/rust:alpine</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#66d9ef">RUN</span> apk add --no-cache git <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  <span style="color:#f92672">&amp;&amp;</span> rustup component add clippy rustfmt <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span>  <span style="color:#f92672">&amp;&amp;</span> cargo install cargo-audit<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#66d9ef">WORKDIR</span> <span style="color:#e6db74">/workspace</span></span></span></code></pre></div>
    </div>
</div>
<p><code>podman build -t forgejo-rust:alpine .</code></p>
<p>then modify in your config the labels to</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>labels <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;rust:docker://forgejo-rust:alpine&#34;</span>
</span></span><span style="display:flex;"><span>];</span></span></code></pre></div>
    </div>
</div>
<p>(then you need to obviously rebuild nixos)</p>
<p>and you&rsquo;ll have instead of the default rust image one that is based on alpine and has <code>cargo audit available</code>, so you could use this now in your pipeline</p>
<p><img src="action_run.webp" alt="action run"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#more-considerations" class="heading">
<h3 id="more-considerations">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    More considerations

</h3>
</a>
<ul>
<li>You might want to consider using agenix or sopsnix etc. for your runner token instead of just dumping it into a file.</li>
<li>Additionally maybe you can figure out how to let the runner directly connect to your forgejo instance, instead of going through the network ig</li>
<li>The alpine image might be limiting sometimes apparently, but guess for a lot of projects it works, and I prefer my images to be as secure as possible ig, even if I&rsquo;m the only user &hellip;</li>
<li>There might be in the future a better way to add the runners, by not using the registration token but just creating a single runner token, but currently I didnt saw how to do this</li>
</ul>
]]></content></item><item><title>Host your own Github</title><link>https://catinashell.de/posts/host-your-own-github/</link><pubDate>Tue, 11 Aug 2026 13:09:12 +0200</pubDate><guid>https://catinashell.de/posts/host-your-own-github/</guid><description>&lt;p&gt;Recently Microsoft, the owner of github announced, they would scan and use all projects they have for ai training (source: &lt;a href="https://docs.github.com/en/site-policy/github-terms/github-terms-of-service?lang=en#j-ai-features-training-and-your-data" target="_blank" rel="noopener"&gt;github docs&lt;/a&gt;, march 2026).&lt;/p&gt;
&lt;p&gt;Well and I honestly don&amp;rsquo;t like that, its the code of the open source community not of big tech &amp;hellip; so I migrated with a few projects a while ago to codeberg, but I was quite annoyed often about their speeds when cloning, sometimes even timing out. So why not just host my own github like interface, the same as codeberg: &lt;strong&gt;Forgejo&lt;/strong&gt; &lt;span style="vertical-align: -1px"&gt;&lt;style&gt;
.icon svg {
width: 14px;
height: 14px;
fill: rgba(255, 255, 255, 0.7);
}
&lt;/style&gt;&lt;span class="icon"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Forgejo&lt;/title&gt;&lt;path d="M16.7773 0c1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.1175a7.0759 7.0759 0 0 1 4.148-1.4205l.1176-.001 1.3385.0002c.4973-.8827 1.4434-1.4788 2.5288-1.4788 1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.319c.8827.4973 1.4788 1.4434 1.4788 2.5287 0 1.602-1.2986 2.9005-2.9005 2.9005-1.6018 0-2.9004-1.2986-2.9004-2.9005 0-1.0853.596-2.0314 1.4788-2.5287l-.0002-9.9831c0-3.887 3.1195-7.0453 6.9915-7.108l.1176-.001h1.3385C14.7458.5962 15.692 0 16.7773 0ZM7.2227 19.9052c-.6596 0-1.1943.5347-1.1943 1.1943s.5347 1.1943 1.1943 1.1943 1.1944-.5347 1.1944-1.1943-.5348-1.1943-1.1944-1.1943Zm9.5546-10.4644c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Zm0-7.7346c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Z"/&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
.&lt;/p&gt;</description><content type="html"><![CDATA[<p>Recently Microsoft, the owner of github announced, they would scan and use all projects they have for ai training (source: <a href="https://docs.github.com/en/site-policy/github-terms/github-terms-of-service?lang=en#j-ai-features-training-and-your-data" target="_blank" rel="noopener">github docs</a>, march 2026).</p>
<p>Well and I honestly don&rsquo;t like that, its the code of the open source community not of big tech &hellip; so I migrated with a few projects a while ago to codeberg, but I was quite annoyed often about their speeds when cloning, sometimes even timing out. So why not just host my own github like interface, the same as codeberg: <strong>Forgejo</strong> <span style="vertical-align: -1px"><style>
.icon svg {
width: 14px;
height: 14px;
fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Forgejo</title><path d="M16.7773 0c1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.1175a7.0759 7.0759 0 0 1 4.148-1.4205l.1176-.001 1.3385.0002c.4973-.8827 1.4434-1.4788 2.5288-1.4788 1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.319c.8827.4973 1.4788 1.4434 1.4788 2.5287 0 1.602-1.2986 2.9005-2.9005 2.9005-1.6018 0-2.9004-1.2986-2.9004-2.9005 0-1.0853.596-2.0314 1.4788-2.5287l-.0002-9.9831c0-3.887 3.1195-7.0453 6.9915-7.108l.1176-.001h1.3385C14.7458.5962 15.692 0 16.7773 0ZM7.2227 19.9052c-.6596 0-1.1943.5347-1.1943 1.1943s.5347 1.1943 1.1943 1.1943 1.1944-.5347 1.1944-1.1943-.5348-1.1943-1.1944-1.1943Zm9.5546-10.4644c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Zm0-7.7346c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Z"/></svg></span></span>
.</p>
<p>Since its your own platform you can make the rules which I kinda like, only me &amp; my projects. No annoying stars that make you feel demotivated if your projects doesn&rsquo;t get liked etc. You decide the theme, landing page, just everything. Can host giant repos etc. etc.</p>
<hr>
<p>Note: I finally managed to migrate my server (at least partly) to NixOS, <em>so all steps are for nixos</em>, if you have a more traditional linux distro, ig its not that hard to figure out the equivalent steps and do them manually (although I recommend just switching to nix too ;P)</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#installing" class="heading">
<h2 id="installing">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Installing

</h2>
</a>
<p>as expected of nixos this is easy (obviously you need to change here the domain to your own one, and have a matching dns record)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>modules/forgejo.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="modules/forgejo.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ lib<span style="color:#f92672">,</span> config<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }:
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">let</span>
</span></span><span style="display:flex;"><span>  domain <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;git.catq.de&#34;</span>;
</span></span><span style="display:flex;"><span>  username <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;me&#34;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">in</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>forgejo <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    database<span style="color:#f92672">.</span>type <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;sqlite3&#34;</span>;
</span></span><span style="display:flex;"><span>    settings <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      server <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>        DOMAIN <span style="color:#f92672">=</span> domain;
</span></span><span style="display:flex;"><span>        ROOT_URL <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;https://</span><span style="color:#e6db74">${</span>domain<span style="color:#e6db74">}</span><span style="color:#e6db74">/&#34;</span>;
</span></span><span style="display:flex;"><span>        HTTP_ADDR <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;127.0.0.1&#34;</span>;
</span></span><span style="display:flex;"><span>        HTTP_PORT <span style="color:#f92672">=</span> <span style="color:#ae81ff">3000</span>;
</span></span><span style="display:flex;"><span>        SSH_PORT <span style="color:#f92672">=</span> lib<span style="color:#f92672">.</span>head config<span style="color:#f92672">.</span>services<span style="color:#f92672">.</span>openssh<span style="color:#f92672">.</span>ports; <span style="color:#75715e"># if you use ssh for git cloning</span>
</span></span><span style="display:flex;"><span>        LANDING_PAGE <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/</span><span style="color:#e6db74">${</span>username<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>;
</span></span><span style="display:flex;"><span>      };
</span></span><span style="display:flex;"><span>      service<span style="color:#f92672">.</span>DISABLE_REGISTRATION <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  systemd<span style="color:#f92672">.</span>services<span style="color:#f92672">.</span>forgejo<span style="color:#f92672">.</span>preStart <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">let</span>
</span></span><span style="display:flex;"><span>      adminCmd <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;</span><span style="color:#e6db74">${</span>lib<span style="color:#f92672">.</span>getExe config<span style="color:#f92672">.</span>services<span style="color:#f92672">.</span>forgejo<span style="color:#f92672">.</span>package<span style="color:#e6db74">}</span><span style="color:#e6db74"> admin user&#34;</span>;
</span></span><span style="display:flex;"><span>      user <span style="color:#f92672">=</span> username;
</span></span><span style="display:flex;"><span>      password <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;arrow9&#34;</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">in</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># important: change that password once logged in!</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      </span><span style="color:#e6db74">${</span>adminCmd<span style="color:#e6db74">}</span><span style="color:#e6db74"> create --admin --email &#34;root@localhost&#34; --username </span><span style="color:#e6db74">${</span>user<span style="color:#e6db74">}</span><span style="color:#e6db74"> --password &#34;</span><span style="color:#e6db74">${</span>password<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34; || true
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>okay so now we have our forgejo instance, next we want a reverse proxy, for this i picked caddy (again change your domain &amp; mail address in here):</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>modules/caddy.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="modules/caddy.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>caddy <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    email <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;yourmail@mail.mail&#34;</span>; <span style="color:#75715e"># you need to fill here a real / real sounding mail, so caddy can automatically obtain the certs ...</span>
</span></span><span style="display:flex;"><span>    openFirewall <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    globalConfig <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      admin off
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    virtualHosts<span style="color:#f92672">.</span><span style="color:#e6db74">&#34;git.catq.de&#34;</span><span style="color:#f92672">.</span>extraConfig <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">        reverse_proxy http://localhost:3000 {
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">            header_up X-Real-IP {remote_host}
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">          }
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#39;&#39;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>then wire everything together by importing both modules in your <code>configuration.nix</code>. and rebuild, now you should have your own forgejo instance running on your domain. open it in a browser, login and <strong>change your password!</strong></p>
<p><img src="forgejo.webp" alt="my user page in forgejo"></p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#protecting-it-from-ai-scrapers" class="heading">
<h2 id="protecting-it-from-ai-scrapers">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Protecting it from AI Scrapers

</h2>
</a>
<p>so now that we have it running, lets protect it from annoying ai bots etc. for this I&rsquo;m going to use <a href="https://anubis.techaro.lol/" target="_blank" rel="noopener">Anubis</a></p>
    
<div class="mermaid-diagram">
       
    <img
        class="mermaid-light"
        src="/mermaid/d3ae96982422b9e8990c7d0479eb5fb09810bb487d210cd2f732a3b28ce3b0b4-light.svg"
        alt="Diagram"
        style="max-width:1119px;"
        
    />
       
    <img
        class="mermaid-dark"
        src="/mermaid/d3ae96982422b9e8990c7d0479eb5fb09810bb487d210cd2f732a3b28ce3b0b4-dark.svg"
        alt="Diagram"
        style="max-width:1119px;"
        
    />
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>modules/anubis.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="modules/anubis.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  services<span style="color:#f92672">.</span>anubis<span style="color:#f92672">.</span>instances<span style="color:#f92672">.</span>forgejo <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    settings <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>      BIND <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;127.0.0.1:8923&#34;</span>;
</span></span><span style="display:flex;"><span>      BIND_NETWORK <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;tcp&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      TARGET <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;http://127.0.0.1:3000&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      SERVE_ROBOTS_TXT <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>      DIFFICULTY <span style="color:#f92672">=</span> <span style="color:#ae81ff">4</span>;
</span></span><span style="display:flex;"><span>    };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    policy<span style="color:#f92672">.</span>extraBots <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#75715e"># so normal https git clone works</span>
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;forgejo-git-info-refs&#34;</span>;
</span></span><span style="display:flex;"><span>        path_regex <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;^/[^/]+/[^/]+</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">.git/info/refs$&#34;</span>;
</span></span><span style="display:flex;"><span>        action <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ALLOW&#34;</span>;
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;forgejo-git-upload-pack&#34;</span>;
</span></span><span style="display:flex;"><span>        path_regex <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;^/[^/]+/[^/]+</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">.git/git-upload-pack$&#34;</span>;
</span></span><span style="display:flex;"><span>        action <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ALLOW&#34;</span>;
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>        name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;forgejo-git-receive-pack&#34;</span>;
</span></span><span style="display:flex;"><span>        path_regex <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;^/[^/]+/[^/]+</span><span style="color:#ae81ff">\\</span><span style="color:#e6db74">.git/git-receive-pack$&#34;</span>;
</span></span><span style="display:flex;"><span>        action <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ALLOW&#34;</span>;
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>note about the few rules I added, they allow that clients can simple download repos via https, this is a hole in the bot protection, but imo here convenience is more important, as git cli cant solve the anubis challenges. and honestly for a scraper to make use of this, they need to know the path etc beforehand, guess it makes it easier for them, still ig its okay.</p>
<p>and change inside <code>modules/caddy.nix</code>, the reverse proxy line to:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>reverse_proxy <span style="color:#e6db74">http://localhost:8923</span> {</span></span></code></pre></div>
    </div>
</div>
<p>and lastly include the anubis module as well in your imports in <code>configuration.nix</code></p>
<p><img src="anubis.webp" alt="anubis"></p>
<p>so now when you want to open your forgejo instance, you&rsquo;ll be greeted with this which takes less than 1s usually if you have js enabled but lets your pc solve a small challenge. also this will only appear the first time, not for every connection you make, so its kinda convenient.</p>
<p>honestly this won&rsquo;t protect you if someone really wants to scrape your stuff, but it makes the cost massivly higher, e.g.</p>
<p>before: AI Company makes 10,000,000 requests and scrapes tons of stuff, in effictly no time, now each requests takes them 0.5s
=&gt; ~1400 cpu hours for the same workload and normal visitors don&rsquo;t really feel it, its the same logic like behind passwords, for it to be hashed and verified takes maybe 0.01s, but if you want to brute force them (im talking about modern algorithms) you need to try billions or more combinations, which then takes quite a while and computing effort.</p>
]]></content></item><item><title>Sudoku Solver</title><link>https://catinashell.de/posts/sudoku-solver/</link><pubDate>Sat, 08 Aug 2026 18:25:23 +0200</pubDate><guid>https://catinashell.de/posts/sudoku-solver/</guid><description>&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#building-a-sudoku-solver-idea" class="heading"&gt;
&lt;h2 id="building-a-sudoku-solver-idea"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Building a Sudoku Solver (Idea)
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;Basically to solve any game via code, you just take the rules a human would play and implement code that performs them one after another &amp;hellip;&lt;/p&gt;</description><content type="html"><![CDATA[<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#building-a-sudoku-solver-idea" class="heading">
<h2 id="building-a-sudoku-solver-idea">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Building a Sudoku Solver (Idea)

</h2>
</a>
<p>Basically to solve any game via code, you just take the rules a human would play and implement code that performs them one after another &hellip;</p>
<p>For Sudoku this is stuff like: if a field can have only one possible value (e.g. in the row are already 1,2,3,4; and in the col 6,7,8,9 -&gt; so this field is clearly a 5) or when there is only like one place in a row where the digit could be. (these cases are called nacked singles &amp; hidden singles apparently in sudoku).</p>
<p>So the usual approach to safe computation is to make a candidate list, like what field could have which candidates (like manually writing notes for a hard sudoku).</p>
<p>For this I&rsquo;m gonna use a 3-dimensional boolean array, with the first 2 dimensions representing the board and then each field in the board can have 9 possible candidates, so each one is represtend with a boolean. Resulting in a 9x9x9 array. For this I&rsquo;m gonna use <strong>numpy</strong>, the reason is mostly I just wanna learn using numpy more and its pretty fast (taking advantage of vector operations and written in c).</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#implementation" class="heading">
<h2 id="implementation">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Implementation

</h2>
</a>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#basic-structure" class="heading">
<h4 id="basic-structure">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Basic Structure

</h4>
</a>
<p>Lets first write the basic structure of our solver, it should have a function <code>solve</code> that takes our puzzle as input, the puzzle is in the format:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span>board <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    [<span style="color:#ae81ff">1</span>,<span style="color:#ae81ff">2</span>,<span style="color:#ae81ff">3</span>,<span style="color:#ae81ff">4</span>,<span style="color:#ae81ff">5</span>,<span style="color:#ae81ff">6</span>,<span style="color:#ae81ff">7</span>,<span style="color:#ae81ff">8</span>,<span style="color:#ae81ff">9</span>],
</span></span><span style="display:flex;"><span>    [<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>,<span style="color:#ae81ff">0</span>],
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">...</span>
</span></span><span style="display:flex;"><span>]</span></span></code></pre></div>
    </div>
</div>
<p>Here 0 means its unknown and a number means its already filled. our function then should solve it and return the solved board. If its not solvable raise an Exception (<code>InvalidBoard</code>), same if there are multiple solutions (<code>MultipleSolutions</code>). You can obviously modify it to just return all solutions if you want instead of raising an exception.
The convention to raise an exception, is because I started doing this sudoku solver because of a kata I found on codewars. And they demanded to have an exception in the case ^^'</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>sudoku_solver.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="sudoku_solver.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> numpy <span style="color:#66d9ef">as</span> np
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># custom exceptions</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">InvalidBoard</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">MultipleSolutions</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">solve</span>(board: list) <span style="color:#f92672">-&gt;</span> list:
</span></span><span style="display:flex;"><span>    board <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>array(board)
</span></span><span style="display:flex;"><span>    hints <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>ones((<span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>), dtype<span style="color:#f92672">=</span>bool)
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># TODO: solve the puzzle ;)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">pass</span></span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#creating-hints-updating-board" class="heading">
<h4 id="creating-hints-updating-board">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Creating Hints, Updating board

</h4>
</a>
<p>So the idea here is to create first hints based on what is actually present already, like if a cell has a 9 already, remove 9 as candidate from the row, col and box. Also since that field has a value, it can obviously no longer assume other values, so the candidates for that cell should also be only the current option</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_hints</span>(board, hints):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c, e <span style="color:#f92672">in</span> enumerate(board[r]):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> e <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># so we have here a field in the board that has already a value</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># so we can set:</span>
</span></span><span style="display:flex;"><span>            
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># first of: the row &amp; col in which this cell is, cant contain this value anymore </span>
</span></span><span style="display:flex;"><span>            hints[:, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>            hints[r, :, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># same with the box </span>
</span></span><span style="display:flex;"><span>            box_row <span style="color:#f92672">=</span> (r <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            box_col <span style="color:#f92672">=</span> (c <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            hints[box_row:box_row<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, box_col:box_col<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># next the field can&#39;t obviously have any other values anymore, so we remove the candidates</span>
</span></span><span style="display:flex;"><span>            hints[r, c, :] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># and lastly we readd the own value as a candidate for this field, earlier we just removed it as well</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>            <span style="color:#75715e"># since that way we can make use of numpy&#39;s vectorization stuff &amp; it&#39;s way shorter</span>
</span></span><span style="display:flex;"><span>            hints[r, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span></span></span></code></pre></div>
    </div>
</div>
<p>The second thing we need is sth to update the board based on the hints, this carry out our two rules:</p>
<ul>
<li>nacked singles: if this field only has one possible candidate</li>
<li>hidden singles: if this field is the only one in the row / col / box that has this candidate</li>
</ul>
<p>(Don&rsquo;t blame me for these weird names, apparently they are officially called this &hellip;)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_board</span>(board, hints):
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># this modified value is added since later on its kinda handy, alternativly one could also just use numpy and compute like the sum of the board or sth similiar</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># and check if it changed, but ig this would take more computing power? </span>
</span></span><span style="display:flex;"><span>    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># nacked singles (only one value left for this field)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>            possible_entries_sum <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, c, :])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">elif</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, c]) <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># hidden singles (only possible place in row / col / box for this value)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> di <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># rows</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, :, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>               <span style="color:#75715e"># means there is only one field in this row that has this value as a candidate -&gt; it must be here</span>
</span></span><span style="display:flex;"><span>               c <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, :, di])
</span></span><span style="display:flex;"><span>               <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>               modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>               board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># cols</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[:, c, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                r <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[:, c, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># boxes</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>                count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                    rr, cc <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argwhere(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>                    <span style="color:#66d9ef">if</span> board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                    board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> modified</span></span></code></pre></div>
    </div>
</div>
<p>So while we can update the board, we need to update the hints, then try filling more of the board and so on &hellip;, so we loop as long as stuff gets modified. Thats why I added here a modified return value, so it&rsquo;s easy to check if the board was actually updated and iterate only as long as stuff changes.</p>
<p><strong>Putting it together</strong></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>sudoku_solver.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="sudoku_solver.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> numpy <span style="color:#66d9ef">as</span> np
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">InvalidBoard</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">MultipleSolutions</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_hints</span>(board, hints):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c, e <span style="color:#f92672">in</span> enumerate(board[r]):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> e <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># col</span>
</span></span><span style="display:flex;"><span>            hints[:, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># row</span>
</span></span><span style="display:flex;"><span>            hints[r, :, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># box</span>
</span></span><span style="display:flex;"><span>            box_row <span style="color:#f92672">=</span> (r <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            box_col <span style="color:#f92672">=</span> (c <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            hints[box_row:box_row<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, box_col:box_col<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># the field can&#39;t assume other values anymore ...</span>
</span></span><span style="display:flex;"><span>            hints[r, c, :] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            hints[r, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_board</span>(board, hints):
</span></span><span style="display:flex;"><span>    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># nacked singles (only one value left for this field)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>            possible_entries_sum <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, c, :])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">elif</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, c]) <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># hidden singles (only possible place in row / col / box for this value)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> di <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># rows</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, :, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>               <span style="color:#75715e"># means there is only one field in this row that has this value as a candidate -&gt; it must be here</span>
</span></span><span style="display:flex;"><span>               c <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, :, di])
</span></span><span style="display:flex;"><span>               <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>               modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>               board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># cols</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[:, c, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                r <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[:, c, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># boxes</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>                count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                    rr, cc <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argwhere(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>                    <span style="color:#66d9ef">if</span> board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                    board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> modified
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">solve</span>(board):
</span></span><span style="display:flex;"><span>    board <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>array(board)
</span></span><span style="display:flex;"><span>    hints <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>ones((<span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>), dtype<span style="color:#f92672">=</span>bool)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    update_hints(board, hints)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">while</span> update_board(board, hints):
</span></span><span style="display:flex;"><span>        update_hints(board, hints)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> board<span style="color:#f92672">.</span>tolist()</span></span></code></pre></div>
    </div>
</div>
<p><em>This is still not able to solve every sudoku that exists, only some easier ones get solved with just this</em></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#backtracking" class="heading">
<h4 id="backtracking">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Backtracking

</h4>
</a>
<p>The next &amp; last step for having a fully working sudoku solver is adding backtracking. Sometimes based on the pure deterministic logic we added a cell can still have two or more candidates and we are stuck, so the classical approach is backtracking. This means we just assume that it&rsquo;s value a first try it out, see if it works, if not then try out value b etc.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>sudoku_solver.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="sudoku_solver.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> numpy <span style="color:#66d9ef">as</span> np
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">InvalidBoard</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">MultipleSolutions</span>(<span style="color:#a6e22e">Exception</span>): <span style="color:#66d9ef">pass</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_hints</span>(board, hints):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c, e <span style="color:#f92672">in</span> enumerate(board[r]):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> e <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># col</span>
</span></span><span style="display:flex;"><span>            hints[:, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># row</span>
</span></span><span style="display:flex;"><span>            hints[r, :, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># box</span>
</span></span><span style="display:flex;"><span>            box_row <span style="color:#f92672">=</span> (r <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            box_col <span style="color:#f92672">=</span> (c <span style="color:#f92672">//</span> <span style="color:#ae81ff">3</span>) <span style="color:#f92672">*</span> <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>            hints[box_row:box_row<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, box_col:box_col<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e"># the field can&#39;t assume other values anymore ...</span>
</span></span><span style="display:flex;"><span>            hints[r, c, :] <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            hints[r, c, (e<span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>)] <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">update_board</span>(board, hints):
</span></span><span style="display:flex;"><span>    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">False</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># nacked singles (only one value left for this field)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>            possible_entries_sum <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, c, :])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">elif</span> possible_entries_sum <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, c]) <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># hidden singles (only possible place in row / col / box for this value)</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> di <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># rows</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r, :, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>               <span style="color:#75715e"># means there is only one field in this row that has this value as a candidate -&gt; it must be here</span>
</span></span><span style="display:flex;"><span>               c <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[r, :, di])
</span></span><span style="display:flex;"><span>               <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>               modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>               board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># cols</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">9</span>):
</span></span><span style="display:flex;"><span>            count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[:, c, di])
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                r <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argmax(hints[:, c, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> board[r][c] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                board[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># boxes</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> r <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> c <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">3</span>):
</span></span><span style="display:flex;"><span>                count <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">raise</span> InvalidBoard()
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> count <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>                    rr, cc <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>argwhere(hints[r:r<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, c:c<span style="color:#f92672">+</span><span style="color:#ae81ff">3</span>, di])[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>                    <span style="color:#66d9ef">if</span> board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>: <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                    modified <span style="color:#f92672">=</span> <span style="color:#66d9ef">True</span>
</span></span><span style="display:flex;"><span>                    board[r <span style="color:#f92672">+</span> rr][c <span style="color:#f92672">+</span> cc] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> modified
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">propagate</span>(board, hints):
</span></span><span style="display:flex;"><span>    iterations_required <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>    update_hints(board, hints)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">while</span> update_board(board, hints):
</span></span><span style="display:flex;"><span>        iterations_required <span style="color:#f92672">+=</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>        update_hints(board, hints)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;required: </span><span style="color:#e6db74">{</span>iterations_required<span style="color:#e6db74">}</span><span style="color:#e6db74"> iterations&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">solve</span>(board):
</span></span><span style="display:flex;"><span>    board <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>array(board)
</span></span><span style="display:flex;"><span>    hints <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>ones((<span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>, <span style="color:#ae81ff">9</span>), dtype<span style="color:#f92672">=</span>bool)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    propagate(board, hints)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># now the board &amp; hints are as small as the deterministic part of the implementation will lead</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># potential improvements: hidden / nacked pairs, triples etc. -&gt; could make it way faster later on</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> np<span style="color:#f92672">.</span>count_nonzero(board) <span style="color:#f92672">==</span> <span style="color:#ae81ff">81</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> board<span style="color:#f92672">.</span>tolist()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># since its not solved now, backtracking is required</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># find the cell with the least possibilities</span>
</span></span><span style="display:flex;"><span>    candidates_per_cell <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>sum(hints, axis<span style="color:#f92672">=</span><span style="color:#ae81ff">2</span>)
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># already filled fields should be ignored (set to 10, so they are certainly not the field thats gonna get tried)</span>
</span></span><span style="display:flex;"><span>    candidates_per_cell[board <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>] <span style="color:#f92672">=</span> <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span>    r, c <span style="color:#f92672">=</span> np<span style="color:#f92672">.</span>unravel_index(np<span style="color:#f92672">.</span>argmin(candidates_per_cell), candidates_per_cell<span style="color:#f92672">.</span>shape)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    solutions <span style="color:#f92672">=</span> []
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">for</span> di <span style="color:#f92672">in</span> np<span style="color:#f92672">.</span>where(hints[r, c])[<span style="color:#ae81ff">0</span>]:
</span></span><span style="display:flex;"><span>        board_try <span style="color:#f92672">=</span> board<span style="color:#f92672">.</span>copy()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        board_try[r][c] <span style="color:#f92672">=</span> di <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">try</span>:
</span></span><span style="display:flex;"><span>            solutions<span style="color:#f92672">.</span>append(solve(board_try))
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">except</span> InvalidBoard:
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">continue</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> solutions <span style="color:#f92672">==</span> []:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">raise</span> InvalidBoard
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">elif</span> len(solutions) <span style="color:#f92672">==</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> solutions[<span style="color:#ae81ff">0</span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">raise</span> MultipleSolutions(solutions)</span></span></code></pre></div>
    </div>
</div>
<p><img src="solving_a_hard_sudoku.webp" alt="solving a hard sudoku"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#further-improvement-ideas" class="heading">
<h4 id="further-improvement-ideas">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Further Improvement Ideas

</h4>
</a>
<p>Here one can also check (like written in the comments), for hidden / nacked pairs, triplets etc. this can make the solving way faster, by increasing the deterministic part of the solver. But for now this is enough</p>
<p>Btw, I added the required iteration prints as it&rsquo;s kinda nice to have like some information of the run and is also a good indicator if it makes sense for your sudoku difficulty to add backtracking, like if there are only
little iterations etc. then it might not be really worth it &hellip; but if you get like a ton of iterations, then its worth considering</p>
<p>Also A nice improvement would be pretty printing the result etc. (like you see here, the result doesnt look soo &ldquo;pretty&rdquo;, its just a bunch of lists, just putting them in newlines etc would be a huge improvement)</p>
]]></content></item><item><title>Next Post in August</title><link>https://catinashell.de/posts/next-post-in-august/</link><pubDate>Mon, 20 Jul 2026 21:48:06 +0200</pubDate><guid>https://catinashell.de/posts/next-post-in-august/</guid><description>&lt;p&gt;The blog is currently kinda quiet, thats due me preparing for exams now + some random coding projects and some other random stuff in my life.&lt;/p&gt;
&lt;p&gt;the next post will probably happen somewhere between &lt;em&gt;10-15. August&lt;/em&gt; and be about sth pretty cool (wouldnt spoiler yet xD)&lt;/p&gt;</description><content type="html"><![CDATA[<p>The blog is currently kinda quiet, thats due me preparing for exams now + some random coding projects and some other random stuff in my life.</p>
<p>the next post will probably happen somewhere between <em>10-15. August</em> and be about sth pretty cool (wouldnt spoiler yet xD)</p>
]]></content></item><item><title>Hugo Server Side Mermaid Rendering</title><link>https://catinashell.de/posts/hugo-server-side-mermaid-rendering/</link><pubDate>Sat, 11 Jul 2026 14:03:00 +0200</pubDate><guid>https://catinashell.de/posts/hugo-server-side-mermaid-rendering/</guid><description>&lt;p&gt;This diagram is rendered during hugo build and served as a static svg.&lt;/p&gt;
&lt;div class="mermaid-diagram"&gt;
&lt;img
class="mermaid-light"
src="https://catinashell.de/mermaid/3afa46fba91dbdd980e65425a1ae655b401f0e721471711e3293c1deda2f2218-light.svg"
alt="Diagram"
style="max-width:742px;"
/&gt;
&lt;img
class="mermaid-dark"
src="https://catinashell.de/mermaid/3afa46fba91dbdd980e65425a1ae655b401f0e721471711e3293c1deda2f2218-dark.svg"
alt="Diagram"
style="max-width:742px;"
/&gt;
&lt;/div&gt;
&lt;p&gt;Most websites just use the mermiad js library and let each user render the diagrams client-side. But this is a imo pretty trashy solution, since it requires each visitor to run javascript (which no one should do &amp;hellip;; read more in my &lt;a href="https://catinashell.de/about#nojs"&gt;about section&lt;/a&gt;).&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#how-to-make-hugo-render-mermaid-diagrams-during-build" class="heading"&gt;
&lt;h2 id="how-to-make-hugo-render-mermaid-diagrams-during-build"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
How to make Hugo render Mermaid Diagrams during Build
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;In the end you can just write in your markdown files:&lt;/p&gt;</description><content type="html"><![CDATA[<p>This diagram is rendered during hugo build and served as a static svg.</p>
    
<div class="mermaid-diagram">
       
    <img
        class="mermaid-light"
        src="/mermaid/3afa46fba91dbdd980e65425a1ae655b401f0e721471711e3293c1deda2f2218-light.svg"
        alt="Diagram"
        style="max-width:742px;"
        
    />
       
    <img
        class="mermaid-dark"
        src="/mermaid/3afa46fba91dbdd980e65425a1ae655b401f0e721471711e3293c1deda2f2218-dark.svg"
        alt="Diagram"
        style="max-width:742px;"
        
    />
</div>
<p>Most websites just use the mermiad js library and let each user render the diagrams client-side. But this is a imo pretty trashy solution, since it requires each visitor to run javascript (which no one should do &hellip;; read more in my <a href="/about#nojs">about section</a>).</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#how-to-make-hugo-render-mermaid-diagrams-during-build" class="heading">
<h2 id="how-to-make-hugo-render-mermaid-diagrams-during-build">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    How to make Hugo render Mermaid Diagrams during Build

</h2>
</a>
<p>In the end you can just write in your markdown files:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-md" data-lang="md"><span style="display:flex;"><span><span style="color:#e6db74">```mermaid
</span></span></span><span style="display:flex;"><span>packet
</span></span><span style="display:flex;"><span>0-15: &#34;Source Port&#34;
</span></span><span style="display:flex;"><span>16-31: &#34;Destination Port&#34;
</span></span><span style="display:flex;"><span>32-63: &#34;Sequence Number&#34;
</span></span><span style="display:flex;"><span>64-95: &#34;Acknowledgment Number&#34;
</span></span><span style="display:flex;"><span>96-99: &#34;Data Offset&#34;
</span></span><span style="display:flex;"><span>100-105: &#34;Reserved&#34;
</span></span><span style="display:flex;"><span>106: &#34;URG&#34;
</span></span><span style="display:flex;"><span>107: &#34;ACK&#34;
</span></span><span style="display:flex;"><span>108: &#34;PSH&#34;
</span></span><span style="display:flex;"><span>109: &#34;RST&#34;
</span></span><span style="display:flex;"><span>110: &#34;SYN&#34;
</span></span><span style="display:flex;"><span>111: &#34;FIN&#34;
</span></span><span style="display:flex;"><span>112-127: &#34;Window&#34;
</span></span><span style="display:flex;"><span>128-143: &#34;Checksum&#34;
</span></span><span style="display:flex;"><span>144-159: &#34;Urgent Pointer&#34;
</span></span><span style="display:flex;"><span>160-191: &#34;(Options and Padding)&#34;
</span></span><span style="display:flex;"><span>192-255: &#34;Data (variable length)&#34;
</span></span><span style="display:flex;"><span><span style="color:#e6db74">```</span></span></span></code></pre></div>
    </div>
</div>
<p>and it will rendered to the corresponding diagram&rsquo;s svg</p>
    
<div class="mermaid-diagram">
       
    <img
        class="mermaid-light"
        src="/mermaid/6072e96a1cb22f82d474e70e621bd4e8e3f80cc6e8fe881e62fb9218ed289898-light.svg"
        alt="Diagram"
        style="max-width:1026px;"
        
    />
       
    <img
        class="mermaid-dark"
        src="/mermaid/6072e96a1cb22f82d474e70e621bd4e8e3f80cc6e8fe881e62fb9218ed289898-dark.svg"
        alt="Diagram"
        style="max-width:1026px;"
        
    />
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#create-a-build-hook" class="heading">
<h4 id="create-a-build-hook">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Create a Build Hook

</h4>
</a>
<p>Hugo uses <code>layouts/_default/_markup/render-codeblock.html</code> to render all codeblocks, but if a specific languages codeblock is provided it will take precedence. <code>render-codeblock-mermaid.html</code> in our case.</p>
<p>So lets create that file and add some test code inside to see if it works:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/_default/_markup/render-codeblock-mermaid.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/_default/_markup/render-codeblock-mermaid.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span>&lt;<span style="color:#f92672">p</span>&gt;this will be later rendered in the file, where the mermaid block was&lt;/<span style="color:#f92672">p</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">.Inner</span> <span style="color:#75715e">}}</span> and this was written.</span></span></code></pre></div>
    </div>
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-md" data-lang="md"><span style="display:flex;"><span><span style="color:#e6db74">```mermaid
</span></span></span><span style="display:flex;"><span>something
</span></span><span style="display:flex;"><span>123
</span></span><span style="display:flex;"><span><span style="color:#e6db74">```</span></span></span></code></pre></div>
    </div>
</div>
<p>should now look like</p>
<hr>
<p><img src="hugo_renderhook_mermaid_test.webp" alt="hugo renderhook mermaid block"></p>
<hr>
<p>now lets replace the renderhook with sth actually useful.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/_default/_markup/render-codeblock-mermaid.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/_default/_markup/render-codeblock-mermaid.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$diagram</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">.Inner</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">strings</span><span style="color:#a6e22e">.TrimSpace</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$url</span> <span style="color:#f92672">:=</span> <span style="color:#e6db74">&#34;https://kroki.io/mermaid/svg&#34;</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$darkInit</span> <span style="color:#f92672">:=</span> <span style="color:#e6db74">&#34;%%{init: {&#39;theme&#39;:&#39;dark&#39;}}%%&#34;</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$diagramDark</span> <span style="color:#f92672">:=</span> <span style="color:#66d9ef">printf</span> <span style="color:#e6db74">&#34;%s\n%s&#34;</span> <span style="color:#a6e22e">$darkInit</span> <span style="color:#a6e22e">$diagram</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$opts</span>  <span style="color:#f92672">:=</span> <span style="color:#a6e22e">dict</span> <span style="color:#e6db74">&#34;method&#34;</span> <span style="color:#e6db74">&#34;POST&#34;</span> <span style="color:#e6db74">&#34;body&#34;</span> <span style="color:#a6e22e">$diagramDark</span> <span style="color:#e6db74">&#34;headers&#34;</span> <span style="color:#f92672">(</span><span style="color:#a6e22e">dict</span> <span style="color:#e6db74">&#34;Content-Type&#34;</span> <span style="color:#e6db74">&#34;text/plain&#34;</span><span style="color:#f92672">)</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;mermaid-diagram&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">{{</span> <span style="color:#66d9ef">with</span> <span style="color:#a6e22e">resources</span><span style="color:#a6e22e">.GetRemote</span> <span style="color:#a6e22e">$url</span> <span style="color:#a6e22e">$opts</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">{{</span> <span style="color:#a6e22e">$w</span> <span style="color:#f92672">:=</span> <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">{{</span> <span style="color:#66d9ef">with</span> <span style="color:#a6e22e">findRESubmatch</span> <span style="color:#e6db74">`viewBox=&#34;0 0 ([0-9.]+)`</span> <span style="color:#a6e22e">.Content</span> <span style="color:#a6e22e">1</span> <span style="color:#75715e">}}{{</span> <span style="color:#a6e22e">$w</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">index</span> <span style="color:#f92672">(</span><span style="color:#66d9ef">index</span> <span style="color:#a6e22e">.</span> <span style="color:#a6e22e">0</span><span style="color:#f92672">)</span> <span style="color:#a6e22e">1</span> <span style="color:#75715e">}}{{</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">img</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;mermaid-dark&#34;</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;</span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">.RelPermalink</span> <span style="color:#75715e">}}</span><span style="color:#e6db74">&#34;</span> <span style="color:#a6e22e">alt</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;Diagram&#34;</span><span style="color:#75715e">{{</span> <span style="color:#66d9ef">with</span> <span style="color:#a6e22e">$w</span> <span style="color:#75715e">}}</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;max-width:</span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">.</span> <span style="color:#75715e">}}</span><span style="color:#e6db74">px;&#34;</span><span style="color:#75715e">{{</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span>&gt;
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">{{</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<p>Here we use kroki.io for the rendering, it should work now on every rebuild (incl. hugo server, automatically) and render all mermaid codeblocks to valid svgs. Basically all we want. But now lets go one step further and self host kroki, since being independent is always better, also otherwise we can&rsquo;t build the blog when we&rsquo;re offline &hellip;</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#selfhosting-kroki" class="heading">
<h4 id="selfhosting-kroki">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Selfhosting Kroki

</h4>
</a>
<p>For this lets just create a docker-compose file</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Docker</title><path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg></span></span>

        <span>docker-compose.yml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="docker-compose.yml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-docker" data-lang="docker"><span style="display:flex;"><span>services:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>  kroki:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    image: yuzutech/kroki<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    depends_on: <span style="color:#f92672">[</span>mermaid<span style="color:#f92672">]</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    environment:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - KROKI_MERMAID_HOST<span style="color:#f92672">=</span>mermaid<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    ports:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;8000:8000&#34;</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>  mermaid:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    image: yuzutech/kroki-mermaid<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    expose:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;8002&#34;</span></span></span></code></pre></div>
    </div>
</div>
<p>and run it with podman: <code>podman-compose up -d</code>. Next we can change in our renderhook <code>https://kroki.io</code> to <code>http://localhost:8000</code></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/_default/_markup/render-codeblock-mermaid.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/_default/_markup/render-codeblock-mermaid.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$diagram</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">.Inner</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">strings</span><span style="color:#a6e22e">.TrimSpace</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">$url</span> <span style="color:#f92672">:=</span> <span style="color:#e6db74">&#34;http://localhost:8000/mermaid/svg&#34;</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>...</span></span></code></pre></div>
    </div>
</div>
<p>but we&rsquo;ll run into some security issues from Hugo that way, so next we need to allow requests to localhost. Inside your <code>hugo.toml</code> you can just add these lines:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Hugo</title><path d="M11.754 0a3.998 3.998 0 00-2.049.596L3.33 4.532a4.252 4.252 0 00-2.017 3.615v8.03c0 1.473.79 2.838 2.067 3.574l6.486 3.733a3.88 3.88 0 003.835.018l7.043-3.966a3.817 3.817 0 001.943-3.323V7.752a3.57 3.57 0 00-1.774-3.084L13.817.541a3.998 3.998 0 00-2.063-.54zm.022 1.674c.413-.006.828.1 1.2.315l7.095 4.127c.584.34.941.96.94 1.635v8.462c0 .774-.414 1.484-1.089 1.864l-7.042 3.966a2.199 2.199 0 01-2.179-.01l-6.485-3.734a2.447 2.447 0 01-1.228-2.123v-8.03c0-.893.461-1.72 1.221-2.19l6.376-3.935a2.323 2.323 0 011.19-.347zm-4.7 3.844V18.37h2.69v-5.62h4.46v5.62h2.696V5.518h-2.696v4.681h-4.46V5.518Z"/></svg></span></span>

        <span>hugo.toml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="hugo.toml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#a6e22e">security</span>.<span style="color:#a6e22e">http</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">methods</span> = [<span style="color:#e6db74">&#39;(?i)GET|POST&#39;</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">urls</span> = [<span style="color:#e6db74">&#39;(?i)^https?://[a-z0-9]&#39;</span>, <span style="color:#e6db74">&#39;! ^https?://\d+\.&#39;</span>, <span style="color:#e6db74">&#39;(?i)^http?://localhost:8000&#39;</span>, <span style="color:#e6db74">&#39;! (?i)^https?://[^/?#]*@&#39;</span>]</span></span></code></pre></div>
    </div>
</div>
<p>This allows connections to localhost:8000. So now <code>hugo</code> should run and render all your mermaid codeblocks to svg&rsquo;s that are embedded automatially where the codeblocks were.</p>
<p>Enjoy ;)</p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#credits" class="heading">
<h3 id="credits">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Credits

</h3>
</a>
<p>All mermaidjs examples here were taken from the <a href="https://mermaid.js.org/syntax/packet.html" target="_blank" rel="noopener">mermaid docs</a></p>
]]></content></item><item><title>Creating a Signal Bot</title><link>https://catinashell.de/posts/creating-a-signal-bot/</link><pubDate>Wed, 08 Jul 2026 19:58:28 +0200</pubDate><guid>https://catinashell.de/posts/creating-a-signal-bot/</guid><description>&lt;p&gt;&lt;img src="bot.webp" alt="some interactions with the bot"&gt;&lt;/p&gt;
&lt;p&gt;Why you want this? You can create a useful bot for chat groups, adding commands like wheater, wikipedia, reminders or something group specific. And then you don&amp;rsquo;t always have to leave signal, but can just get the info you want directly in the chat. This is pretty cool if you need sth during a conversation ;)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;If you run into any issues, just write me on &lt;a href="https://catq.de/mastodon" target="_blank" rel="noopener"&gt;mastodon&lt;/a&gt; or a &lt;a href="https://catinashell.de/about#contact"&gt;mail&lt;/a&gt;, I&amp;rsquo;ll gladly help and make the post more comprehensive&lt;/em&gt;&lt;/p&gt;</description><content type="html"><![CDATA[<p><img src="bot.webp" alt="some interactions with the bot"></p>
<p>Why you want this? You can create a useful bot for chat groups, adding commands like wheater, wikipedia, reminders or something group specific. And then you don&rsquo;t always have to leave signal, but can just get the info you want directly in the chat. This is pretty cool if you need sth during a conversation ;)</p>
<p><em>If you run into any issues, just write me on <a href="https://catq.de/mastodon" target="_blank" rel="noopener">mastodon</a> or a <a href="/about#contact">mail</a>, I&rsquo;ll gladly help and make the post more comprehensive</em></p>
<hr>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#preperations" class="heading">
<h3 id="preperations">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Preperations

</h3>
</a>
<p>first off you need <a href="https://github.com/AsamK/signal-cli" target="_blank" rel="noopener">signal-cli</a> installed</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#getting-a-new-signal-account" class="heading">
<h4 id="getting-a-new-signal-account">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Getting a new Signal Account

</h4>
</a>
<p><strong>Number</strong></p>
<p>-&gt; you need a phone number for this, so you can register a signal account on it</p>
<p>but you can also just go to SMSPool or whatever site and get the registration code there and done. I did this, it cost ~13ct &hellip;, ig its affordable xD</p>
<p><strong>Registration</strong></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>signal-cli -a +49111111111111 register</span></span></code></pre></div>
    </div>
</div>
<p>just replace the number with the one you want to use for the new signal account / the one you bought for receiving it.</p>
<p>btw its normal if the tool doesnt output anything after running, this means it was successful.</p>
<details>
	<summary><b>If you run into the &lsquo;Captcha Error&rsquo;</b> expand</summary>
	<hr>
<p>It might be that you run into an error saying sth about captcha,</p>
<p>there is a link in it. click it and solve the captcha, then it wants to open your signal app. DON&rsquo;T! Just click it away, then right click on the open app button, and copy the link.</p>
<p><img src="signal_captcha_link.webp" alt="copying the link"></p>
<p>Next run:</p>
<p><code>signal-cli -a +49111111111111 register --captcha &lt;link you copied&gt;</code></p>
<hr>
</details>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>signal-cli -a +49111111111111 verify 123-456</span></span></code></pre></div>
    </div>
</div>
<p>here run this command with your number and the code you just received. Here again, if successful, don&rsquo;t expect any output</p>
<p><strong>Test</strong></p>
<p>now you should be able to send signal messages via the command line.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>signal-cli -a +49111111111111 send -m <span style="color:#e6db74">&#34;This is a message&#34;</span> &lt;Your Actual Signal Number&gt;</span></span></code></pre></div>
    </div>
</div>
<p>here replace it again. and add your main signal number, for a test message. You should now get a new message request from your other number</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#setting-your-own-rest-api-up" class="heading">
<h3 id="setting-your-own-rest-api-up">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Setting your own Rest-API Up

</h3>
</a>
<p>I&rsquo;m using the project: <a href="https://github.com/bbernhard/signal-cli-rest-api" target="_blank" rel="noopener">signal-cli-rest-api</a>, which can be easily deployed via podman (or docker).</p>
<p>You can use the following docker compose, its already slightly modified from the docs there, to use json (as the bot lib I&rsquo;m using needs it)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Docker</title><path d="M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.185.185 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg></span></span>

        <span>docker-compose.yml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="docker-compose.yml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-docker" data-lang="docker"><span style="display:flex;"><span>version: <span style="color:#e6db74">&#34;3&#34;</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>services:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>  signal-cli-rest-api:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    image: bbernhard/signal-cli-rest-api:latest<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    environment:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - MODE<span style="color:#f92672">=</span>json-rpc-native<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    ports:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;8080:8080&#34;</span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>    volumes:<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>      - <span style="color:#e6db74">&#34;/.local/share/signal-cli:/home/.local/share/signal-cli&#34;</span></span></span></code></pre></div>
    </div>
</div>
<p><strong>Modify it if required</strong></p>
<p>The data from <code>signal-cli</code> is stored in either:</p>
<p><code>$XDG_DATA_HOME/signal-cli/</code> or <code>$HOME/.local/share/signal-cli/</code></p>
<p>If it&rsquo;s the later, just keep it as it is in the provided docker-compose file</p>
<p><strong>Running &amp; Testing</strong>
You can run it now via <code>podman-compose up -d</code></p>
<p>Then you can go to <code>http://localhost:8080/v1/accounts</code> and check if your bots number is listed there, if yes, everything is right. Congrats :)</p>
<p><em>Note: here is the <a href="https://bbernhard.github.io/signal-cli-rest-api/" target="_blank" rel="noopener">API Doc</a>, you don&rsquo;t really need to manually interact it if you follow this guide, but maybe you want to write your own library or have other reasons you want to interact directly with the api</em></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#the-bot" class="heading">
<h3 id="the-bot">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    The Bot

</h3>
</a>
<p>I choose <a href="https://github.com/signalbot-org/signalbot" target="_blank" rel="noopener">signalbot</a> as the library for the bot. For this lets create a virtual env in python and add the lib.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>uv venv .
</span></span><span style="display:flex;"><span>uv pip install python-dotenv
</span></span><span style="display:flex;"><span>uv pip install signalbot</span></span></code></pre></div>
    </div>
</div>
<p>Then you should create a <code>.env</code> file:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>.ENV</title><path d="M24 0v24H0V0h24ZM10.933 15.89H6.84v5.52h4.198v-.93H7.955v-1.503h2.77v-.93h-2.77v-1.224h2.978v-.934Zm2.146 0h-1.084v5.52h1.035v-3.6l2.226 3.6h1.118v-5.52h-1.036v3.686l-2.259-3.687Zm5.117 0h-1.208l1.973 5.52h1.19l1.976-5.52h-1.182l-1.352 4.085-1.397-4.086ZM5.4 19.68H3.72v1.68H5.4v-1.68Z"/></svg></span></span>

        <span>.env</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename=".env"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-env" data-lang="env"><span style="display:flex;"><span>SIGNAL_SERVICE<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;127.0.0.1:8080&#34;</span> <span style="color:#75715e"># &lt;-- keep it</span>
</span></span><span style="display:flex;"><span>PHONE_NUMBER<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;+491111111111&#34;</span>  <span style="color:#75715e"># &lt;---- your bot&#39;s number</span></span></span></code></pre></div>
    </div>
</div>
<p>next you can run the <a href="https://github.com/signalbot-org/signalbot#minimal-bot" target="_blank" rel="noopener">minimal bot example</a>:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>bot.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="bot.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> os
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> logging
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> signalbot <span style="color:#f92672">import</span> (
</span></span><span style="display:flex;"><span>    Command,
</span></span><span style="display:flex;"><span>    Config,
</span></span><span style="display:flex;"><span>    Context,
</span></span><span style="display:flex;"><span>    SignalBot,
</span></span><span style="display:flex;"><span>    triggered,
</span></span><span style="display:flex;"><span>    enable_console_logging,
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> dotenv <span style="color:#f92672">import</span> load_dotenv
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>load_dotenv()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">PingCommand</span>(Command):
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@triggered</span>(<span style="color:#e6db74">&#34;!ping&#34;</span>)
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">async</span> <span style="color:#66d9ef">def</span> <span style="color:#a6e22e">handle</span>(self, context: Context) <span style="color:#f92672">-&gt;</span> <span style="color:#66d9ef">None</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">await</span> context<span style="color:#f92672">.</span>send(<span style="color:#e6db74">&#34;Pong!&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> __name__ <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;__main__&#34;</span>:
</span></span><span style="display:flex;"><span>    enable_console_logging(logging<span style="color:#f92672">.</span>INFO)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    bot <span style="color:#f92672">=</span> SignalBot(
</span></span><span style="display:flex;"><span>        Config(
</span></span><span style="display:flex;"><span>            signal_service<span style="color:#f92672">=</span>os<span style="color:#f92672">.</span>environ[<span style="color:#e6db74">&#34;SIGNAL_SERVICE&#34;</span>],
</span></span><span style="display:flex;"><span>            phone_number<span style="color:#f92672">=</span>os<span style="color:#f92672">.</span>environ[<span style="color:#e6db74">&#34;PHONE_NUMBER&#34;</span>],
</span></span><span style="display:flex;"><span>        )
</span></span><span style="display:flex;"><span>    )
</span></span><span style="display:flex;"><span>    bot<span style="color:#f92672">.</span>register(PingCommand())
</span></span><span style="display:flex;"><span>    bot<span style="color:#f92672">.</span>start()</span></span></code></pre></div>
    </div>
</div>
<p><strong>Test</strong></p>
<p>Now if you go to signal and write your bot number <code>!ping</code>,</p>
<p><img src="signal_bot_ping_command.webp" alt="ping command in the chat"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#relationship-between-the-services" class="heading">
<h3 id="relationship-between-the-services">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Relationship between the Services

</h3>
</a>
    
<div class="mermaid-diagram">
       
    <img
        class="mermaid-light"
        src="/mermaid/111a27a177f079de1e01e20ad9e277ec71621031d20e76ec61d57a6ba413fc84-light.svg"
        alt="Diagram"
        style="max-width:1254px;"
        
    />
       
    <img
        class="mermaid-dark"
        src="/mermaid/111a27a177f079de1e01e20ad9e277ec71621031d20e76ec61d57a6ba413fc84-dark.svg"
        alt="Diagram"
        style="max-width:1254px;"
        
    />
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#whats-next" class="heading">
<h4 id="whats-next">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    What&rsquo;s next?

</h4>
</a>
<p>You can easily add more commands to your bot</p>
<p>Read the <a href="https://signalbot-org.github.io/signalbot/latest/" target="_blank" rel="noopener">signalbot docs</a>, to see what the lib provides.</p>
<p>If you want a follow up with some command ideas etc. Just write me on Mastodon or so, and I&rsquo;ll make an article.</p>
<p>Have fun ;)</p>
]]></content></item><item><title>Using AI to create Anki Templates with Random Values</title><link>https://catinashell.de/posts/using-ai-to-create-anki-templates/</link><pubDate>Tue, 07 Jul 2026 08:12:28 +0200</pubDate><guid>https://catinashell.de/posts/using-ai-to-create-anki-templates/</guid><description>&lt;p&gt;TLDR; just put the template in a file, use ai to modify it to your wishes. And I&amp;rsquo;m talking a bit about my own experience and what I did.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m using &lt;a href="https://apps.ankiweb.net/" target="_blank" rel="noopener"&gt;Anki&lt;/a&gt; quite a lot, for learning geography with the Ultimate Geography Deck, learning Kanji or learning stuff for university.&lt;/p&gt;
&lt;p&gt;Well and its a lot of math, like I want a card for everything (guess its inefficient, but fun at least and helps me being motivated). So having a static card is not really an option, since my brain will just remember the solution and finished, I won&amp;rsquo;t think much about it and wouldn&amp;rsquo;t need to solve the question again and again &amp;hellip;&lt;/p&gt;</description><content type="html"><![CDATA[<p>TLDR; just put the template in a file, use ai to modify it to your wishes. And I&rsquo;m talking a bit about my own experience and what I did.</p>
<p>I&rsquo;m using <a href="https://apps.ankiweb.net/" target="_blank" rel="noopener">Anki</a> quite a lot, for learning geography with the Ultimate Geography Deck, learning Kanji or learning stuff for university.</p>
<p>Well and its a lot of math, like I want a card for everything (guess its inefficient, but fun at least and helps me being motivated). So having a static card is not really an option, since my brain will just remember the solution and finished, I won&rsquo;t think much about it and wouldn&rsquo;t need to solve the question again and again &hellip;</p>
<p>So what did I do? I created a template which allows to define ranges for random values that are inserted into the template.</p>
<p><img src="interactive-random-math-anki-card.webp" alt="a anki math card template with random values each time"></p>
<p>on each refresh, the values are different, so it&rsquo;s always a new different thing to solve, making me learn the way to solve it instead of just a solution.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#creating-card-templates" class="heading">
<h3 id="creating-card-templates">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Creating card templates

</h3>
</a>
<p>Well, so how was it done? Pretty easy, I just took a anki card template I already had (<a href="https://github.com/hmelder/AnkiTUM" target="_blank" rel="noopener">anki tum card template</a>). Copied the front into a file called <code>front.html</code>, the back in <code>back.html</code>, put it in the same folder, opened Zed Editor.</p>
<p>Then opened the AI Panel, ran it (glm 5.2, as I got the cheap coder plan from z.ai), told it to create an interactive card template for me, which presents me everytime with a random matrix and has the determinant calculated in the back. And it went pretty well, I got a working template.</p>
<p><img src="ai-editing-anki-templates.webp" alt="inside zed, letting ai edit a template"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#what-can-you-do-besides-this" class="heading">
<h3 id="what-can-you-do-besides-this">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    What can you do besides this?

</h3>
</a>
<p>You can basically task the ai to create any template idea you have, make all your cards interactive. For me it improved the fun of solving the cards by a lot, making it not all rember and repeat without thinking.</p>
<p>I also created a template where I have a few variable fields, like a,b,c,d,&hellip; where I can fill in ranges and use it in the card + use calculations like <code>$(a + b)</code>, this allows making a lot of pretty cool math cards, with a lot of exercies I can solve that have random values.</p>
<p><img src="var-definitions-anki.webp" alt="defining vars for the anki cards"></p>
<p>But you could e.g. also create cards for an interactive x-y-diagram, or make the solar system interactive? maybe its funnier to click on the planets instead of just saying the positions? maybe have them even spinning, it just makes the learning more fun.</p>
<p>Also you could make cards choose a random font and color each time, this is relevant for language learning, at least for japanese. Since often I just map the image of a kanji to its meaning. If I see it in Japan then in a different font, I can&rsquo;t read it at all xD This way my brain gets forced to memorize the radicals (parts) of the kanji</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#examples-for-cards-where-i-use-random-values" class="heading">
<h3 id="examples-for-cards-where-i-use-random-values">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Examples for cards where I use random values

</h3>
</a>
<p><img src="another-anki-template-with-random-values.webp" alt="an anki card, where I have to simplify an expression"></p>
<p><img src="inverse-matrix-anki.webp" alt="inverse matrix anki"></p>
<p><a href="https://github.com/slayernominee/Anki-Random-Template" target="_blank" rel="noopener">You can view my math template on Github</a></p>
]]></content></item><item><title>Stalwart Mail Alias Creation Script</title><link>https://catinashell.de/posts/stalwart-mail-alias-creation-script/</link><pubDate>Fri, 03 Jul 2026 22:18:38 +0200</pubDate><guid>https://catinashell.de/posts/stalwart-mail-alias-creation-script/</guid><description>&lt;p&gt;I just run: &lt;code&gt;al &amp;lt;name for the alias&amp;gt;&lt;/code&gt; and get a new mail redirecting all mails to my main inbox.&lt;/p&gt;
&lt;p&gt;&lt;img src="preview.webp" alt="how it looks later"&gt;&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#why" class="heading"&gt;
&lt;h3 id="why"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Why?
&lt;/h3&gt;
&lt;/a&gt;
&lt;p&gt;You might want to hide your mail from websites where you register, as they might sell your mail address (which is then used to profile or spam you), they might get hacked and you get tons of spam, or they just spam you right away. An alias mail can be easily disabled and tada, finished, no more wories, no more mails from that address (and the site you gave it to) without having to change your whole mailbox &amp;hellip;&lt;/p&gt;</description><content type="html"><![CDATA[<p>I just run: <code>al &lt;name for the alias&gt;</code> and get a new mail redirecting all mails to my main inbox.</p>
<p><img src="preview.webp" alt="how it looks later"></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#why" class="heading">
<h3 id="why">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Why?

</h3>
</a>
<p>You might want to hide your mail from websites where you register, as they might sell your mail address (which is then used to profile or spam you), they might get hacked and you get tons of spam, or they just spam you right away. An alias mail can be easily disabled and tada, finished, no more wories, no more mails from that address (and the site you gave it to) without having to change your whole mailbox &hellip;</p>
<hr>
<p>This is the 2nd part of the <a href="http://localhost:1313/series/self-hosting-a-mailserver/" target="_blank" rel="noopener">series about setting up your own mail server</a>. I&rsquo;m presuming you already have a Stalwart Mail Server running.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#preparations" class="heading">
<h3 id="preparations">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Preparations

</h3>
</a>
<ol>
<li>
<p>Obtain your API Key from the Stalwart WebUI, in the default installation its under: <em>http://{your-domain}:8080/</em>, head to your account settings (left side panel, at the bottom the right option | <code>/account/Account/x:ApiKey</code>). Then go to Credentials and add a API Key. <em>You need to use your admin account to create this api key, as it requires more permissions than a default mailbox has</em>.</p>
</li>
<li>
<p>Install Stalwart CLI on your System</p>
</li>
</ol>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#script" class="heading">
<h3 id="script">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Script

</h3>
</a>
<p>Install the dependencies via:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>uv venv <span style="color:#f92672">&amp;&amp;</span> uv pip install pyperclip</span></span></code></pre></div>
    </div>
</div>
<p>and configure the script</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>create_alias.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="create_alias.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> json
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> os
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> subprocess
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> sys
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> pyperclip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># --------------------</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>DOMAIN <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;example.de&#34;</span>        <span style="color:#75715e"># &lt;--- Here your domain ending, like if your mail is &#39;admin@example.de&#39;, then example.de</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>HOSTNAME <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;mail.example.de&#34;</span> <span style="color:#75715e"># &lt;--- your domain with the .mail prefix usually, where the server is actually running at</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>TOKEN <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;API_AAA....&#34;</span>        <span style="color:#75715e"># &lt;---- Paste here your API Key</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>USERNAME <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;admin&#34;</span>           <span style="color:#75715e"># &lt;---- the mailbox you usually use, like if it&#39;s admin@example.de, its admin,</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>                             <span style="color:#75715e">#       if you use me@example.de as your mailbox, then enter &#39;me&#39;</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>ALIAS_POSTFIX <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;&#34;</span>           <span style="color:#75715e"># &lt;---- e.g. &#34;-alias&#34;, if you want to have a default ending for every alias, e.g. &#39;al test&#39; should</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>                             <span style="color:#75715e">#       produce the alias &#39;test-alias@example.de&#39; as alias mail</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># --------------------</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>CACHE_FILE <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;.stalwart-alias-cache.json&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># --------------------</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Usage: uv run create_alias.py &lt;alias_prefix&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># or     uv run create_alias.py</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># ------------</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> len(sys<span style="color:#f92672">.</span>argv) <span style="color:#f92672">&gt;</span> <span style="color:#ae81ff">1</span>:
</span></span><span style="display:flex;"><span>    new_alias_prefix <span style="color:#f92672">=</span> input(<span style="color:#e6db74">&#34;alias: &#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>    new_alias_prefix <span style="color:#f92672">=</span> sys<span style="color:#f92672">.</span>argv[<span style="color:#ae81ff">1</span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>user_id_cached <span style="color:#f92672">=</span> <span style="color:#66d9ef">None</span>
</span></span><span style="display:flex;"><span>domain_id_cached <span style="color:#f92672">=</span> <span style="color:#66d9ef">None</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> os<span style="color:#f92672">.</span>path<span style="color:#f92672">.</span>isfile(CACHE_FILE):
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">with</span> open(CACHE_FILE, <span style="color:#e6db74">&#34;r&#34;</span>) <span style="color:#66d9ef">as</span> f:
</span></span><span style="display:flex;"><span>        cache <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>load(f)
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;users&#34;</span> <span style="color:#f92672">in</span> cache <span style="color:#f92672">and</span> USERNAME <span style="color:#f92672">in</span> cache[<span style="color:#e6db74">&#34;users&#34;</span>]:
</span></span><span style="display:flex;"><span>            user_id_cached <span style="color:#f92672">=</span> cache[<span style="color:#e6db74">&#34;users&#34;</span>][USERNAME]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;domains&#34;</span> <span style="color:#f92672">in</span> cache <span style="color:#f92672">and</span> DOMAIN <span style="color:#f92672">in</span> cache[<span style="color:#e6db74">&#34;domains&#34;</span>]:
</span></span><span style="display:flex;"><span>            domain_id_cached <span style="color:#f92672">=</span> cache[<span style="color:#e6db74">&#34;domains&#34;</span>][DOMAIN]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">run_stalwart_cmd</span>(cmd, nojson<span style="color:#f92672">=</span><span style="color:#66d9ef">False</span>):
</span></span><span style="display:flex;"><span>    env <span style="color:#f92672">=</span> os<span style="color:#f92672">.</span>environ<span style="color:#f92672">.</span>copy()
</span></span><span style="display:flex;"><span>    env[<span style="color:#e6db74">&#34;STALWART_URL&#34;</span>] <span style="color:#f92672">=</span> <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;https://</span><span style="color:#e6db74">{</span>HOSTNAME<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>    env[<span style="color:#e6db74">&#34;STALWART_TOKEN&#34;</span>] <span style="color:#f92672">=</span> TOKEN
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    cmd <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;stalwart-cli &#34;</span> <span style="color:#f92672">+</span> cmd
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> nojson:
</span></span><span style="display:flex;"><span>        cmd <span style="color:#f92672">+=</span> <span style="color:#e6db74">&#34; --json&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># print(cmd)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    result <span style="color:#f92672">=</span> subprocess<span style="color:#f92672">.</span>check_output(
</span></span><span style="display:flex;"><span>        cmd,
</span></span><span style="display:flex;"><span>        env<span style="color:#f92672">=</span>env,
</span></span><span style="display:flex;"><span>        shell<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>,
</span></span><span style="display:flex;"><span>        text<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>,
</span></span><span style="display:flex;"><span>    )
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> nojson:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> result
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> json<span style="color:#f92672">.</span>loads(result)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> user_id_cached:
</span></span><span style="display:flex;"><span>    user_account <span style="color:#f92672">=</span> run_stalwart_cmd(
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;query Account --where name=</span><span style="color:#e6db74">{</span>USERNAME<span style="color:#e6db74">}</span><span style="color:#e6db74"> --fields id,name,emailAddress&#34;</span>
</span></span><span style="display:flex;"><span>    )
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    user_id <span style="color:#f92672">=</span> user_account[<span style="color:#e6db74">&#34;id&#34;</span>]
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] obtained user id: </span><span style="color:#e6db74">{</span>user_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>    user_id <span style="color:#f92672">=</span> user_id_cached
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] loaded user id from cache: </span><span style="color:#e6db74">{</span>user_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">not</span> domain_id_cached:
</span></span><span style="display:flex;"><span>    domain_id <span style="color:#f92672">=</span> run_stalwart_cmd(
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;query Domain --fields id,name --where name=</span><span style="color:#e6db74">{</span>DOMAIN<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>    )[<span style="color:#e6db74">&#34;id&#34;</span>]
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] obtained domain id: </span><span style="color:#e6db74">{</span>domain_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>    domain_id <span style="color:#f92672">=</span> domain_id_cached
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] loaded domain id from cache: </span><span style="color:#e6db74">{</span>domain_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>user_aliases <span style="color:#f92672">=</span> run_stalwart_cmd(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;get Account </span><span style="color:#e6db74">{</span>user_id<span style="color:#e6db74">}</span><span style="color:#e6db74"> --fields aliases&#34;</span>)[<span style="color:#e6db74">&#34;aliases&#34;</span>]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> len(list(map(int, list(user_aliases)))) <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>:
</span></span><span style="display:flex;"><span>    new_alias_id <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;0&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>    new_alias_id <span style="color:#f92672">=</span> str(max(list(map(int, list(user_aliases)))) <span style="color:#f92672">+</span> <span style="color:#ae81ff">1</span>)
</span></span><span style="display:flex;"><span>alias_list <span style="color:#f92672">=</span> [user_aliases[a][<span style="color:#e6db74">&#34;name&#34;</span>] <span style="color:#66d9ef">for</span> a <span style="color:#f92672">in</span> user_aliases]
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] obtained next alias id: </span><span style="color:#e6db74">{</span>new_alias_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>new_alias <span style="color:#f92672">=</span> <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>new_alias_prefix<span style="color:#e6db74">}{</span>ALIAS_POSTFIX<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> new_alias <span style="color:#f92672">in</span> alias_list:
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">&#34;[-] FAILURE: alias already exists! - exiting&#34;</span>)
</span></span><span style="display:flex;"><span>    exit()
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[+] alias can be created: </span><span style="color:#e6db74">{</span>new_alias<span style="color:#e6db74">}</span><span style="color:#e6db74">@</span><span style="color:#e6db74">{</span>DOMAIN<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>alias_patch <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;aliases/</span><span style="color:#e6db74">{</span>new_alias_id<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>: {
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;enabled&#34;</span>: <span style="color:#66d9ef">True</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;name&#34;</span>: new_alias,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;domainId&#34;</span>: domain_id,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#66d9ef">None</span>,
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>result <span style="color:#f92672">=</span> run_stalwart_cmd(
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;update Account &#34;</span> <span style="color:#f92672">+</span> user_id <span style="color:#f92672">+</span> <span style="color:#e6db74">&#34; --json &#39;&#34;</span> <span style="color:#f92672">+</span> json<span style="color:#f92672">.</span>dumps(alias_patch) <span style="color:#f92672">+</span> <span style="color:#e6db74">&#34;&#39;&#34;</span>,
</span></span><span style="display:flex;"><span>    nojson<span style="color:#f92672">=</span><span style="color:#66d9ef">True</span>,
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> result<span style="color:#f92672">.</span>startswith(<span style="color:#e6db74">&#34;Updated&#34;</span>):
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">&#34;[+] created alias - copying to clipboard&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    cache <span style="color:#f92672">=</span> {<span style="color:#e6db74">&#34;users&#34;</span>: {USERNAME: user_id}, <span style="color:#e6db74">&#34;domains&#34;</span>: {DOMAIN: domain_id}}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">with</span> open(CACHE_FILE, <span style="color:#e6db74">&#34;w&#34;</span>) <span style="color:#66d9ef">as</span> f:
</span></span><span style="display:flex;"><span>        json<span style="color:#f92672">.</span>dump(cache, f, indent<span style="color:#f92672">=</span><span style="color:#ae81ff">4</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    pyperclip<span style="color:#f92672">.</span>copy(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#e6db74">{</span>new_alias<span style="color:#e6db74">}</span><span style="color:#e6db74">@</span><span style="color:#e6db74">{</span>DOMAIN<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;[-] FAILURE: </span><span style="color:#e6db74">{</span>result<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)</span></span></code></pre></div>
    </div>
</div>
<hr>
<p>Now you can run it via <code>uv run create_alias.py &lt;alias to create&gt;</code></p>
<p>And you might create an alias for the script for this edit your <code>.bashrc</code> (or <code>.zshrc</code> if you use zsh) and add sth at the bottom like:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GNU Bash</title><path d="M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z"/></svg></span></span>

        <span>.bashrc</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename=".bashrc"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># ...</span>
</span></span><span style="display:flex;"><span>alias al<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;uv run create_alias.py&#34;</span></span></span></code></pre></div>
    </div>
</div>
<p>so you can run in the future <code>al &lt;alias&gt;</code> and it gets copied right into your clipboard</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#different-variation" class="heading">
<h3 id="different-variation">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Different Variation

</h3>
</a>
<p><a href="/snippets/stalwart-alias-script/">see this snippet for more details about a different variation of this script, one with a alias domain</a></p>
]]></content></item><item><title>Setting Up My Own Mailserver (Stalwart)</title><link>https://catinashell.de/posts/setting-up-my-own-mailserver/</link><pubDate>Thu, 02 Jul 2026 15:19:27 +0200</pubDate><guid>https://catinashell.de/posts/setting-up-my-own-mailserver/</guid><description>&lt;p&gt;&lt;em&gt;TLDR; Me renting about mail, you can skip to &lt;a href="#options"&gt;Options&lt;/a&gt;, if you don&amp;rsquo;t wanna read it, because you already know&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Mail usually totally sucks, you register somewhere for free, like gmail or whatever, and need to provide tons of personal data + have them scan your mails (not sure if they openly admit it tbh, but I believe they do even if claimed otherwise&amp;hellip;). Mails are horrible for privacy &amp;hellip; They are often unencrypted (except if you set up PGP and your communication partner also uses it, but almost no one except in the privacy corner does so &amp;hellip;). There are some providers who don&amp;rsquo;t ask you for as much, like Proton. Still it sucks, you can&amp;rsquo;t easily move provider etc. Lets say they decide to charge everyone one day &amp;hellip; Or change their privacy policy, or make some controversal tweets &amp;hellip; and you want to distance yourself from them.&lt;/p&gt;</description><content type="html"><![CDATA[<p><em>TLDR; Me renting about mail, you can skip to <a href="#options">Options</a>, if you don&rsquo;t wanna read it, because you already know</em></p>
<p>Mail usually totally sucks, you register somewhere for free, like gmail or whatever, and need to provide tons of personal data + have them scan your mails (not sure if they openly admit it tbh, but I believe they do even if claimed otherwise&hellip;). Mails are horrible for privacy &hellip; They are often unencrypted (except if you set up PGP and your communication partner also uses it, but almost no one except in the privacy corner does so &hellip;). There are some providers who don&rsquo;t ask you for as much, like Proton. Still it sucks, you can&rsquo;t easily move provider etc. Lets say they decide to charge everyone one day &hellip; Or change their privacy policy, or make some controversal tweets &hellip; and you want to distance yourself from them.</p>
<p>Also free plans are kinda limited, only one mail address &hellip; no aliasing etc. Also the usual mail addresses are trash, like <yourfullname>123@provider, because <yourfullname> wasnt free anymore etc., not even to think about <name>@<provider> &hellip;</p>
<p>So whats the solution?
Host your own mail server</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#options" class="heading">
<h3 id="options">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Options

</h3>
</a>
<p>Popular onces are:</p>
<ul>
<li>Mailcow</li>
<li>Mail in a Box</li>
<li>Docker Mail Server</li>
<li>Stalwart</li>
</ul>
<p>and some more, I picked <a href="https://stalw.art/" target="_blank" rel="noopener">Stalwart</a>, as it&rsquo;s written in Rust, meaning its fast and memory safe, so one whole class of exploits (everything that has to do with memory (which is easily half) doesn&rsquo;t exist), and its fast &amp; stable.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#setup" class="heading">
<h2 id="setup">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Setup

</h2>
</a>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#presetup" class="heading">
<h3 id="presetup">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Presetup

</h3>
</a>
<p>Make sure you have in your domain dns set:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><pre tabindex="0"><code>... (nameserver record, soa record)

@	IN	A	&lt;server_ip&gt;
mail	IN	A	&lt;server_ip&gt;</code></pre>
    </div>
</div>
<p>(@ and mail pointing at your servers ip)</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#installing-stalwart" class="heading">
<h3 id="installing-stalwart">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Installing Stalwart

</h3>
</a>
<p>It&rsquo;s was pretty easy in the beginning, until SSL didn&rsquo;t work for some reason, tbh I find the documentation kinda lacking &hellip;
So first of, you can just follow the <a href="https://stalw.art/docs/install/platform/linux/" target="_blank" rel="noopener">installation guide from stalwart</a>, still I write the steps here down, so that you can easier follow me along (also ommited the more edge case stuff, most linux distros use systemd nowadays etc. its the default basic setup) &hellip;</p>
<ol>
<li><strong>Get the install script &amp; launch it</strong> (btw, the docs suck here kinda, as the copy button copies the $ along &hellip;)</li>
</ol>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>curl --proto <span style="color:#e6db74">&#39;=https&#39;</span> --tlsv1.2 -sSf https://get.stalw.art/install.sh -o install.sh <span style="color:#f92672">&amp;&amp;</span> sudo sh install.sh</span></span></code></pre></div>
    </div>
</div>
<ol start="2">
<li><strong>Get the temporary credentials</strong> from the logs</li>
</ol>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>sudo journalctl -u stalwart -n <span style="color:#ae81ff">200</span> | grep -A8 <span style="color:#e6db74">&#39;bootstrap mode&#39;</span> | head -n <span style="color:#ae81ff">5</span></span></span></code></pre></div>
    </div>
</div>
<p><img src="log_credentials.webp" alt="the credentials shown in the log"></p>
<ol start="3">
<li><strong>WebUI Setup</strong></li>
</ol>
<p>Go to <strong>http://&lt;server_ip&gt;:8080/</strong> to see the installation wizzard</p>
<p>For the hostname, they want basically your domain with .mail in front of it</p>
<p>Like lets say you want to later send / receive mails with <em>hello@example.de</em>, you set the hostname to <em>mail.example.de</em>.
The domain thingy is the ending you want to use, so only <em>example.de</em>.</p>
<p>Leave the automatic tls and sininging keys on, tls won&rsquo;t work still (at least not for me).</p>
<p>Now you can basically just click through every setup page without changing anything, the defaults are okay and don&rsquo;t need to be modified.
Only the last step (DNS sth.) might be worth changing, you can add your providers api key here if you want. It will do the stuff automatically then. But I didn&rsquo;t &hellip;</p>
<p>After finishing go your terminal again and run:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>systemctl restart stalwart</span></span></code></pre></div>
    </div>
</div>
<p>Then you&rsquo;re supposed to be able to login on <em>https://yourdomain/</em>, but although I could enter it (after a certificate warning), when entering my login, it just failed &hellip;</p>
<p><img src="login_fail.webp" alt="login fail"></p>
<p>so I just went back to <em>http://yourdomain:8080/</em> and logged in there again.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#ssl-configuration" class="heading">
<h3 id="ssl-configuration">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    SSL Configuration

</h3>
</a>
<p>Well the installation didn&rsquo;t get any SSL Certs by itself for some reason (even after reinstalling etc.). So what you should do is:</p>
<p>Go in the dashboard on the right to <strong>Domains &gt; Domains</strong>, click on your domain, scroll down to the <strong>TLS Section</strong>, and add here as <em>additional hostnames</em> your domain and mail.domain &hellip;</p>
<p><img src="tls_fix.webp" alt="tls fix"></p>
<p>now you might need to wait a while, but it should be able to get now finally some certs. (Like you can wait 15min or so if you want, or check in the Logs Section in the side panel (Observability &gt; Logs) for when it will run and then just come back when it changed to sth in the distant future (~3months ig))</p>
<p>now the certs are there, still login to the portal via https stills fails after the login, although now without cert issue</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#dns-settings" class="heading">
<h3 id="dns-settings">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    DNS Settings

</h3>
</a>
<p>Go to <strong>Domains &gt; Domains</strong> and select the <strong>3 dots</strong> on the right of your domain entry:</p>
<p><img src="domain_zone_file.webp" alt="domain zone file location"></p>
<p>Now view zone file, copy all the content and head to your dns provider (in my case Hetzer), there you need to paste this in your zone file:</p>
<p>In the case of Hetzner, inside your &ldquo;project&rdquo;, head to dns (on the left), click on your domain, then click the &ldquo;Actions&rdquo; Button (right top), go to edit zone file and paste everything at the bottom &amp; save.</p>
<p>Now that this is done your mail server is ready.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#reverse-dns" class="heading">
<h4 id="reverse-dns">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Reverse DNS

</h4>
</a>
<p>You probably also want to setup reverse DNS, since many mail providers (you might want to communicate with) check if your ip also resolves to your domain. For this go to your server settings and set the reverse entry to sth like <code>mail.example.org</code>.</p>
<p>You can verify this setting via: <code>dig -x &lt;ip&gt; +short</code>. Note: It usually takes quite a while to update (at least for me it took)</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>❯ dig -x 1.1.1.1 +short
</span></span><span style="display:flex;"><span>one.one.one.one.</span></span></code></pre></div>
    </div>
</div>
<p>means the reverse Entry of 1.1.1.1 point to one.one.one.one, which is usually a good sign, you want sth similiar, pointing to your mail server hostname.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#testing" class="heading">
<h3 id="testing">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Testing

</h3>
</a>
<p>You can now head to your mail client (e.g. Thunderbird) and add your account with your domain and admin password, all settings can be figured out automatically.</p>
<p><img src="thunderbird.webp" alt="inside thunderbird"></p>
<p>Now you can go to the web portal again and create a new custom mail box like hello@domain etc. and add them to your mail clients.</p>
<p><em>Note: I&rsquo;m gonna soon write a follow up article talking about how I set up mail aliasing on my own server via a script, so that one can just run <code>genalias &lt;keyword&gt;</code> to get a new mail alias (<keyword>-a@domain) copied to clipboard that redirects all mails it receives to your main inbox. Subscribe via RSS if you want, or follow me on Mastodon</em></p>
]]></content></item><item><title>How to add a copy button to Codeblocks in Hugo</title><link>https://catinashell.de/posts/hugo-copy-codeblocks/</link><pubDate>Tue, 30 Jun 2026 09:53:18 +0200</pubDate><guid>https://catinashell.de/posts/hugo-copy-codeblocks/</guid><description>&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#before--after" class="heading"&gt;
&lt;h2 id="before--after"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Before &amp;amp; After
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;&lt;img src="codeblock_before.webp" alt="default hugo codeblock"&gt;&lt;/p&gt;
&lt;style&gt;
.codeblock {
position: relative;
margin: 1.4em 0;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
background: #272822;
}
.codeblock-label {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
font-size: 0.8rem;
color: rgba(255, 255, 255, 0.7);
}
.codeblock-icon {
align-items: center;
width: 14px;
height: 14px;
flex-shrink: 0;
opacity: 0.85;
fill: rgba(255, 255, 255, 0.7);
}
.codeblock-copybtn {
position: absolute;
top: 0px;
right: 0px;
background: transparent;
color: rgba(255, 255, 255, 0.5);
cursor: pointer;
}
.codeblock-copybtn:hover {
color: rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.08);
}
.codeblock-copybtn-icon {
margin-right: 4px;
}
&lt;/style&gt;
&lt;div class="codeblock"&gt;
&lt;div class="codeblock-label"&gt;
&lt;span class="codeblock-icon"&gt;&lt;style&gt;
.icon svg {
width: 14px;
height: 14px;
fill: rgba(255, 255, 255, 0.7);
}
&lt;/style&gt;&lt;span class="icon"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Python&lt;/title&gt;&lt;path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;oneorzero.py&lt;/span&gt;
&lt;/div&gt;
&lt;div class="codeblock-body"&gt;
&lt;button class="codeblock-copybtn"&gt;
&lt;span class="codeblock-copybtn-icon"&gt;
&lt;svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
width="16"
&gt;
&lt;path
stroke-linecap="round"
stroke-linejoin="round"
d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
/&gt;
&lt;/svg&gt;
&lt;/span&gt;
&lt;span class="codeblock-copybtn-label"&gt;copy&lt;/span&gt;
&lt;/button&gt;&lt;div class="highlight" filename="oneorzero.py"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; random
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(random&lt;span style="color:#f92672"&gt;.&lt;/span&gt;randint(&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#motivation" class="heading"&gt;
&lt;h2 id="motivation"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Motivation
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;I often need codeblocks in my posts, but it&amp;rsquo;s rather inconvenient for anyone following the steps, that until now one couldn&amp;rsquo;t copy the commands right away.&lt;/p&gt;</description><content type="html"><![CDATA[<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#before--after" class="heading">
<h2 id="before--after">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Before &amp; After

</h2>
</a>
<p><img src="codeblock_before.webp" alt="default hugo codeblock"></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Python</title><path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg></span></span>

        <span>oneorzero.py</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="oneorzero.py"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> random
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>print(random<span style="color:#f92672">.</span>randint(<span style="color:#ae81ff">0</span>, <span style="color:#ae81ff">1</span>))</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#motivation" class="heading">
<h2 id="motivation">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Motivation

</h2>
</a>
<p>I often need codeblocks in my posts, but it&rsquo;s rather inconvenient for anyone following the steps, that until now one couldn&rsquo;t copy the commands right away.</p>
<p>Also it would be kinda cool if one could set a filename for a codeblock, to make it clearer which file I&rsquo;m referring to. And maybe a language icon, just because it looks cool</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#basic-structure" class="heading">
<h2 id="basic-structure">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Basic Structure

</h2>
</a>
<p>Create a new file in your hugo folder: <code>layouts/_default/_markup/render-codeblock.html</code></p>
<p>and add this line to your hugo conf:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Hugo</title><path d="M11.754 0a3.998 3.998 0 00-2.049.596L3.33 4.532a4.252 4.252 0 00-2.017 3.615v8.03c0 1.473.79 2.838 2.067 3.574l6.486 3.733a3.88 3.88 0 003.835.018l7.043-3.966a3.817 3.817 0 001.943-3.323V7.752a3.57 3.57 0 00-1.774-3.084L13.817.541a3.998 3.998 0 00-2.063-.54zm.022 1.674c.413-.006.828.1 1.2.315l7.095 4.127c.584.34.941.96.94 1.635v8.462c0 .774-.414 1.484-1.089 1.864l-7.042 3.966a2.199 2.199 0 01-2.179-.01l-6.485-3.734a2.447 2.447 0 01-1.228-2.123v-8.03c0-.893.461-1.72 1.221-2.19l6.376-3.935a2.323 2.323 0 011.19-.347zm-4.7 3.844V18.37h2.69v-5.62h4.46v5.62h2.696V5.518h-2.696v4.681h-4.46V5.518Z"/></svg></span></span>

        <span>hugo.toml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="hugo.toml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#a6e22e">markup</span>.<span style="color:#a6e22e">goldmark</span>.<span style="color:#a6e22e">renderer</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">unsafe</span> = <span style="color:#66d9ef">true</span></span></span></code></pre></div>
    </div>
</div>
<p>this allows hugo to render javascript too, which we need for the copy button to work</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#filename-support" class="heading">
<h2 id="filename-support">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Filename Support

</h2>
</a>
<p>This is one of the easier steps:</p>
<p>I want to pass the filename via sth like:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-md" data-lang="md"><span style="display:flex;"><span>``<span style="color:#e6db74">`python {filename=&#34;oneorzero.py&#34;}
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">...
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>``</span></span></code></pre></div>
    </div>
</div>
<p>as this would follow the default syntax for options in codeblocks, like highlighting lines etc.</p>
<p>So lets first introduce a new attribute called filename, and if doesn&rsquo;t exist, fall back to the title attribute (so if one just uses <code>title=&quot;...&quot;</code> it would also work)</p>
<p>Next lets wrap the default codeblock in a div and and add our own label ahead of it and give it some styling, the full version now looks sth like this (note that the colors match the default syntax highlighting theme, if you want a different color variation, change them accordingly):</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>{{- $label := .Attributes.filename | default .Attributes.title -}}</span></span></code></pre></div>
    </div>
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>HTML5</title><path d="M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0zm7.031 9.75l-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531z"/></svg></span></span>

        <span>layouts/_default/_markup/render-codeblock.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/_default/_markup/render-codeblock.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>{{- $label := .Attributes.filename | default .Attributes.title -}}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">margin</span>: <span style="color:#ae81ff">1.4</span><span style="color:#66d9ef">em</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border</span>: <span style="color:#ae81ff">1</span><span style="color:#66d9ef">px</span> <span style="color:#66d9ef">solid</span> rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.1</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border-radius</span>: <span style="color:#ae81ff">8</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">background</span>: <span style="color:#ae81ff">#272822</span>; <span style="color:#75715e">/* default theme (mokai?) color */</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-label</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">8</span><span style="color:#66d9ef">px</span> <span style="color:#ae81ff">12</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border-bottom</span>: <span style="color:#ae81ff">1</span><span style="color:#66d9ef">px</span> <span style="color:#66d9ef">solid</span> rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.1</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">0.8</span><span style="color:#66d9ef">rem</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.7</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  {{ if $label }}
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-label&#34;</span>&gt;{{ $label }}&lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>  {{ end }}
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-body&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    {{- (transform.HighlightCodeBlock .).Wrapped }}
</span></span><span style="display:flex;"><span>  &lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#copy-button" class="heading">
<h2 id="copy-button">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Copy Button

</h2>
</a>
<p>The copy button should be on the top right, so lets add it:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-css" data-lang="css"><span style="display:flex;"><span>.<span style="color:#a6e22e">codeblock-copybtn</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">position</span>: <span style="color:#66d9ef">absolute</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">top</span>: <span style="color:#ae81ff">0</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">right</span>: <span style="color:#ae81ff">0</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">background</span>: <span style="color:#66d9ef">transparent</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.5</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">cursor</span>: <span style="color:#66d9ef">pointer</span>;
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>.<span style="color:#a6e22e">codeblock-copybtn</span>:<span style="color:#a6e22e">hover</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.9</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">background</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.08</span>);
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>.<span style="color:#a6e22e">codeblock-copybtn-icon</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">margin-right</span>: <span style="color:#ae81ff">4</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-body&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">button</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">onclick</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;navigator.clipboard.writeText(&#39;{{ .Inner }}&#39;)&#34;</span>
</span></span><span style="display:flex;"><span>  &gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn-icon&#34;</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;<span style="color:#f92672">svg</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">xmlns</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://www.w3.org/2000/svg&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">fill</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;none&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">viewBox</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;0 0 24 24&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">stroke-width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1.5&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">stroke</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;currentColor&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;16&#34;</span>
</span></span><span style="display:flex;"><span>      &gt;
</span></span><span style="display:flex;"><span>        &lt;<span style="color:#f92672">path</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">stroke-linecap</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">stroke-linejoin</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">d</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184&#34;</span>
</span></span><span style="display:flex;"><span>        /&gt;
</span></span><span style="display:flex;"><span>      &lt;/<span style="color:#f92672">svg</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn-label&#34;</span>&gt;copy&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;/<span style="color:#f92672">button</span>&gt;
</span></span><span style="display:flex;"><span>  {{- (transform.HighlightCodeBlock .).Wrapped }}
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<p>This just copies it to the clipboard with no visual indicator, so lets change this and add a proper function</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">button</span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn&#34;</span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#a6e22e">onclick</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;copyText(this, &#39;{{ .Inner }}&#39;)&#34;</span>
</span></span><span style="display:flex;"><span>&gt;&lt;/<span style="color:#f92672">button</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">script</span>&gt;
</span></span><span style="display:flex;"><span>  window.<span style="color:#a6e22e">copyText</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>    window.<span style="color:#a6e22e">copyText</span> <span style="color:#f92672">||</span>
</span></span><span style="display:flex;"><span>    ((<span style="color:#a6e22e">btn</span>, <span style="color:#a6e22e">text</span>) =&gt; {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">navigator</span>.<span style="color:#a6e22e">clipboard</span>.<span style="color:#a6e22e">writeText</span>(<span style="color:#a6e22e">text</span>).<span style="color:#a6e22e">then</span>(() =&gt; {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">label</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">btn</span>.<span style="color:#a6e22e">querySelector</span>(<span style="color:#e6db74">&#34;.codeblock-copybtn-label&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">icon</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">btn</span>.<span style="color:#a6e22e">querySelector</span>(<span style="color:#e6db74">&#34;.codeblock-copybtn-icon&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">label</span>.<span style="color:#a6e22e">textContent</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;Copied!&#34;</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">icon</span>.<span style="color:#a6e22e">innerHTML</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#39;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; fill=&#34;none&#34; viewBox=&#34;0 0 24 24&#34; stroke-width=&#34;1.5&#34; stroke=&#34;currentColor&#34; width=&#34;16&#34;&gt;&lt;path stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; d=&#34;M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75&#34; /&gt;&lt;/svg&gt;&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">setTimeout</span>(() =&gt; {
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">label</span>.<span style="color:#a6e22e">textContent</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;copy&#34;</span>;
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">icon</span>.<span style="color:#a6e22e">innerHTML</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; fill=&#34;none&#34; viewBox=&#34;0 0 24 24&#34; stroke-width=&#34;1.5&#34; stroke=&#34;currentColor&#34; width=&#34;16&#34;&gt; &lt;path stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; d=&#34;M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184&#34; /&gt; &lt;/svg&gt;&#39;</span>;
</span></span><span style="display:flex;"><span>        }, <span style="color:#ae81ff">2500</span>);
</span></span><span style="display:flex;"><span>      });
</span></span><span style="display:flex;"><span>    });
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">script</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<p>(SVG&rsquo;s are btw from <a href="https://heroicons.com/" target="_blank" rel="noopener">Heroic Icons</a>)</p>
<p><em>Note: this weird <code>window.</code> stuff is so, that the function is defined only once when there are multiple codeblocks in one page</em></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#language-icon" class="heading">
<h2 id="language-icon">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Language Icon

</h2>
</a>
<p>For this we create a new file <code>layouts/partials/codeblock-icons.html</code></p>
<p>At the top we have a dict with all icons we support, you can take the svgs from <a href="https://simpleicons.org/?q=python" target="_blank" rel="noopener">Simple Icons</a>, for now I only added a nix &amp; python icon, you can add more if you need.</p>
<p>If there is no icon, it should default to a generic code icon.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/partials/codeblock-icons.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/partials/codeblock-icons.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#a6e22e">$icons</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">dict</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;nix&#34;</span> <span style="color:#e6db74">`&lt;svg role=&#34;img&#34; viewBox=&#34;0 0 24 24&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&lt;title&gt;NixOS&lt;/title&gt;&lt;path d=&#34;M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z&#34;/&gt;&lt;/svg&gt;`</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;python&#34;</span> <span style="color:#e6db74">`&lt;svg role=&#34;img&#34; viewBox=&#34;0 0 24 24&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&lt;title&gt;Python&lt;/title&gt;&lt;path d=&#34;M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z&#34;/&gt;&lt;/svg&gt;`</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">-}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">with</span> <span style="color:#66d9ef">index</span> <span style="color:#a6e22e">$icons</span> <span style="color:#f92672">(</span><span style="color:#a6e22e">.</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">lower</span><span style="color:#f92672">)</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-icon&#34;</span>&gt;<span style="color:#75715e">{{-</span> <span style="color:#a6e22e">.</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">safeHTML</span> <span style="color:#75715e">}}</span>&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">else</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">svg</span> <span style="color:#a6e22e">xmlns</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://www.w3.org/2000/svg&#34;</span> <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;14&#34;</span> <span style="color:#a6e22e">height</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;14&#34;</span> <span style="color:#a6e22e">viewBox</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;0 0 24 24&#34;</span> <span style="color:#a6e22e">fill</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;none&#34;</span> <span style="color:#a6e22e">stroke</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;currentColor&#34;</span> <span style="color:#a6e22e">stroke-width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2&#34;</span> <span style="color:#a6e22e">stroke-linecap</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span> <span style="color:#a6e22e">stroke-linejoin</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>&gt;&lt;<span style="color:#f92672">polyline</span> <span style="color:#a6e22e">points</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;16 18 22 12 16 6&#34;</span>&gt;&lt;/<span style="color:#f92672">polyline</span>&gt;&lt;<span style="color:#f92672">polyline</span> <span style="color:#a6e22e">points</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;8 6 2 12 8 18&#34;</span>&gt;&lt;/<span style="color:#f92672">polyline</span>&gt;&lt;/<span style="color:#f92672">svg</span>&gt;
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span></span></span></code></pre></div>
    </div>
</div>
<p>next change in our <code>render-codeblock.html</code> the label section:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-html" data-lang="html"><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-label&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  {{ partial &#34;codeblock-icons.html&#34; .Type }}
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">span</span>&gt;{{ $label }}&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<p>and add / change some styling (or the icons will be really big):</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;display:grid;"><code class="language-css" data-lang="css"><span style="display:flex;"><span>.<span style="color:#a6e22e">codeblock-label</span> {
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">flex</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">gap</span>: <span style="color:#ae81ff">10</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">8</span><span style="color:#66d9ef">px</span> <span style="color:#ae81ff">12</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">border-bottom</span>: <span style="color:#ae81ff">1</span><span style="color:#66d9ef">px</span> <span style="color:#66d9ef">solid</span> rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.1</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">0.8</span><span style="color:#66d9ef">rem</span>;
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.7</span>);
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex; background-color:#3c3d38"><span>.<span style="color:#a6e22e">codeblock-icon</span> {
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">width</span>: <span style="color:#ae81ff">14</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">height</span>: <span style="color:#ae81ff">14</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">flex-shrink</span>: <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">opacity</span>: <span style="color:#ae81ff">0.85</span>;
</span></span><span style="display:flex; background-color:#3c3d38"><span>  <span style="color:#66d9ef">fill</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.7</span>);
</span></span><span style="display:flex; background-color:#3c3d38"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#everything-together" class="heading">
<h2 id="everything-together">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Everything Together

</h2>
</a>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/_default/_markup/render-codeblock.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/_default/_markup/render-codeblock.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#a6e22e">$label</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">.Attributes.filename</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">default</span> <span style="color:#a6e22e">.Attributes.title</span> <span style="color:#75715e">-}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">position</span>: <span style="color:#66d9ef">relative</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">margin</span>: <span style="color:#ae81ff">1.4</span><span style="color:#66d9ef">em</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border</span>: <span style="color:#ae81ff">1</span><span style="color:#66d9ef">px</span> <span style="color:#66d9ef">solid</span> rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.1</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border-radius</span>: <span style="color:#ae81ff">8</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">background</span>: <span style="color:#ae81ff">#272822</span>; <span style="color:#75715e">/* default theme (mokai?) color */</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-label</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">flex</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">gap</span>: <span style="color:#ae81ff">10</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">8</span><span style="color:#66d9ef">px</span> <span style="color:#ae81ff">12</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">border-bottom</span>: <span style="color:#ae81ff">1</span><span style="color:#66d9ef">px</span> <span style="color:#66d9ef">solid</span> rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.1</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">0.8</span><span style="color:#66d9ef">rem</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.7</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-icon</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">width</span>: <span style="color:#ae81ff">14</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">height</span>: <span style="color:#ae81ff">14</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">flex-shrink</span>: <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">opacity</span>: <span style="color:#ae81ff">0.85</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">fill</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.7</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-copybtn</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">position</span>: <span style="color:#66d9ef">absolute</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">top</span>: <span style="color:#ae81ff">0</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">right</span>: <span style="color:#ae81ff">0</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">background</span>: <span style="color:#66d9ef">transparent</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.5</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">cursor</span>: <span style="color:#66d9ef">pointer</span>;
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-copybtn</span>:<span style="color:#a6e22e">hover</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">color</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.9</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">background</span>: rgba(<span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">255</span>, <span style="color:#ae81ff">0.08</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  .<span style="color:#a6e22e">codeblock-copybtn-icon</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">margin-right</span>: <span style="color:#ae81ff">4</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">{{</span> <span style="color:#66d9ef">if</span> <span style="color:#a6e22e">$label</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-label&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">{{</span> <span style="color:#a6e22e">partial</span> <span style="color:#e6db74">&#34;codeblock-icons.html&#34;</span> <span style="color:#a6e22e">.Type</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">span</span>&gt;<span style="color:#75715e">{{</span> <span style="color:#a6e22e">$label</span> <span style="color:#75715e">}}</span>&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">{{</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>  &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-body&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">button</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn&#34;</span> <span style="color:#a6e22e">onclick</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;copyText(this, &#39;</span><span style="color:#75715e">{{</span> <span style="color:#a6e22e">.Inner</span> <span style="color:#75715e">}}</span><span style="color:#e6db74">&#39;)&#34;</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn-icon&#34;</span>&gt;
</span></span><span style="display:flex;"><span>        &lt;<span style="color:#f92672">svg</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">xmlns</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://www.w3.org/2000/svg&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">fill</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;none&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">viewBox</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;0 0 24 24&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">stroke-width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1.5&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">stroke</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;currentColor&#34;</span>
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;16&#34;</span>
</span></span><span style="display:flex;"><span>        &gt;
</span></span><span style="display:flex;"><span>          &lt;<span style="color:#f92672">path</span>
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">stroke-linecap</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">stroke-linejoin</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">d</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184&#34;</span>
</span></span><span style="display:flex;"><span>          /&gt;
</span></span><span style="display:flex;"><span>        &lt;/<span style="color:#f92672">svg</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-copybtn-label&#34;</span>&gt;copy&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;/<span style="color:#f92672">button</span>&gt;
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">{{-</span> <span style="color:#f92672">(</span><span style="color:#a6e22e">transform</span><span style="color:#a6e22e">.HighlightCodeBlock</span> <span style="color:#a6e22e">.</span><span style="color:#f92672">)</span><span style="color:#a6e22e">.Wrapped</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>  &lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">div</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">script</span>&gt;
</span></span><span style="display:flex;"><span>  window.<span style="color:#a6e22e">copyText</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>    window.<span style="color:#a6e22e">copyText</span> <span style="color:#f92672">||</span>
</span></span><span style="display:flex;"><span>    ((<span style="color:#a6e22e">btn</span>, <span style="color:#a6e22e">text</span>) =&gt; {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">navigator</span>.<span style="color:#a6e22e">clipboard</span>.<span style="color:#a6e22e">writeText</span>(<span style="color:#a6e22e">text</span>).<span style="color:#a6e22e">then</span>(() =&gt; {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">label</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">btn</span>.<span style="color:#a6e22e">querySelector</span>(<span style="color:#e6db74">&#34;.codeblock-copybtn-label&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">icon</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">btn</span>.<span style="color:#a6e22e">querySelector</span>(<span style="color:#e6db74">&#34;.codeblock-copybtn-icon&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">label</span>.<span style="color:#a6e22e">textContent</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;Copied!&#34;</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">icon</span>.<span style="color:#a6e22e">innerHTML</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#39;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; fill=&#34;none&#34; viewBox=&#34;0 0 24 24&#34; stroke-width=&#34;1.5&#34; stroke=&#34;currentColor&#34; width=&#34;16&#34;&gt;&lt;path stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; d=&#34;M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0 1 18 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3 1.5 1.5 3-3.75&#34; /&gt;&lt;/svg&gt;&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">setTimeout</span>(() =&gt; {
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">label</span>.<span style="color:#a6e22e">textContent</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;copy&#34;</span>;
</span></span><span style="display:flex;"><span>          <span style="color:#a6e22e">icon</span>.<span style="color:#a6e22e">innerHTML</span> <span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34; fill=&#34;none&#34; viewBox=&#34;0 0 24 24&#34; stroke-width=&#34;1.5&#34; stroke=&#34;currentColor&#34; width=&#34;16&#34;&gt; &lt;path stroke-linecap=&#34;round&#34; stroke-linejoin=&#34;round&#34; d=&#34;M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184&#34; /&gt; &lt;/svg&gt;&#39;</span>;
</span></span><span style="display:flex;"><span>        }, <span style="color:#ae81ff">2500</span>);
</span></span><span style="display:flex;"><span>      });
</span></span><span style="display:flex;"><span>    });
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">script</span>&gt;</span></span></code></pre></div>
    </div>
</div>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg></span></span>

        <span>layouts/partials/codeblock-icons.html</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="layouts/partials/codeblock-icons.html"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-go-html-template" data-lang="go-html-template"><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#a6e22e">$icons</span> <span style="color:#f92672">:=</span> <span style="color:#a6e22e">dict</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;nix&#34;</span> <span style="color:#e6db74">`&lt;svg role=&#34;img&#34; viewBox=&#34;0 0 24 24&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&lt;title&gt;NixOS&lt;/title&gt;&lt;path d=&#34;M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z&#34;/&gt;&lt;/svg&gt;`</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;python&#34;</span> <span style="color:#e6db74">`&lt;svg role=&#34;img&#34; viewBox=&#34;0 0 24 24&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&lt;title&gt;Python&lt;/title&gt;&lt;path d=&#34;M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z&#34;/&gt;&lt;/svg&gt;`</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;sh&#34;</span> <span style="color:#e6db74">`&lt;svg role=&#34;img&#34; viewBox=&#34;0 0 24 24&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&lt;title&gt;GNU Bash&lt;/title&gt;&lt;path d=&#34;M21.038,4.9l-7.577-4.498C13.009,0.134,12.505,0,12,0c-0.505,0-1.009,0.134-1.462,0.403L2.961,4.9 C2.057,5.437,1.5,6.429,1.5,7.503v8.995c0,1.073,0.557,2.066,1.462,2.603l7.577,4.497C10.991,23.866,11.495,24,12,24 c0.505,0,1.009-0.134,1.461-0.402l7.577-4.497c0.904-0.537,1.462-1.529,1.462-2.603V7.503C22.5,6.429,21.943,5.437,21.038,4.9z M15.17,18.946l0.013,0.646c0.001,0.078-0.05,0.167-0.111,0.198l-0.383,0.22c-0.061,0.031-0.111-0.007-0.112-0.085L14.57,19.29 c-0.328,0.136-0.66,0.169-0.872,0.084c-0.04-0.016-0.057-0.075-0.041-0.142l0.139-0.584c0.011-0.046,0.036-0.092,0.069-0.121 c0.012-0.011,0.024-0.02,0.036-0.026c0.022-0.011,0.043-0.014,0.062-0.006c0.229,0.077,0.521,0.041,0.802-0.101 c0.357-0.181,0.596-0.545,0.592-0.907c-0.003-0.328-0.181-0.465-0.613-0.468c-0.55,0.001-1.064-0.107-1.072-0.917 c-0.007-0.667,0.34-1.361,0.889-1.8l-0.007-0.652c-0.001-0.08,0.048-0.168,0.111-0.2l0.37-0.236 c0.061-0.031,0.111,0.007,0.112,0.087l0.006,0.653c0.273-0.109,0.511-0.138,0.726-0.088c0.047,0.012,0.067,0.076,0.048,0.151 l-0.144,0.578c-0.011,0.044-0.036,0.088-0.065,0.116c-0.012,0.012-0.025,0.021-0.038,0.028c-0.019,0.01-0.038,0.013-0.057,0.009 c-0.098-0.022-0.332-0.073-0.699,0.113c-0.385,0.195-0.52,0.53-0.517,0.778c0.003,0.297,0.155,0.387,0.681,0.396 c0.7,0.012,1.003,0.318,1.01,1.023C16.105,17.747,15.736,18.491,15.17,18.946z M19.143,17.859c0,0.06-0.008,0.116-0.058,0.145 l-1.916,1.164c-0.05,0.029-0.09,0.004-0.09-0.056v-0.494c0-0.06,0.037-0.093,0.087-0.122l1.887-1.129 c0.05-0.029,0.09-0.004,0.09,0.056V17.859z M20.459,6.797l-7.168,4.427c-0.894,0.523-1.553,1.109-1.553,2.187v8.833 c0,0.645,0.26,1.063,0.66,1.184c-0.131,0.023-0.264,0.039-0.398,0.039c-0.42,0-0.833-0.114-1.197-0.33L3.226,18.64 c-0.741-0.44-1.201-1.261-1.201-2.142V7.503c0-0.881,0.46-1.702,1.201-2.142l7.577-4.498c0.363-0.216,0.777-0.33,1.197-0.33 c0.419,0,0.833,0.114,1.197,0.33l7.577,4.498c0.624,0.371,1.046,1.013,1.164,1.732C21.686,6.557,21.12,6.411,20.459,6.797z&#34;/&gt;&lt;/svg&gt;`</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">-}}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">with</span> <span style="color:#66d9ef">index</span> <span style="color:#a6e22e">$icons</span> <span style="color:#f92672">(</span><span style="color:#a6e22e">.</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">lower</span><span style="color:#f92672">)</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">class</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;codeblock-icon&#34;</span>&gt;<span style="color:#75715e">{{-</span> <span style="color:#a6e22e">.</span> <span style="color:#f92672">|</span> <span style="color:#a6e22e">safeHTML</span> <span style="color:#75715e">}}</span>&lt;/<span style="color:#f92672">span</span>&gt;
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">else</span> <span style="color:#75715e">}}</span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">svg</span> <span style="color:#a6e22e">xmlns</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://www.w3.org/2000/svg&#34;</span> <span style="color:#a6e22e">width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;14&#34;</span> <span style="color:#a6e22e">height</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;14&#34;</span> <span style="color:#a6e22e">viewBox</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;0 0 24 24&#34;</span> <span style="color:#a6e22e">fill</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;none&#34;</span> <span style="color:#a6e22e">stroke</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;currentColor&#34;</span> <span style="color:#a6e22e">stroke-width</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;2&#34;</span> <span style="color:#a6e22e">stroke-linecap</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span> <span style="color:#a6e22e">stroke-linejoin</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;round&#34;</span>&gt;&lt;<span style="color:#f92672">polyline</span> <span style="color:#a6e22e">points</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;16 18 22 12 16 6&#34;</span>&gt;&lt;/<span style="color:#f92672">polyline</span>&gt;&lt;<span style="color:#f92672">polyline</span> <span style="color:#a6e22e">points</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;8 6 2 12 8 18&#34;</span>&gt;&lt;/<span style="color:#f92672">polyline</span>&gt;&lt;/<span style="color:#f92672">svg</span>&gt;
</span></span><span style="display:flex;"><span><span style="color:#75715e">{{-</span> <span style="color:#66d9ef">end</span> <span style="color:#75715e">}}</span></span></span></code></pre></div>
    </div>
</div>
]]></content></item><item><title>RSS is Awesome!</title><link>https://catinashell.de/posts/rss-is-awesome/</link><pubDate>Mon, 29 Jun 2026 10:17:52 +0200</pubDate><guid>https://catinashell.de/posts/rss-is-awesome/</guid><description>&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#what-is-rss" class="heading"&gt;
&lt;h3 id="what-is-rss"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
What is RSS?
&lt;/h3&gt;
&lt;/a&gt;
&lt;p&gt;Its a format for website feed, basically like a social media timeline for only the stuff the website wants to post there (one site can also have multiple feeds, like one per category etc.).
So lets say you subscribe to &lt;a href="https://nixos.org/blog/announcements-rss.xml" target="_blank" rel="noopener"&gt;NixOS Announcement Feed&lt;/a&gt;, whenever they write a new announcement post they also (automatically probably) create an entry in their rss feed.&lt;/p&gt;</description><content type="html"><![CDATA[<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#what-is-rss" class="heading">
<h3 id="what-is-rss">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    What is RSS?

</h3>
</a>
<p>Its a format for website feed, basically like a social media timeline for only the stuff the website wants to post there (one site can also have multiple feeds, like one per category etc.).
So lets say you subscribe to <a href="https://nixos.org/blog/announcements-rss.xml" target="_blank" rel="noopener">NixOS Announcement Feed</a>, whenever they write a new announcement post they also (automatically probably) create an entry in their rss feed.</p>
<p>Now you have a rss reader app (aggregator, e.g. <a href="https://github.com/spacecowboy/Feeder" target="_blank" rel="noopener">Feeder</a> for Android) and subscribe to their feed, and get all their news in that app, instead of having to check their website each time or subscribe to a newsletter.
It&rsquo;s basically like <strong>creating your personal news feed, filled with only the stuff you want to see</strong>, no random suggestions etc.</p>
<p>Many of the leading news agencies etc. have their own rss feed, there is one for github releases, youtube channels etc. whatever you like.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#advantages" class="heading">
<h3 id="advantages">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Advantages

</h3>
</a>
<ul>
<li>you don&rsquo;t have to open sites to see if they have new content (<strong>everything at one place</strong>)</li>
<li>you don&rsquo;t have to give anyone your email (like in a newsletter)</li>
<li>its <strong>private by design</strong>, no javascript is run on your device</li>
<li><strong>no ads</strong> (except if they are embedded into the articles)</li>
<li><strong>no distracting recommendations</strong>, or badly formated stuff &hellip;, everything like in the fast reader view from the browser.</li>
<li><strong>never miss sth</strong>, as you&rsquo;ll always see all the content you subscribed to and not only what any algorithm wants you to see</li>
</ul>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#this-blog-also-has-an-rss-feed" class="heading">
<h3 id="this-blog-also-has-an-rss-feed">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    This blog also has an RSS Feed

</h3>
</a>
<p><a href="https://catinashell.de/posts/index.xml" target="_blank" rel="noopener">Cat in a Shell RSS Feed</a>, you can add it to your chosen RSS Reader and never miss any new blog post I&rsquo;m writing.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#how-to-find-more-feeds" class="heading">
<h3 id="how-to-find-more-feeds">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    How to find more feeds?

</h3>
</a>
<p>This icon means often rss feed:
<img src="rss_icon.webp" alt="rss icon"></p>
<p>You can find it on many popular sites.</p>
<p>Also there are some currated lists, showing some popular rss feeds, like <a href="https://github.com/plenaryapp/awesome-rss-feeds" target="_blank" rel="noopener">this awesome-rss-feeds github repo</a></p>
]]></content></item><item><title>Secure a Caddy Server &amp; Best Practices</title><link>https://catinashell.de/posts/secure-a-caddy-server-and-best-practices/</link><pubDate>Sun, 28 Jun 2026 11:14:58 +0200</pubDate><guid>https://catinashell.de/posts/secure-a-caddy-server-and-best-practices/</guid><description>&lt;p&gt;I currently use &lt;a href="https://caddyserver.com/" target="_blank" rel="noopener"&gt;Caddy&lt;/a&gt; for the statically generated Hugo Blog, since Caddy seems like a robust webserver written in go (so memory safe) and rather fast. Also it handles https automatically, requesting certificates etc. so no longer having to run anything manually.
Also its pretty easy to configure for this use case&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#minimal-caddy-config" class="heading"&gt;
&lt;h4 id="minimal-caddy-config"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Minimal Caddy Config
&lt;/h4&gt;
&lt;/a&gt;
&lt;style&gt;
.codeblock {
position: relative;
margin: 1.4em 0;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
background: #272822;
}
.codeblock-label {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
font-size: 0.8rem;
color: rgba(255, 255, 255, 0.7);
}
.codeblock-icon {
align-items: center;
width: 14px;
height: 14px;
flex-shrink: 0;
opacity: 0.85;
fill: rgba(255, 255, 255, 0.7);
}
.codeblock-copybtn {
position: absolute;
top: 0px;
right: 0px;
background: transparent;
color: rgba(255, 255, 255, 0.5);
cursor: pointer;
}
.codeblock-copybtn:hover {
color: rgba(255, 255, 255, 0.9);
background: rgba(255, 255, 255, 0.08);
}
.codeblock-copybtn-icon {
margin-right: 4px;
}
&lt;/style&gt;
&lt;div class="codeblock"&gt;
&lt;div class="codeblock-body"&gt;
&lt;button class="codeblock-copybtn"&gt;
&lt;span class="codeblock-copybtn-icon"&gt;
&lt;svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
width="16"
&gt;
&lt;path
stroke-linecap="round"
stroke-linejoin="round"
d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
/&gt;
&lt;/svg&gt;
&lt;/span&gt;
&lt;span class="codeblock-copybtn-label"&gt;copy&lt;/span&gt;
&lt;/button&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-caddyfile" data-lang="caddyfile"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;catinashell.de {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;root&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;*&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/var/www/blog/public&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;file_server&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;this is a pretty basic working example, you generate the content via &lt;code&gt;hugo&lt;/code&gt; inside &lt;code&gt;/var/www/blog&lt;/code&gt;, move ownership to caddy &lt;code&gt;chown -R caddy:caddy /var/www/blog&lt;/code&gt; and done.&lt;/p&gt;</description><content type="html"><![CDATA[<p>I currently use <a href="https://caddyserver.com/" target="_blank" rel="noopener">Caddy</a> for the statically generated Hugo Blog, since Caddy seems like a robust webserver written in go (so memory safe) and rather fast. Also it handles https automatically, requesting certificates etc. so no longer having to run anything manually.
Also its pretty easy to configure for this use case</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#minimal-caddy-config" class="heading">
<h4 id="minimal-caddy-config">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Minimal Caddy Config

</h4>
</a>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">root</span> <span style="color:#a6e22e">*</span> <span style="color:#e6db74">/var/www/blog/public</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">file_server</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>this is a pretty basic working example, you generate the content via <code>hugo</code> inside <code>/var/www/blog</code>, move ownership to caddy <code>chown -R caddy:caddy /var/www/blog</code> and done.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#improving-the-config" class="heading">
<h2 id="improving-the-config">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Improving the Config

</h2>
</a>
<p>Well but this isn&rsquo;t enough, like I also want <strong>HSTS</strong> to be enabled (preventing dropping the connection from https to http), have a <strong>content-security-policy</strong>, allowing only resources from my own server. Redirecting invalid routes to the <strong>404</strong>.html site, etc.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#security-headers--their-explanations" class="heading">
<h4 id="security-headers--their-explanations">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Security Headers (&amp; their Explanations)

</h4>
</a>
<p>This is probably the most important part, adding a few security Headers for:</p>
<ul>
<li>HSTS</li>
<li>Content-Security-Policy</li>
<li>Referrer Policy</li>
<li>Removing some Information Headers in the Response</li>
<li>Disabling the site to be embeded as an iframe.</li>
</ul>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">...</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">header</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Strict-Transport-Security</span> <span style="color:#e6db74">&#34;max-age=31536000; includeSubDomains; preload&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Content-Security-Policy</span> <span style="color:#e6db74">&#34;default-src &#39;self&#39;; script-src &#39;self&#39;; style-src &#39;self&#39; &#39;unsafe-inline&#39;; object-src &#39;none&#39;; frame-src &#39;none&#39;; base-uri &#39;self&#39;; frame-ancestors &#39;none&#39;; upgrade-insecure-requests&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Referrer-Policy</span> <span style="color:#e6db74">strict-origin-when-cross-origin</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">X-Content-Type-Options</span> <span style="color:#e6db74">nosniff</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">X-Frame-Options</span> <span style="color:#e6db74">DENY</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">-X-Powered-By</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">-Server</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p><strong>Strict-Transport-Security</strong>: This is the HSTS header, telling the browser, that it should only connect via https in the future, and don&rsquo;t use http ever. This prevents protcol downgrading attacks (https -&gt; http)</p>
<p><strong>Content-Security-Policy</strong>: Tells the browser to only load resources from the specified origins, lets say an evil attacker manages to embed a malicious <code>&lt;script&gt;</code> tag inside the site, or load a script via <code>&lt;script src=&quot;https://evil.org/evil.js&quot;&gt;</code>. The browser won&rsquo;t run these scripts with the shown policy, as it only loads js from my own page.
This also blocks the site to be embeded as an iframe via <code>frame-ancestors 'none'</code>, tells the browser to upgrade connections &amp; blocks some legacy plugins via <code>onject-src 'none'</code></p>
<p><strong>Referrer-Policy</strong>: <code>strict-origin-when-cross-origin</code>, this means, that if you click on an external link the opened site will only see that you came from <code>https://catinashell.de</code>, not that you came from <code>https://catinashell.de/posts/caddy-security/</code>.</p>
<p><strong>X-Content-Type-Options</strong>: <code>nosniff</code> tells the browser to not try guessing the mime type of resources found, as this could in certain cases be exploited, e.g. you have a .txt file on your server, containing js code, this should only be treatened as a txt file, but the browser might guess from the content its js and execute it. This is mostly relevant if you let users upload content, still best practice.</p>
<p><strong>X-Frame-Options</strong>: <code>DENY</code> tells browsers here again, to not allow this site to be embedded as an iframe, protecting against click jacking attacks.</p>
<p><strong>-X-Powered-By</strong> &amp; <strong>-Server</strong>: This ommits these Headers in the response, giving a potential attacker less information about the server. Well for this blog it&rsquo;s kinda irrelevant, as my whole stack can be easily figured out by reading the About Section + this post xD.
But it might hinder automatic vuln scans a bit at least. Its clearly not a complete shield against any analysis of your stack. There are tons of ways to figure this out (just analyse the link structures, which scripts run etc. lets you easily figure out, that this site was generated with Hugo, potentially due to changes over time also the version (or at least version range)).</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#disable-admin-endpoint" class="heading">
<h4 id="disable-admin-endpoint">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Disable Admin Endpoint

</h4>
</a>
<p>The first easy fix is disabling the admin endpoint, reachable on localhost:2019, this initself, doesn&rsquo;t seem like a big security risk. But lets say an attacker manages to trick the server into making a request to itself, they could access the endpoint. Loading a different config, maybe redirecting all visitors to an evil host (well this wouldn&rsquo;t happen so easily on a pure caddy fileserver and no other services running, but still, best practice is best practice).</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">admin</span> <span style="color:#66d9ef">off</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#encodings" class="heading">
<h4 id="encodings">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Encodings

</h4>
</a>
<p>This allows compressing the transmitted pages, increasing loading speed. An easy gain. <em>zstd</em> should be the standard in modern browsers, and for older ones <em>gzip</em> works as a fallback.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">...</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">encode</span> <span style="color:#e6db74">zstd</span> <span style="color:#e6db74">gzip</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#not-found-should-display-the-404html-page" class="heading">
<h4 id="not-found-should-display-the-404html-page">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Not Found should display the 404.html page

</h4>
</a>
<p>Achieved by:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">...</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">handle_errors</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">@404</span> <span style="color:#66d9ef">expression</span> <span style="color:#ae81ff">{http.error.status_code}</span> <span style="color:#e6db74">==</span> <span style="color:#ae81ff">404</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">rewrite</span> <span style="color:#a6e22e">@404</span> <span style="color:#e6db74">/404.html</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">file_server</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p><em>Note: you can also easily handle other errors by changing the error code, e.g. 403, 401, 500 etc.</em> (But for now 404 is enough for me, as I don&rsquo;t have any locked parts, its just a public blog &hellip;, and I don&rsquo;t expect an internal server error in a static webpage)</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#cache-assets" class="heading">
<h4 id="cache-assets">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Cache Assets

</h4>
</a>
<p>You can cache in Caddy Assets easily, first specify with the <code>@static</code> label what are cachable assets (fonts, imaages, js, css). Then set a Cache-Control header for these assets, in my case set to 30 days (in seconds). So if a visitor revists your site, the images won&rsquo;t need to be loaded every time again.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">...</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">@static</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">file</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">path</span> <span style="color:#e6db74">*.ico</span> <span style="color:#e6db74">*.css</span> <span style="color:#e6db74">*.js</span> <span style="color:#e6db74">*.gif</span> <span style="color:#e6db74">*.webp</span> <span style="color:#e6db74">*.avif</span> <span style="color:#e6db74">*.jpg</span> <span style="color:#e6db74">*.jpeg</span> <span style="color:#e6db74">*.png</span> <span style="color:#e6db74">*.svg</span> <span style="color:#e6db74">*.woff</span> <span style="color:#e6db74">*.woff2</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">header</span> <span style="color:#a6e22e">@static</span> <span style="color:#e6db74">Cache-Control</span> <span style="color:#e6db74">max-age=2592000</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#have-wwwdomain-redirect-to-domain" class="heading">
<h4 id="have-wwwdomain-redirect-to-domain">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Have www.domain redirect to domain

</h4>
</a>
<p>I don&rsquo;t see a point in including the www. part, it just makes the domain longer for no reason &hellip; So I like redirecting to the base domain. This can be done by:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>www.catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">redir</span> <span style="color:#e6db74">https://catinashell.de</span><span style="color:#ae81ff">{uri}</span> <span style="color:#e6db74">permanent</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#the-full-config" class="heading">
<h3 id="the-full-config">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    The full config

</h3>
</a>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Caddy</title><path d="M11.094.47c-.842 0-1.696.092-2.552.288a11.37 11.37 0 0 0-4.87 2.423 10.632 10.632 0 0 0-2.36 2.826A10.132 10.132 0 0 0 .305 8.582c-.398 1.62-.4 3.336-.043 5.048.085.405.183.809.31 1.212a11.85 11.85 0 0 0 1.662 3.729 3.273 3.273 0 0 0-.086.427 3.323 3.323 0 0 0 2.848 3.71 3.279 3.279 0 0 0 1.947-.346c1.045.51 2.17.864 3.339 1.04a11.66 11.66 0 0 0 4.285-.155 11.566 11.566 0 0 0 4.936-2.485 10.643 10.643 0 0 0 2.352-2.894 11.164 11.164 0 0 0 1.356-4.424 11.214 11.214 0 0 0-.498-4.335c.175-.077.338-.175.486-.293a.444.444 89.992 0 0 .001 0c.402-.322.693-.794.777-1.342a2.146 2.146 0 0 0-1.79-2.434 2.115 2.115 0 0 0-1.205.171c-.038-.043-.078-.086-.113-.13a11.693 11.693 0 0 0-3.476-2.93 13.348 13.348 0 0 0-1.76-.81 13.55 13.55 0 0 0-2.06-.613A12.121 12.121 0 0 0 11.093.47Zm.714.328c.345-.004.688.01 1.028.042a9.892 9.892 0 0 1 2.743.639c.984.39 1.89.958 2.707 1.632.803.662 1.502 1.45 2.091 2.328.026.039.048.08.07.12a2.12 2.12 0 0 0-.435 2.646c-.158.114-.97.692-1.634 1.183-.414.308-.733.557-.733.557l.581.68s.296-.276.665-.638c.572-.562 1.229-1.233 1.395-1.403a2.122 2.122 0 0 0 1.907.677 11.229 11.229 0 0 1-.013 4.046 11.41 11.41 0 0 1-1.475 3.897 12.343 12.343 0 0 1-2.079 2.587c-1.19 1.125-2.633 2.022-4.306 2.531a10.826 10.826 0 0 1-3.973.484 11.04 11.04 0 0 1-3.057-.652 3.304 3.304 0 0 0 1.417-2.294 3.275 3.275 0 0 0-.294-1.842c.18-.162.403-.363.656-.6 1.015-.955 2.353-2.303 2.353-2.303l-.47-.599s-1.63.972-2.801 1.728c-.307.198-.573.378-.777.517a3.273 3.273 0 0 0-1.516-.611c-1.507-.198-2.927.672-3.487 2.017a10.323 10.323 0 0 1-.695-1.078A10.92 10.92 0 0 1 .728 14.8a10.35 10.35 0 0 1-.2-1.212c-.164-1.653.103-3.258.629-4.754a12.95 12.95 0 0 1 1.087-2.288c.57-.968 1.248-1.872 2.069-2.656A11.013 11.013 0 0 1 11.808.797Zm-.147 3.257a3.838 3.838 0 0 0-3.82 3.82v2.36h-.94c-.751 0-1.377.625-1.377 1.377v3.8h1.46v-3.718h9.354v6.264H10.02v1.46h6.4c.751 0 1.377-.625 1.377-1.377v-6.43c0-.751-.626-1.377-1.377-1.377h-.94v-2.36a3.838 3.838 0 0 0-3.82-3.819zm0 1.46a2.371 2.371 0 0 1 2.36 2.36v2.36H9.3v-2.36a2.372 2.372 0 0 1 2.36-2.36zm10.141.392a1.253 1.253 0 0 1 1.296 1.434c-.049.319-.217.59-.453.78-.266.213-.61.318-.968.264a1.253 1.253 0 0 1-1.045-1.42 1.255 1.255 0 0 1 1.17-1.058zM5.384 17.425a2.02 2.02 0 0 1 1.917 1.298c.116.3.159.628.114.967a2.015 2.015 0 0 1-2.249 1.728 2.016 2.016 0 0 1-1.727-2.25 2.017 2.017 0 0 1 1.945-1.743z"/></svg></span></span>

        <span>/etc/caddy/Caddyfile</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="/etc/caddy/Caddyfile"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-caddyfile" data-lang="caddyfile"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">admin</span> <span style="color:#66d9ef">off</span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>www.catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">redir</span> <span style="color:#e6db74">https://catinashell.de</span><span style="color:#ae81ff">{uri}</span> <span style="color:#e6db74">permanent</span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>catinashell.de {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">root</span> <span style="color:#a6e22e">*</span> <span style="color:#e6db74">/var/www/blog/public</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">file_server</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">encode</span> <span style="color:#e6db74">zstd</span> <span style="color:#e6db74">gzip</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">handle_errors</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">@404</span> <span style="color:#66d9ef">expression</span> <span style="color:#ae81ff">{http.error.status_code}</span> <span style="color:#e6db74">==</span> <span style="color:#ae81ff">404</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">rewrite</span> <span style="color:#a6e22e">@404</span> <span style="color:#e6db74">/404.html</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">file_server</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">header</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Strict-Transport-Security</span> <span style="color:#e6db74">&#34;max-age=31536000; includeSubDomains; preload&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Content-Security-Policy</span> <span style="color:#e6db74">&#34;default-src &#39;self&#39;; script-src &#39;self&#39;; style-src &#39;self&#39; &#39;unsafe-inline&#39;; object-src &#39;none&#39;; frame-src &#39;none&#39;; base-uri &#39;self&#39;; frame-ancestors &#39;none&#39;; upgrade-insecure-requests&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">Referrer-Policy</span> <span style="color:#e6db74">strict-origin-when-cross-origin</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">X-Content-Type-Options</span> <span style="color:#e6db74">nosniff</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">X-Frame-Options</span> <span style="color:#e6db74">DENY</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">-X-Powered-By</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">-Server</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@static</span> {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">file</span>
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">path</span> <span style="color:#e6db74">*.ico</span> <span style="color:#e6db74">*.css</span> <span style="color:#e6db74">*.js</span> <span style="color:#e6db74">*.gif</span> <span style="color:#e6db74">*.webp</span> <span style="color:#e6db74">*.avif</span> <span style="color:#e6db74">*.jpg</span> <span style="color:#e6db74">*.jpeg</span> <span style="color:#e6db74">*.png</span> <span style="color:#e6db74">*.svg</span> <span style="color:#e6db74">*.woff</span> <span style="color:#e6db74">*.woff2</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">header</span> <span style="color:#a6e22e">@static</span> <span style="color:#e6db74">Cache-Control</span> <span style="color:#e6db74">max-age=2592000</span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
]]></content></item><item><title>Updating to Noctalia v5 on NixOS</title><link>https://catinashell.de/posts/updating-to-noctalia-v5-on-nixos/</link><pubDate>Sat, 27 Jun 2026 18:31:21 +0200</pubDate><guid>https://catinashell.de/posts/updating-to-noctalia-v5-on-nixos/</guid><description>&lt;p&gt;Currently &lt;a href="https://noctalia.dev/blog/announcing-noctalia-v5" target="_blank" rel="noopener"&gt;Noctalia v5&lt;/a&gt; is still in the alpha, but I still decided to adapt already, as it works better with my current setup.
I&amp;rsquo;m using an Impermanent NixOS System and didn&amp;rsquo;t want to persist the &lt;code&gt;.cache&lt;/code&gt; folder (really don&amp;rsquo;t want to, caches should be cleared &amp;hellip;). And unfortunately Noctalia v4 stores the current Wallpaper in there, so if you don&amp;rsquo;t persist it, each restart Noctalia has the Wallpaper set to the default one with the own &amp;hellip;&lt;/p&gt;</description><content type="html"><![CDATA[<p>Currently <a href="https://noctalia.dev/blog/announcing-noctalia-v5" target="_blank" rel="noopener">Noctalia v5</a> is still in the alpha, but I still decided to adapt already, as it works better with my current setup.
I&rsquo;m using an Impermanent NixOS System and didn&rsquo;t want to persist the <code>.cache</code> folder (really don&rsquo;t want to, caches should be cleared &hellip;). And unfortunately Noctalia v4 stores the current Wallpaper in there, so if you don&rsquo;t persist it, each restart Noctalia has the Wallpaper set to the default one with the own &hellip;</p>
<p>Well in Noctalia 5 this is no longer the case, everything is now more cleanly defined in a <strong>TOML-File</strong></p>
<p>So how to switch? Well the old flake path, now points anyway to v5, if you haven&rsquo;t specified a commit / branch, so one a flake update, you&rsquo;d anyway be switched to 5.</p>
<p>But here the flake input anyway</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>flake.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="flake.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>noctalia <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>  url <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;github:noctalia-dev/noctalia&#34;</span>;
</span></span><span style="display:flex;"><span>  inputs<span style="color:#f92672">.</span>nixpkgs<span style="color:#f92672">.</span>follows <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;nixpkgs&#34;</span>;
</span></span><span style="display:flex;"><span>};</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#config-format-change" class="heading">
<h2 id="config-format-change">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Config Format Change

</h2>
</a>
<p>Also the import <strong>Home Manager Import</strong> changed to: <code>inputs.noctalia.homeModules.default</code> from the previous noctalia-shell thing.
Previously I had a <code>noctalia.json</code> in my config, loaded via <code>noctalia-shell.settings = builtins.fromJSON ./noctalia.json;</code>.</p>
<p>Now it looks like this:</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg></span></span>

        <span>noctalia.nix</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="noctalia.nix"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>{ inputs<span style="color:#f92672">,</span> <span style="color:#f92672">...</span> }:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  imports <span style="color:#f92672">=</span> [ inputs<span style="color:#f92672">.</span>noctalia<span style="color:#f92672">.</span>homeModules<span style="color:#f92672">.</span>default ];
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  programs<span style="color:#f92672">.</span>noctalia <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    enable <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>;
</span></span><span style="display:flex;"><span>    settings <span style="color:#f92672">=</span> builtins<span style="color:#f92672">.</span>fromTOML (builtins<span style="color:#f92672">.</span>readFile <span style="color:#e6db74">./noctalia_config.toml</span>);
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>
    </div>
</div>
<p>Loading a <code>noctalia_config.toml</code> instead, also a few settings changed, so I kinda had to make my whole config from scratch. Luckily its pretty good documentated in the <a href="https://docs.noctalia.dev/v5/configuration/" target="_blank" rel="noopener">noctalia docs</a>.
The new config also allows having multiple bars instead of a single one and many more cool things, and also comes with extreme <strong>performance improvements</strong> by <strong>completely ditching qt &amp; quickshell, and rewriting everything in C++</strong> (Why not Rust? TT).</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>TOML</title><path d="M.014 0h5.34v2.652H2.888v18.681h2.468V24H.015V0Zm17.622 5.049v2.78h-4.274v12.935h-3.008V7.83H6.059V5.05h11.577ZM23.986 24h-5.34v-2.652h2.467V2.667h-2.468V0h5.34v24Z"/></svg></span></span>

        <span>noctalia_config.toml</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="noctalia_config.toml"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#a6e22e">theme</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">mode</span>              = <span style="color:#e6db74">&#34;dark&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">source</span>            = <span style="color:#e6db74">&#34;wallpaper&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">wallpaper_scheme</span>  = <span style="color:#e6db74">&#34;m3-content&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[<span style="color:#a6e22e">wallpaper</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">enabled</span>               = <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">transition_on_startup</span> = <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">directory</span>             = <span style="color:#e6db74">&#34;~/Pictures/Wallpapers&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[<span style="color:#a6e22e">nightlight</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">enabled</span>              = <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">temperature_day</span>      = <span style="color:#ae81ff">6500</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">temperature_night</span>    = <span style="color:#ae81ff">3500</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[<span style="color:#a6e22e">location</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">auto_locate</span> = <span style="color:#66d9ef">false</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sunset</span>      = <span style="color:#e6db74">&#34;20:30&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">sunrise</span>     = <span style="color:#e6db74">&#34;06:30&#34;</span>
</span></span><span style="display:flex;"><span>...</span></span></code></pre></div>
    </div>
</div>
<p>pretty clean in my opinion.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#command-changes" class="heading">
<h2 id="command-changes">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Command Changes

</h2>
</a>
<p>The IPC commands also changed, so your window manager (e.g. niri) shortcuts will probably stop working.
The new commands look like this: <code>noctalia msg panel-toggle launcher</code></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-label">
        <span class="codeblock-icon"><style>
.icon svg {
    width: 14px;
    height: 14px;
    fill: rgba(255, 255, 255, 0.7);
}
</style><span class="icon"><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>niri</title><path d="M16.23881 21.91267c0 1.04353-.5217 2.08705-4.17383 2.08705-3.65226 0-4.17395-1.04365-4.17395-2.08705 0-1.56521 1.04352-2.6086 4.17395-2.6086s4.17383 1.04339 4.17383 2.6086zM7.89103-.00038c2.08691 0 10.43483 6.26087 10.43483 11.47835 0 3.52136-1.65048 5.06209-3.09492 5.73623-1.09417.5108-1.39726-.17027-.78877-1.21866.409-.7044.75325-1.55688.75325-2.43065 0-1.56522-.52182-2.60874-1.56522-3.65214-1.04352-1.04352-2.38385-1.56521-3.13043-1.56521-1.04353 0-1.56522 3.06697-1.56522 4.69565 0 1.29764.3872 2.4663.77658 3.31301.3672.79877.05988 1.34726-.76363 1.04442-.89954-.33079-1.97832-.98377-2.6217-2.27064-1.04351-2.08679-.52182-5.09017-.52182-7.82597 0-4.17395 0-7.30426 2.08705-7.30426z"/></svg></span></span>

        <span>niri.kdl</span>
    </div>

    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight" filename="niri.kdl"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-kdl" data-lang="kdl"><span style="display:flex;"><span><span style="color:#75715e">// Launcher
</span></span></span><span style="display:flex;"><span>Mod+Space <span style="color:#f92672">{</span> spawn <span style="color:#e6db74">&#34;noctalia&#34;</span> <span style="color:#e6db74">&#34;msg&#34;</span> <span style="color:#e6db74">&#34;panel-toggle&#34;</span> <span style="color:#e6db74">&#34;launcher&#34;</span><span style="color:#f92672">;</span> <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Locker
</span></span></span><span style="display:flex;"><span>CTRL+Alt+L <span style="color:#f92672">{</span> spawn <span style="color:#e6db74">&#34;noctalia&#34;</span> <span style="color:#e6db74">&#34;msg&#34;</span> <span style="color:#e6db74">&#34;session&#34;</span> <span style="color:#e6db74">&#34;lock&#34;</span><span style="color:#f92672">;</span> <span style="color:#f92672">}</span></span></span></code></pre></div>
    </div>
</div>
<p>If you need more keybindings with the new format, e.g. for volume etc. you might check out <a href="https://git.catq.de/me/mynixos/src/commit/ac6daa04e2d565c1021e6459192cac7dcc6f95d5/home/settings/niri/keybindings.kdl" target="_blank" rel="noopener">my current niri keybindings as reference</a>. Note: these are based on <a href="https://github.com/ryan4yin/nix-config" target="_blank" rel="noopener">ryan4yin&rsquo;s nix config</a>, which at the time of my writing still use noctalia v4 syntax.</p>
]]></content></item><item><title>Hardening NixOS Impermanence Setup with noexec</title><link>https://catinashell.de/posts/hardening-nixos-impermanence-setup-with-noexec/</link><pubDate>Fri, 26 Jun 2026 15:15:56 +0200</pubDate><guid>https://catinashell.de/posts/hardening-nixos-impermanence-setup-with-noexec/</guid><description>&lt;p&gt;An impermanent NixOS Setup is something, I personally I really enjoy, as I don&amp;rsquo;t like preserving everything on my system forever &amp;hellip; Persistence Opt-In is the best approach.&lt;/p&gt;
&lt;p&gt;And recently I came across a nice Blog about hardening NixOS from &lt;a href="https://xeiaso.net/blog/paranoid-nixos-2021-07-18/" target="_blank" rel="noopener"&gt;&lt;strong&gt;Xe Iaso&amp;rsquo;s blog&lt;/strong&gt;&lt;/a&gt;. And well one thing especially seemed cool, so I wanted to share it.&lt;/p&gt;
&lt;style&gt;
.heading {
text-decoration: none;
}
.heading:hover {
color: rgba(200,200,255,0.7);
}
.heading-anchor {
margin-left: -1em;
position: absolute;
opacity: 0;
text-decoration: none;
transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
opacity: 1;
}
&lt;/style&gt;
&lt;a href="#noexec-for-the-root-fs" class="heading"&gt;
&lt;h2 id="noexec-for-the-root-fs"&gt;
&lt;div class="heading-anchor" aria-label="Link to this section"&gt;
#
&lt;/div&gt;
Noexec for the Root FS
&lt;/h2&gt;
&lt;/a&gt;
&lt;p&gt;At the bottom of the blog is a part about having &lt;code&gt;noexec&lt;/code&gt; for the root fs (which is a tmpfs anyway). Since all programs in NixOS life anyway in &lt;code&gt;/nix/store&lt;/code&gt; and &lt;code&gt;/nix&lt;/code&gt; is its own partition in the typical Impermancence Setup (I won&amp;rsquo;t talk about how to this now, as there are already many good blogs discussing this, and showing how it&amp;rsquo;s done; if you want to see my own setup, check &lt;a href="https://git.catq.de/me/mynixos" target="_blank" rel="noopener"&gt;my Codeberg out&lt;/a&gt;).
So only the &lt;code&gt;/nix&lt;/code&gt; parititon needs to be mounted without &lt;code&gt;noexec&lt;/code&gt;, the rest can be &lt;mark&gt;&lt;code&gt;noexec&lt;/code&gt;&lt;/mark&gt;.&lt;/p&gt;</description><content type="html"><![CDATA[<p>An impermanent NixOS Setup is something, I personally I really enjoy, as I don&rsquo;t like preserving everything on my system forever &hellip; Persistence Opt-In is the best approach.</p>
<p>And recently I came across a nice Blog about hardening NixOS from <a href="https://xeiaso.net/blog/paranoid-nixos-2021-07-18/" target="_blank" rel="noopener"><strong>Xe Iaso&rsquo;s blog</strong></a>. And well one thing especially seemed cool, so I wanted to share it.</p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#noexec-for-the-root-fs" class="heading">
<h2 id="noexec-for-the-root-fs">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Noexec for the Root FS

</h2>
</a>
<p>At the bottom of the blog is a part about having <code>noexec</code> for the root fs (which is a tmpfs anyway). Since all programs in NixOS life anyway in <code>/nix/store</code> and <code>/nix</code> is its own partition in the typical Impermancence Setup (I won&rsquo;t talk about how to this now, as there are already many good blogs discussing this, and showing how it&rsquo;s done; if you want to see my own setup, check <a href="https://git.catq.de/me/mynixos" target="_blank" rel="noopener">my Codeberg out</a>).
So only the <code>/nix</code> parititon needs to be mounted without <code>noexec</code>, the rest can be <mark><code>noexec</code></mark>.</p>
<p>Additionally you can even add <mark><code>nodev</code></mark> and <mark><code>nosuid</code></mark> to the root fs, since devices should life under <code>/dev</code>, which is its own partition anyway (a temporary device fs). And <code>suid</code> (switch user id) requires the partition to allow executables anyway.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>disko<span style="color:#f92672">.</span>devices<span style="color:#f92672">.</span>nodev <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;/&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    fsType <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;tmpfs&#34;</span>;
</span></span><span style="display:flex;"><span>    mountOptions <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;size=50%&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;mode=755&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;noexec&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nodev&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nosuid&#34;</span>
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>};</span></span></code></pre></div>
    </div>
</div>
<p>I use this setup for a while now and so far I haven&rsquo;t run into any issues with it. So I can only recommend it to anyone, since its certainly not wrong, to minimise the attack surface (even though this is obviously not a here you go, don&rsquo;t worry anymore about anything else). It just stops things like running a <strong>C Binary</strong> that is placed into e.g. <code>/tmp</code> via <code>/tmp/malicious_binary</code> but not sth like <code>bash /tmp/malicious_script.sh</code></p>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#boot-partition" class="heading">
<h4 id="boot-partition">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Boot Partition

</h4>
</a>
<p>These options can also be added to the <code>/boot</code> Parititon without issues.</p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>content<span style="color:#f92672">.</span>partitions<span style="color:#f92672">.</span>esp <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>  name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;ESP&#34;</span>;
</span></span><span style="display:flex;"><span>  size <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;1G&#34;</span>;
</span></span><span style="display:flex;"><span>  type <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;EF00&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  content <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    type <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;filesystem&#34;</span>;
</span></span><span style="display:flex;"><span>    format <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;vfat&#34;</span>;
</span></span><span style="display:flex;"><span>    mountpoint <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/boot&#34;</span>;
</span></span><span style="display:flex;"><span>    mountOptions <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;fmask=0177&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;dmask=0077&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;noexec&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nosuid&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nodev&#34;</span>
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>};</span></span></code></pre></div>
    </div>
</div>
<style>
.heading {
    text-decoration: none;
}
.heading:hover {
    color: rgba(200,200,255,0.7);
}
.heading-anchor {
    margin-left: -1em;
    position: absolute;
    opacity: 0;
    text-decoration: none;
    transition: opacity 0.15s;
}
h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor {
    opacity: 1;
}
</style>

<a href="#persistent-partition" class="heading">
<h4 id="persistent-partition">
    <div class="heading-anchor" aria-label="Link to this section">
        #
    </div>
    Persistent Partition

</h4>
</a>
<p>Well if you don&rsquo;t have any binaries you want to persist, you can also add these options there too, if you have some like through steam games, flatpaks etc. you can at least add the <code>nodev</code> and <code>nosuid</code> most of the times. Also if you&rsquo;re writing code yourself that is compiled, you probably don&rsquo;t want <code>noexec</code> for these files.</p>
<p><em>My config looks sth like: (Note: these are already btrfs subvolumes, since I encrypt my whole btrfs fs via luks, so using subvolumes is kinda convenient -&gt; only one decrypt)</em></p>
<style>
    .codeblock {
        position: relative;
        margin: 1.4em 0;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        background: #272822;  
    }
    .codeblock-label {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        font-size: 0.8rem;
        color: rgba(255, 255, 255, 0.7);
    }
    .codeblock-icon {
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        opacity: 0.85;
        fill: rgba(255, 255, 255, 0.7);
    }
    .codeblock-copybtn {
        position: absolute;
        top: 0px;
        right: 0px;
        background: transparent;
        color: rgba(255, 255, 255, 0.5);
        cursor: pointer;
    }
    .codeblock-copybtn:hover {
        color: rgba(255, 255, 255, 0.9);
        background: rgba(255, 255, 255, 0.08);
    }
    .codeblock-copybtn-icon {
        margin-right: 4px;
    }
</style>

<div class="codeblock">
    
    <div class="codeblock-body">
        <button class="codeblock-copybtn">
            <span class="codeblock-copybtn-icon">
                <svg
                    xmlns="http://www.w3.org/2000/svg"
                    fill="none"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="currentColor"
                    width="16"
                >
                    <path
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"
                    />
                </svg>
            </span>
            <span class="codeblock-copybtn-label">copy</span>
        </button><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nix" data-lang="nix"><span style="display:flex;"><span>subvolumes <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;/persistent&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    mountOptions <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;subvol=persistent&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;noatime&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nosuid&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;nodev&#34;</span>
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>    mountpoint <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/persistent&#34;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;/nix&#34;</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>    mountOptions <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;subvol=nix&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;noatime&#34;</span>
</span></span><span style="display:flex;"><span>    ];
</span></span><span style="display:flex;"><span>    mountpoint <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;/nix&#34;</span>;
</span></span><span style="display:flex;"><span>  };
</span></span><span style="display:flex;"><span>};</span></span></code></pre></div>
    </div>
</div>
]]></content></item><item><title>Starting a blog</title><link>https://catinashell.de/posts/starting-a-blog/</link><pubDate>Thu, 25 Jun 2026 22:00:11 +0200</pubDate><guid>https://catinashell.de/posts/starting-a-blog/</guid><description>&lt;p&gt;Recently I&amp;rsquo;ve come across some pretty cool blogs, like the one from &lt;a href="https://%e3%83%9e%e3%83%aa%e3%82%a6%e3%82%b9.com" target="_blank" rel="noopener"&gt;マリウス&lt;/a&gt;, or some cool Nix related blogs, a lot of them linked in this &lt;a href="https://nixwebr.ing/" target="_blank" rel="noopener"&gt;Nix Webring Project&lt;/a&gt;.
I really enjoy reading a lot of these posts and doing some of the projects shown there myself, or finding inspiration for my own setups etc.
So I thought maybe I should also start a blog, as I do certain things still different in the end or find some nice tweaks I just wanna share, as I&amp;rsquo;ve not seen them so far.&lt;/p&gt;</description><content type="html"><![CDATA[<p>Recently I&rsquo;ve come across some pretty cool blogs, like the one from <a href="https://%e3%83%9e%e3%83%aa%e3%82%a6%e3%82%b9.com" target="_blank" rel="noopener">マリウス</a>, or some cool Nix related blogs, a lot of them linked in this <a href="https://nixwebr.ing/" target="_blank" rel="noopener">Nix Webring Project</a>.
I really enjoy reading a lot of these posts and doing some of the projects shown there myself, or finding inspiration for my own setups etc.
So I thought maybe I should also start a blog, as I do certain things still different in the end or find some nice tweaks I just wanna share, as I&rsquo;ve not seen them so far.</p>
<p>And honestly I also just wanna share a bit of what I&rsquo;m doing with the world, maybe it&rsquo;s even helpful to someone out there.</p>
<p>Well so here I am, I don&rsquo;t know if this will have any future or I stop this already tomorrow, but as of now, I&rsquo;m kinda motiviated. Ig this might even help me review things better as I&rsquo;m going through them again sharing them.</p>
<p>As for this Blog, for now I&rsquo;m settling with <strong>Hugo</strong>, it stroke me as one of the best solutions for managing such a blog, as for the theming, I&rsquo;m not yet sure about. And the Server, unfortunately I wasn&rsquo;t able to install NixOS and NixOS-Infect dind&rsquo;t work, so I just choose <em>Fedora</em> which I&rsquo;m also a bit familiar (used if for around a year or so as my daily driver).</p>
<p>The <strong>topics</strong> will probably mostly revolve around <strong>NixOS, Privacy-Focused and/or FOSS Projects, Security</strong> &amp; potentially CTFs (I wanted to start for a real long time, but haven&rsquo;t yet xD). And a lot about just the issues I encounter in my setup now and then and how I resolved them, nice tweaks I found etc.</p>
]]></content></item></channel></rss>