Introduction
Introduction Statistics Contact Development Disclaimer Help
kokada.dev.rss.xml - sfeed_tests - sfeed tests and RSS and Atom files
git clone git://git.codemadness.org/sfeed_tests
Log
Files
Refs
README
LICENSE
---
kokada.dev.rss.xml (494372B)
---
1 <?xml version="1.0" encoding="utf-8"?>
2 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><ti…
3 # dd if=/dev/urandom of=/dev/brain0
4 dd: error writing &amp;#39;/dev/brain0&amp;#39;: No space left on device
5
6 </description><atom:link href="https://kokada.dev/rss/" rel="self"/><lan…
7 post&lt;/a&gt;. It is mostly
8 because I ran out of things to write, but I expected this. This is proba…
9 more likely how I am actually going to post from now. At least, it shows…
10 my plan to have a &lt;a href="https://kokada.dev/blog/making-a-blog-for-…
11 time&lt;/a&gt;, that is
12 easy to go back when I wanted is working fine, but I digress.&lt;/p&gt;
13 &lt;p&gt;Going back to the theme of the today blog post, I needed to wri…
14 page&lt;/a&gt; for the first time in years. I
15 hate &lt;a href="https://en.wikipedia.org/wiki/Troff"&gt;troff&lt;/a&gt;…
16 for man pages (similar to &lt;a href="https://en.wikipedia.org/wiki/LaTe…
17 documents). It is one of the weirdest languages that I ever saw, and eve…
18 example in Wikipedia shows that:&lt;/p&gt;
19 &lt;pre&gt;&lt;code class="language-troff"&gt;.ND &amp;quot;January 10, …
20 .AU &amp;quot;Ms. Jane Smith&amp;quot;
21 .AT &amp;quot;Upcoming appointment&amp;quot;
22 .MT 5
23 .DS
24 Reference #A12345
25 .sp 4
26 Mr. Samuel Jones
27 Field director, Bureau of Inspections
28 1010 Government Plaza
29 Capitoltown, ST
30 .sp 3
31 Dear Mr. Jones,
32 .sp 2
33 .P
34 Making reference to the noted obligation to submit for state inspection …
35 .B now ,
36 in
37 .I this
38 year of
39 .I this
40 decade, to prepare our industrial base for the interstate and internatio…
41 .P
42 Thank you for your consideration of our position.
43 .FC Sincerely
44 .SG
45 &lt;/code&gt;&lt;/pre&gt;
46 &lt;p&gt;Keep in mind that the break lines are necessary every time you …
47 macro, like &lt;code&gt;.I this&lt;/code&gt; (that I &lt;em&gt;think&lt;…
48 as illegible as hell, and it is worse that the format lacks good tooling…
49 least I didn't find any good ones).&lt;/p&gt;
50 &lt;p&gt;Most people when they need to write a man page nowadays ends up…
51 other format that generates a man page. For example, in the past I used
52 &lt;a href="https://pandoc.org/"&gt;Pandoc&lt;/a&gt; to convert Markdown…
53 Pandoc is a great project the result is sub-optimal at best: Markdowns a…
54 the end, designed for generating HTML (and a subset of it), and not man …
55 so you basically ends up fighting the format for it to do what you want.
56 Also, Pandoc is a big project, with a ~200MB binary (at least it is the …
57 Pandoc binary in Nix).&lt;/p&gt;
58 &lt;p&gt;For this specific project I needed something small. I am trying…
59 of the most essential pieces inside NixOS, &lt;code&gt;nixos-rebuild&lt;…
60 with a &lt;a href="https://discourse.nixos.org/t/nixos-rebuild-ng-a-nixo…
61 Python&lt;/a&gt;
62 (sorry Rust zealots!), called &lt;code&gt;nixos-rebuild-ng&lt;/code&gt;.…
63 &lt;p&gt;Since this project will eventually (if successful) be in the cr…
64 NixOS, I want to reduce the number of dependencies as much as possible, …
65 something as big as Pandoc is out. I could use
66 &lt;a href="https://asciidoc.org/"&gt;AsciiDoc&lt;/a&gt;, but it is a bi…
67 (this may seem ironic, but &lt;code&gt;nixos-rebuild-ng&lt;/code&gt; has…
68 that is optional). And I also hated the last time I tried to use it to g…
69 man pages: it more flexible than Markdown, but still far from optimal.&l…
70 &lt;p&gt;Thanks to Drew DeVault (creator of &lt;a href="https://swaywm.o…
71 had the same issues in the past and created
72 &lt;a href="https://drewdevault.com/2018/05/13/scdoc.html"&gt;&lt;code&g…
73 page generator using a DSL inspired in Markdown, but specific to generat…
74 pages. The binary is written in C (and advantage in this case since it m…
75 is easier to bootstrap), is small (~1 Kloc) and has no dependencies, so …
76 fits the requirement.&lt;/p&gt;
77 &lt;p&gt;While the language suffers from being a niche project for a nic…
78 &lt;a href="https://man.archlinux.org/man/scdoc.5.en"&gt;man page&lt;/a&…
79 nice. It is terse though and lacks examples, and this is what this blog …
80 will try to accomplish.&lt;/p&gt;
81 &lt;p&gt;To start, let's have a quick summary of the syntax, written in …
82 comments:&lt;/p&gt;
83 &lt;pre&gt;&lt;code class="language-scdoc"&gt;; quick summary:
84 ; # new section
85 ; comments starts with ;
86 ; - this is a list
87 ; - sub-list
88 ; - *bold*: _underline_, force a line break++
89 ; - [tables], \[ can be used to force an actual [
90 ; . numbered list
91 ; please configure your editor to use hard tabs
92 ; see `man 5 scdoc` for more information about syntax
93 ; or https://man.archlinux.org/man/scdoc.5.en
94 &lt;/code&gt;&lt;/pre&gt;
95 &lt;p&gt;I actually added this summary in the &lt;code&gt;.scd&lt;/code&…
96 I wrote, so it is easy for someone that never saw the format to start
97 collaborating.&lt;/p&gt;
98 &lt;p&gt;And here an example of a (summarised) man page in &lt;code&gt;.…
99 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
100 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
101 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
102 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
103 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
104 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
105 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
106 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
107 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
108 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
109 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
110 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
111 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
112 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
113 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
114 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
115 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
116 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
117 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
118 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
119 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
120 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
121 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
122 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
123 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
124 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
125 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
126 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
127 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
128 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
129 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
130 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
131 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
132 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
133 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
134 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
135 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
136 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
137 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
138 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
139 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
140 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
141 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
142 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
143 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
144 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
145 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
146 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
147 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
148 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
149 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
150 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
151 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
152 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
153 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
154 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
155 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
156 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
157 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
158 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
159 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And here is …
160 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
161 file"&gt;&lt;/a&gt;&lt;/p&gt;
162 &lt;p&gt;One of nice things that I found is how looking at the plain tex…
163 like the man page result already. And if you know Markdown, you can basi…
164 understand most things that is happening. There are a few differences, l…
165 &lt;code&gt;*bold*&lt;/code&gt; instead of &lt;code&gt;**bold**&lt;/code…
166 end of the world.&lt;/p&gt;
167 &lt;p&gt;Now, the format has its quirks. The first line being the name o…
168 and section in parenthesis is required, but this makes sense, since you …
169 this information for the corners. But for one, it requires the usage of …
170 tabs to create indentation, and the error messages are awful, in a situa…
171 that kind remembers me of &lt;code&gt;Makefile&lt;/code&gt;. Also the ch…
172 means that the traditional &lt;code&gt;app [command]&lt;/code&gt; needs …
173 &lt;code&gt;app \[command]&lt;/code&gt;. I found this a strange choice s…
174 format that is only used for man pages, and using &lt;code&gt;[command]&…
175 optional is common, but at least it is easy to escape.&lt;/p&gt;
176 &lt;p&gt;In the end, I think all that matters is the result. And for the…
177 all those years trying to write a man page, I am satisfied with the resu…
178 man page looks exactly as I wanted once rendered, and the &lt;code&gt;.s…
179 reasonable good that it can work as a documentation for someone that for…
180 reason or another can't use the man page (can't say the same for the tro…
181 version). Also, it is really easy for someone to just go there and updat…
182 man page, even without experience in the format (except for maybe the
183 requirement of tabs). So all in all, I really liked the format, and will…
184 again if I need to write another man page in the future.&lt;/p&gt;</desc…
185 wireless earbuds instead of wired earphones is the latency: it is bad, g…
186 up to seconds(!) depending on your particular combination of OS/earbuds/…
187 &lt;p&gt;There is a solution though: Bluetooth LE Audio, that is suppose…
188 multiple issues with the original design for Bluetooth Classic Audio, in…
189 a much lower latency, improved efficiency (e.g.: less battery power) and…
190 multiple streams of audio. LE Audio also includes a new default codec for
191 improved audio quality, &lt;a href="https://en.wikipedia.org/wiki/LC3_(c…
192 replaces the venerable &lt;a href="https://en.wikipedia.org/wiki/SBC_(co…
193 for audio.&lt;/p&gt;
194 &lt;p&gt;However, the standard is a mess right now: a few wireless headp…
195 support it, but they're generally disabled by default and it is pretty m…
196 enable. And even after enabling it, getting it to work can be a pain.&lt…
197 &lt;p&gt;I have pretty much the best setup to use LE Audio right now: a …
198 released Pixel 9 Pro with Sony's
199 &lt;a href="https://www.sony.ie/headphones/products/wf-1000xm5"&gt;WF-10…
200 after lots of tries I got it to work. You can see below the versions of
201 everything I am using:&lt;/p&gt;
202 &lt;ul&gt;
203 &lt;li&gt;Android: 14&lt;/li&gt;
204 &lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.…
205 Connect&lt;/a&gt;:
206 11.0.1&lt;/li&gt;
207 &lt;li&gt;WM-1000XM5: 4.0.2&lt;/li&gt;
208 &lt;/ul&gt;
209 &lt;p&gt;The first thing you need to do is enable in &amp;quot;Sound Con…
210 Priority&amp;quot; in &amp;quot;Device Settings -&amp;gt; System&amp;quo…
211 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
212 Connect"&gt;&lt;/a&gt;&lt;/p&gt;
213 &lt;p&gt;After this, you will need to pair your headset with the device …
214 do this as same as always: press and hold the button in case for a few s…
215 until a blue light starts to blink. However, this is where things starts…
216 janky: I couldn't get the headset to pair with Android again.&lt;/p&gt;
217 &lt;p&gt;A few of the things that I needed to do (in no specific order):…
218 &lt;ul&gt;
219 &lt;li&gt;Remove the previous paired headset&lt;/li&gt;
220 &lt;li&gt;Restart the Android&lt;/li&gt;
221 &lt;li&gt;Clean-up &amp;quot;Sound Connect&amp;quot; storage (Long press…
222 &amp;quot;Storage and Cache&amp;quot; -&amp;gt; &amp;quot;Clear storage&…
223 &lt;/ul&gt;
224 &lt;p&gt;If you can get the headset to connect, go to the &amp;quot;Blue…
225 Android, click in the gear icon for the headset and enable &amp;quot;LE …
226 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
227 Settings"&gt;&lt;/a&gt;&lt;/p&gt;
228 &lt;p&gt;If you can't, you may want to &lt;a href="https://helpguide.son…
229 settings&lt;/a&gt;
230 and try again from the start (that means pairing your device with &amp;q…
231 Connect&amp;quot; again, and you may want to try to clear the storage be…
232 &lt;p&gt;Yes, the process is extremely janky, but I think this is why bo…
233 Connect&amp;quot; and Android marks this feature as beta/experimental. A…
234 to test the latency, but from my initial testing there are some glitches…
235 the audio is only used for a short period of time (e.g.: Duolingo only e…
236 the audio when the character is speaking). So I only recommend this if y…
237 to test how LE Audio will behave, since it is clear that this needs more
238 polish.&lt;/p&gt;</description><pubDate>Mon, 07 Oct 2024 00:00:00 +0000<…
239 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
240 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
241 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
242 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
243 is this stored? Well, I had to look at the Nix source code to find the a…
244 since I can't find this anywhere in the web or in ChatGPT (but I am sure…
245 now that I posted this it will eventually be searchable), and the answer…
246 found
247 &lt;a href="https://github.com/NixOS/nix/blob/c116030605bf7fecd232d0ff3b…
248 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
249 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
250 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
251 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
252 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Where is &lt…
253 &lt;a href="https://github.com/NixOS/nix/blob/c116030605bf7fecd232d0ff3b…
254 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
255 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
256 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
257 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
258 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
259 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
260 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
261 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
262 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
263 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
264 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
265 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
266 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
267 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
268 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So we solved…
269 &lt;ul&gt;
270 &lt;li&gt;If &lt;code&gt;NIX_DATA_HOME&lt;/code&gt; is set, the file wil…
271 &lt;code&gt;$NIX_DATA_HOME/trusted-settings.json&lt;/code&gt;&lt;/li&gt;
272 &lt;li&gt;If &lt;code&gt;XDG_DATA_HOME&lt;/code&gt; is set, the file wil…
273 &lt;code&gt;$XDG_DATA_HOME/nix/trusted-settings.json&lt;/code&gt;&lt;/li…
274 &lt;li&gt;Otherwise Nix will fallback to &lt;code&gt;$HOME/.local/share/…
275 &lt;/ul&gt;
276 &lt;p&gt;By the way, if you don't know why you got this prompt, if &lt;c…
277 &lt;code&gt;nixConfig&lt;/code&gt; attribute inside &lt;code&gt;outputs&…
278 attribute (like &lt;code&gt;extra-substituters&lt;/code&gt;) you will ge…
279 &lt;a href="https://nix.dev/manual/nix/2.23/command-ref/conf-file#conf-a…
280 in your Nix configuration (please &lt;strong&gt;do not do this&lt;/stron…
281 it may allow running possible unsafe options without asking you first).&…
282 &lt;p&gt;You can inspect the JSON file or delete it and Nix will prompt …
283 next time you run a &lt;code&gt;nix&lt;/code&gt; command. And yes, savin…
284 controversial considering this is Nix, but having the power to set &lt;c…
285 attributes is really powerful, and with great powers comes great
286 responsibilities.&lt;/p&gt;</description><pubDate>Mon, 30 Sep 2024 00:00…
287 everywhere you go. However, I like to talk about tools, and AIs, or more
288 specifically, &lt;a href="https://en.wikipedia.org/wiki/Large_language_m…
289 Models&lt;/a&gt; (LLM), can be
290 really useful tools. Maybe someday we will have our AI overlords dominat…
291 everything (including my job), but right now I don't feel particularly
292 threatened given my experience with AIs.&lt;/p&gt;
293 &lt;p&gt;Given that &lt;a href="https://mashable.com/article/google-sear…
294 worse&lt;/a&gt;, I am
295 slowly relying in LLMs more and more. This is the focus of this post, ba…
296 &lt;a href="https://www.rottentomatoes.com/m/the_good_the_bad_and_the_ug…
297 ugly&lt;/a&gt; (by the
298 way, never saw this film) of LLMs, especially focused for solving coding
299 problems. I will take a look at the my chat history in
300 &lt;a href="https://chatgpt.com/"&gt;ChatGPT&lt;/a&gt; and see where it …
301 shined, and where it just completely wasted my time.&lt;/p&gt;
302 &lt;p&gt;A disclaimer, I never bothered to buy a ChatGPT subscription be…
303 feel that the tool is useful enough (at least yet), so most of the examp…
304 here are either with &lt;a href="https://openai.com/index/chatgpt/"&gt;G…
305 mini&lt;/a&gt;,
306 since those where the models offered by free in ChatGPT.&lt;/p&gt;
307 &lt;p&gt;An addendum, I have some experience with &lt;a href="https://gi…
308 Copilot&lt;/a&gt; (another LLM, but this one runs
309 inside your IDE or favorite text editor) in &lt;code&gt;$PREVIOUS_JOB&lt…
310 with it is even more underwhelming than what I am going to describe in t…
311 post: it was basically really good for generating fixture for tests and …
312 ok-ish to plain bad for everything else. Yes, that's would fit in a twee…
313 xeet?).&lt;/p&gt;
314 &lt;h2&gt;The good&lt;/h2&gt;
315 &lt;p&gt;&lt;a href="https://chatgpt.com/share/c58a1432-2761-4954-acac-c…
316 &lt;blockquote&gt;
317 &lt;p&gt;Is there any way that I can pass a context for a net.conn to ca…
318 Read()?&lt;/p&gt;
319 &lt;/blockquote&gt;
320 &lt;p&gt;This is one of the good cases where ChatGPT felt to me that I w…
321 an expert in Go. To start, I didn't even mention in my initial prompt th…
322 was talking about Go, but it correctly inferred so. Also, the solution o…
323 was great:&lt;/p&gt;
324 &lt;blockquote&gt;
325 &lt;ol&gt;
326 &lt;li&gt;&lt;strong&gt;Use a separate goroutine&lt;/strong&gt; to handl…
327 &lt;li&gt;&lt;strong&gt;Set a deadline&lt;/strong&gt; on the connection …
328 the &lt;code&gt;Read()&lt;/code&gt; when the context is canceled.&lt;/li…
329 &lt;/ol&gt;
330 &lt;/blockquote&gt;
331 &lt;p&gt;Before asking ChatGPT about this issue I had already coded my o…
332 solution that was something similar to this:&lt;/p&gt;
333 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
334 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
335 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
336 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
337 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
338 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
339 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
340 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
341 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
342 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
343 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
344 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
345 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
346 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
347 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
348 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
349 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
350 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
351 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
352 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
353 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Compared thi…
354 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
355 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
356 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
357 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
358 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
359 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
360 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
361 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
362 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
363 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
364 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
365 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
366 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
367 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
368 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
369 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
370 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
371 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
372 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
373 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
374 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
375 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The ChatGPT …
376 &lt;ol&gt;
377 &lt;li&gt;It doesn't close the connection socket allowing it to be reuse…
378 &lt;li&gt;It waits until the goroutine is finished to avoid leaks&lt;/li…
379 &lt;li&gt;It closes the channel after it finishes&lt;/li&gt;
380 &lt;/ol&gt;
381 &lt;p&gt;Now, I don't claim to be a Go expert (far from it), but this wa…
382 cases where I felt that I was being guided by someone that is coding in …
383 years.&lt;/p&gt;
384 &lt;p&gt;But it didn't end there, I asked:&lt;/p&gt;
385 &lt;blockquote&gt;
386 &lt;p&gt;If I want to reuse the connection, do I need to reset the SetRe…
387 &lt;/blockquote&gt;
388 &lt;p&gt;Since in this particular case I wanted the underlying connectio…
389 and ChatGPT correctly amended the code:&lt;/p&gt;
390 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
391 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
392 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
393 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
394 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
395 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
396 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
397 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
398 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
399 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
400 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
401 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
402 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
403 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
404 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
405 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Also the exp…
406 &lt;blockquote&gt;
407 &lt;p&gt;When you set a read deadline with &lt;code&gt;conn.SetReadDeadl…
408 the &lt;code&gt;Read()&lt;/code&gt; call, this deadline remains in effec…
409 operations. This means that if you attempt another read operation after …
410 it could immediately fail with a timeout error if the deadline is still …
411 effect.
412 To reuse the connection, you'll need to remove the deadline or set a new…
413 You can do this by calling &lt;code&gt;conn.SetReadDeadline(time.Time{})…
414 any existing deadline.&lt;/p&gt;
415 &lt;/blockquote&gt;
416 &lt;p&gt;I had one last question that I kind already knew the answer:&lt…
417 &lt;blockquote&gt;
418 &lt;p&gt;Do we need to defer the clearing?&lt;/p&gt;
419 &lt;/blockquote&gt;
420 &lt;p&gt;And ChatGPT correctly returned:&lt;/p&gt;
421 &lt;blockquote&gt;
422 &lt;p&gt;Whether you need to defer the clearing of the read deadline dep…
423 your code is structured. If you want to ensure that the read deadline is
424 always cleared after a context cancellation, even if the code panics or …
425 early, then deferring the &lt;code&gt;conn.SetReadDeadline(time.Time{})&…
426 idea.&lt;/p&gt;
427 &lt;/blockquote&gt;
428 &lt;p&gt;This whole interaction was one of the best ones I ever had in C…
429 it gave me an actual functional code with good explanation on what was
430 happening. But still, it didn't talked at all about the gotcha of settin…
431 read deadline and reusing the underlying connection, needing another pro…
432 give me this information.&lt;/p&gt;
433 &lt;p&gt;Also, there is one issue in ChatGPT solution though: we are dis…
434 values of the buffer once the context is done by returning &lt;code&gt;n…
435 the number of bytes read. In this particular case this is what I wanted,…
436 this is a possible issue that ChatGPT didn't talk.&lt;/p&gt;
437 &lt;p&gt;For comparison,
438 &lt;a href="https://stackoverflow.com/questions/61637359/how-to-use-cont…
439 is the best that I got searching in both DuckDuckGo and Google, that is …
440 kind based my first solution on. I still not sure where ChatGPT could gi…
441 such a good answer for this question, because I just couldn't find anyth…
442 remotely similar during my searches.&lt;/p&gt;
443 &lt;h2&gt;The amazing&lt;/h2&gt;
444 &lt;p&gt;&lt;a href="https://chatgpt.com/share/0c9a148f-4cfd-4b4e-aa84-7…
445 &lt;blockquote&gt;
446 &lt;p&gt;I want to write an extension to &lt;a href="https://github.com/…
447 me to rewrite &lt;code&gt;[link](../2024-07-30/post.md)&lt;/code&gt; to
448 &lt;code&gt;[link](https://kokada.capivaras.dev/slug)&lt;/code&gt;&lt;/p…
449 &lt;/blockquote&gt;
450 &lt;p&gt;Here is the generated code:&lt;/p&gt;
451 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
452 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
453 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
454 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
455 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
456 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
457 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
458 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
459 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
460 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
461 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
462 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
463 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
464 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
465 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
466 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
467 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
468 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
469 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
470 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
471 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
472 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
473 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
474 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
475 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
476 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
477 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
478 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
479 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
480 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
481 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
482 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
483 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
484 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
485 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
486 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
487 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
488 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
489 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
490 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
491 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
492 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
493 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
494 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
495 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
496 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
497 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
498 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
499 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
500 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
501 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
502 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
503 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
504 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
505 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
506 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="chroma…
507 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
508 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
509 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
510 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
511 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
512 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
513 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
514 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
515 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
516 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
517 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
518 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
519 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
520 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
521 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
522 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
523 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
524 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
525 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
526 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This one wil…
527 the Markdown renderer that &lt;a href="https://kokada.dev/blog/making-a-…
528 blog&lt;/a&gt;, does not
529 have good examples or documentation (at least I didn't found neither).&l…
530 &lt;p&gt;So I was not really hopeful I would get any answers in ChatGPT,…
531 put me in the correct path, the code was almost correct. It did had some…
532 and missing imports, and there were some compilation errors that were ea…
533 fixed. And when it registered the extension, it also added a
534 &lt;code&gt;html.WithHardWraps()&lt;/code&gt; renderer for no reason at …
535 &lt;p&gt;But this is one of the experiences in LLM that most impressed m…
536 at all on how to solve this problem, and ChatGPT basically gave me the
537 solution. A &lt;a href="https://github.com/thiagokokada/blog/blob/3a2ea5…
538 code&lt;/a&gt;
539 from this chat is still used to power this blog to this day, that also
540 demonstrates that the code is not garbage (since now I understand what i…
541 and I can even extend it).&lt;/p&gt;
542 &lt;p&gt;I am still not sure how the license situation of this code is t…
543 licenses even make sense in AI generated code?&lt;/p&gt;
544 &lt;h2&gt;The bad&lt;/h2&gt;
545 &lt;p&gt;&lt;a href="https://chatgpt.com/share/95fcd777-b03c-4cfe-8d1d-1…
546 &lt;blockquote&gt;
547 &lt;p&gt;I want to configure VM options inside IntelliJ by project&lt;/p…
548 &lt;/blockquote&gt;
549 &lt;blockquote&gt;
550 &lt;p&gt;My project uses sbt, and I want to set this in a way that I can…
551 colleagues&lt;/p&gt;
552 &lt;/blockquote&gt;
553 &lt;blockquote&gt;
554 &lt;p&gt;I am using a build.sbt file, but IntelliJ is not loading it's J…
555 I need to set this up manually. I want to automate this&lt;/p&gt;
556 &lt;/blockquote&gt;
557 &lt;p&gt;This is an example of my most common interaction with ChatGPT: …
558 gives some options that could work, but not in my specific case. So I st…
559 ask for more information until it eventually starts to
560 &lt;a href="https://en.wikipedia.org/wiki/Hallucination_(artificial_inte…
561 &lt;p&gt;In this particular case, the hallucination was in:&lt;/p&gt;
562 &lt;blockquote&gt;
563 &lt;p&gt;The sbt-idea-plugin can generate IntelliJ IDEA project files ba…
564 SBT configuration, including JVM options. This allows you to ensure that
565 IntelliJ loads the correct settings from the SBT configuration.&lt;/p&gt;
566 &lt;p&gt;Steps:&lt;/p&gt;
567 &lt;ol&gt;
568 &lt;li&gt;Add the &lt;code&gt;sbt-idea-plugin&lt;/code&gt; to your &lt;c…
569 &lt;/ol&gt;
570 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
571 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;ol start="2"&gt;
572 &lt;li&gt;Run the following command in your terminal to regenerate Intel…
573 project files:&lt;/li&gt;
574 &lt;/ol&gt;
575 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
576 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/blo…
577 &lt;p&gt;Yes, there is a
578 &lt;a href="https://github.com/JetBrains/sbt-idea-plugin"&gt;&lt;code&gt…
579 doesn't generate project files based in my SBT configuration. It is not …
580 from the repository that it is supposed to be pointing too.&lt;/p&gt;
581 &lt;p&gt;I will just not say that this interaction was a waste of time b…
582 the other ideas can be applied, but this was the kind of case where I en…
583 just being disappointed because the thing that seemed to be a possible s…
584 for my problem ended up not existing at all.&lt;/p&gt;
585 &lt;h2&gt;The ugly&lt;/h2&gt;
586 &lt;p&gt;There are lots of examples where ChatGPT just plain disappointe…
587 few:&lt;/p&gt;
588 &lt;blockquote&gt;
589 &lt;p&gt;What is the language that is a fork of Go that has extra featur…
590 &lt;/blockquote&gt;
591 &lt;p&gt;&lt;a href="https://chatgpt.com/share/2b854bbd-d376-4049-97fe-b…
592 &lt;p&gt;This is one of those cases where I saw something once and was t…
593 remember. ChatGPT just gave me lots of answers that were not a fork of Go
594 (&lt;a href="https://vlang.io/"&gt;V&lt;/a&gt;, &lt;a href="https://gith…
595 &lt;a href="https://www.ponylang.io"&gt;Pony&lt;/a&gt;), hallucinated a …
596 and said that &lt;a href="https://ziglang.org/"&gt;Zig&lt;/a&gt; is focu…
597 &lt;p&gt;By the way, I eventually remember what the language was:
598 &lt;a href="https://goplus.org/"&gt;Go+&lt;/a&gt;. To be fair with ChatG…
599 Go+ had map (as the &lt;a href="https://en.wikipedia.org/wiki/Map_(highe…
600 function&lt;/a&gt;, not a
601 hashmap that both Go and Go+ have). But still, Go+ explicit announces th…
602 is a language for STEM everywhere in their website, and even them ChatGPT
603 couldn't answer.&lt;/p&gt;
604 &lt;blockquote&gt;
605 &lt;p&gt;In IntelliJ, I need to pass some VM options to the run configur…
606 application to run tests, e.g.:&lt;/p&gt;
607 &lt;pre&gt;&lt;code&gt;--add-exports=java.base/sun.security.x509=ALL-UNN…
608 --add-opens=java.base/sun.security.ssl=ALL-UNNAMED
609 -Dconfig.resource=api.test.conf
610 &lt;/code&gt;&lt;/pre&gt;
611 &lt;p&gt;However, the &lt;code&gt;api.test.conf&lt;/code&gt; may be &lt;…
612 depending on the subproject I am running inside Idea. Can I parametrize …
613 in some way?&lt;/p&gt;
614 &lt;/blockquote&gt;
615 &lt;p&gt;&lt;a href="https://chatgpt.com/share/aa9bd051-65de-49d9-8d56-0…
616 &lt;p&gt;So quick answer: you can't. IntelliJ macros are not powerful en…
617 ChatGPT itself said so when I asked about the IntelliJ macros
618 &lt;a href="https://chatgpt.com/share/7a057bf5-bcec-458b-9432-98e3f551ad…
619 &lt;p&gt;But in this particular case, ChatGPT happily said &amp;quot;yes…
620 options in IntelliJ IDEA to make them more flexible depending on the sub…
621 or other context&amp;quot;. Thanks for wasting my time, I guess.&lt;/p&g…
622 &lt;h2&gt;Conclusion&lt;/h2&gt;
623 &lt;p&gt;I do think that LLMs, in particular ChatGPT since this is the o…
624 experience with, are improving. But still, if there is anything that I
625 concluded after putting all those experiences in a post is that you stil…
626 someone that knows at least as much about whatever you're asking ChatGPT…
627 actually validate the answer.&lt;/p&gt;
628 &lt;p&gt;Not only because LLMs hallucinates a lot, but also because even…
629 example the LLM needed extra input to figure out about the possible draw…
630 the solution. The only case where I felt that ChatGPT outsmarted me was …
631 &amp;quot;amazing&amp;quot; case, but this was literally the only exampl…
632 all my chat history with ChatGPT that was like this.&lt;/p&gt;
633 &lt;p&gt;So yes, at least for now I still don't think AI will be our ove…
634 someday.&lt;/p&gt;</description><pubDate>Mon, 02 Sep 2024 00:00:00 +0000…
635 more about it than some of my other projects. For some reason or another…
636 to make sure that this blog will continue with me for a long time. This …
637 of the reasons why I use &lt;a href="https://kokada.dev/blog/using-githu…
638 blog&lt;/a&gt; and why I
639 created a &lt;a href="https://kokada.dev/blog/quick-bits-why-you-should-…
640 automation&lt;/a&gt;
641 to make sure I never forget how to maintain this blog.&lt;/p&gt;
642 &lt;p&gt;Still, there are a bunch of dependencies that I need to make su…
643 working so I can publish blog posts:&lt;/p&gt;
644 &lt;ul&gt;
645 &lt;li&gt;Markdown&lt;/li&gt;
646 &lt;li&gt;A text editor&lt;/li&gt;
647 &lt;li&gt;Hosting and blog platform&lt;/li&gt;
648 &lt;li&gt;Shell script and
649 &lt;a href="https://kokada.dev/blog/abusing-makefiles-for-fun-and-profit…
650 &lt;li&gt;Go toolchain and modules&lt;/li&gt;
651 &lt;/ul&gt;
652 &lt;p&gt;Let's start with the most important one: the texts themselves, …
653 written in &lt;a href="https://www.markdownguide.org/"&gt;Markdown&lt;/a…
654 Markdown is that it is just plain text files with some special notation …
655 allow you to format text, but the text itself is still legible even if y…
656 no support to render Markdowns. So it means as long as I can read a plai…
657 file, I can still read the posts, no issue there. Closely related issue …
658 the text editor, but the nice thing about Markdown is that if tomorrow I…
659 to change from &lt;code&gt;neovim&lt;/code&gt; to, say, &lt;a href="http…
660 Markdown files without issue. I also use a standardised Markdown impleme…
661 called &lt;a href="https://commonmark.org/"&gt;CommonMark&lt;/a&gt;, tha…
662 of the original Markdown spec.&lt;/p&gt;
663 &lt;p&gt;The next point is the host (&lt;a href="capivaras.dev"&gt;capiv…
664 platform (&lt;a href="https://github.com/mataroa-blog/mataroa"&gt;Mataro…
665 things about Mataroa is that it avoids platform lock-in by having multip…
666 to &lt;a href="https://mataroa.blog/export/"&gt;export your posts&lt;/a&…
667 to &lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt;, for example, and s…
668 Pages&lt;/a&gt;.&lt;/p&gt;
669 &lt;p&gt;This is especially nice consider how small &lt;a href="capivara…
670 so it is good to know that if I eventually have issues I could move to
671 somewhere else. I also have an e-mail backup every month with all posts …
672 (another &lt;a href="https://hey.mataroa.blog/blog/monthly-auto-exports-…
673 feature&lt;/a&gt;), and
674 of course I have a &lt;a href="https://github.com/thiagokokada/blog"&gt;…
675 acts as a &lt;a href="https://kokada.dev/blog/using-github-as-a-bad-blog…
676 blog&lt;/a&gt;. So I would
677 say the chance of losing access to the content is slim.&lt;/p&gt;
678 &lt;p&gt;One other issue is the URL of the posts that are indexed in man…
679 places, like &lt;a href="https://news.ycombinator.com/"&gt;Hacker News&l…
680 &lt;a href="https://lobste.rs/"&gt;Lobte.rs&lt;/a&gt;, etc. This is why …
681 bullet and purchase a proper domain, and this website should now be avai…
682 in &lt;a href="kokada.dev"&gt;kokada.dev&lt;/a&gt;. This means that in m…
683 &lt;a href="capivaras.dev"&gt;capivaras.dev&lt;/a&gt;, I can just point …
684 domain if needed (it is not as easy since I also need to preserve the po…
685 URLs, but shouldn't be difficult to fix this if I ever need to do so).&l…
686 &lt;p&gt;Now for the tools that I use to publish from the original Markd…
687 everything else. Let's start with shell script(s) and Makefile: I decide…
688 they're less of an issue if they eventually stop working: they're only u…
689 make my life easier, but I can still publish files manually if needed. S…
690 tried to rewrite both the
691 &lt;a href="https://github.com/thiagokokada/blog/commit/a0d421ca90f3da05…
692 and
693 &lt;a href="https://github.com/thiagokokada/blog/commit/074580065b21fbda…
694 to avoid GNUisms, so in the eventual case that I decide to e.g.: stop us…
695 GNU/Linux system like NixOS and use a *BSD system instead, I am covered.…
696 &lt;p&gt;In other projects I would probably add a &lt;code&gt;shell.nix&…
697 versions of the tools that I am using, but I am trying to avoid Nix while
698 building this blog as much as I can, mainly because it is not available
699 everywhere (e.g.: *BSD systems).&lt;/p&gt;
700 &lt;p&gt;Go is the more important part: the tooling used to &lt;a href="…
701 written in
702 Go&lt;/a&gt;. Go
703 is a good language when you want to ensure that things will work for a l…
704 time because of its &lt;a href="https://go.dev/blog/compat"&gt;backwards…
705 guarantee&lt;/a&gt;. Also I don't expect Google dropping Go
706 development soon, but even if this happen (&lt;a href="https://killedbyg…
707 Google&amp;quot;&lt;/a&gt; is a thing after all), it is very likely
708 some other group or company would adopt its development quickly, conside…
709 &lt;a href="https://www.tiobe.com/tiobe-index/go/"&gt;how popular the la…
710 &lt;p&gt;However, the &lt;a href="https://github.com/thiagokokada/blog/b…
711 modules&lt;/a&gt; that I depend
712 are another story:&lt;/p&gt;
713 &lt;ul&gt;
714 &lt;li&gt;&lt;a href="https://github.com/elliotchance/orderedmap/"&gt;el…
715 ordered map implementation that I use until Go adds it in the &lt;a href…
716 library&lt;/a&gt;&lt;/li&gt;
717 &lt;li&gt;&lt;a href="https://github.com/gorilla/feeds"&gt;gorilla/feeds…
718 &lt;li&gt;&lt;a href="https://github.com/gosimple/slug"&gt;gosimple/slug…
719 &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Slug"&gt;s…
720 library&lt;/li&gt;
721 &lt;li&gt;&lt;a href="https://github.com/yuin/goldmark"&gt;yuin/goldmark…
722 renderer&lt;/li&gt;
723 &lt;li&gt;&lt;a href="https://github.com/teekennedy/goldmark-markdown"&g…
724 a renderer for Goldmark to render back to Markdown (since Goldmark itself
725 doesn't have this capacity)&lt;/li&gt;
726 &lt;/ul&gt;
727 &lt;p&gt;In common for all those modules are that they're clearly small …
728 maintained mostly by one developer. They're all very good, don't get me …
729 but they're still an reliability issue in the future. There is no guaran…
730 those repositories will not be deleted tomorrow, for example.&lt;/p&gt;
731 &lt;p&gt;Yes, &lt;a href="https://proxy.golang.org/"&gt;Go Proxy&lt;/a&g…
732 reading its page is that while it caches modules contents, this is not
733 guarantee:&lt;/p&gt;
734 &lt;blockquote&gt;
735 &lt;p&gt;proxy.golang.org does not save all modules forever. There are a…
736 reasons for this, but one reason is if proxy.golang.org is not able to d…
737 a suitable license. In this case, only a temporarily cached copy of the
738 module will be made available, and may become unavailable if it is remov…
739 from the original source and becomes outdated. The checksums will still
740 remain in the checksum database regardless of whether or not they have b…
741 unavailable in the mirror.&lt;/p&gt;
742 &lt;/blockquote&gt;
743 &lt;p&gt;This is why this is the first project that made sense to me to …
744 code of all modules inside the
745 &lt;a href="https://github.com/thiagokokada/blog/tree/0b97630d6b30551ffe…
746 directory in the repository, avoiding the risks I commented above. This …
747 me to ensure that this blog will still be publishable in the future, as …
748 I have a working Go toolchain (and Go toolchain makes this
749 &lt;a href="https://kokada.dev/blog/quick-bits-go-automatically-download…
750 &lt;p&gt;There are a few other things that can bitrot this blog, for exa…
751 nowhere. I always try to use
752 &lt;a href="https://en.wikipedia.org/wiki/Permalink"&gt;permalinks&lt;/a…
753 the only actual way to ensure those links would work in the future would…
754 point them to &lt;a href="https://archive.org/"&gt;archive.org&lt;/a&gt;…
755 exist forever). Maybe something to fix in the future, hope not in the far
756 future, before things start to break.&lt;/p&gt;</description><pubDate>Sa…
757 end up with a &lt;a href="https://github.com/thiagokokada/nix-configs/"&…
758 with many things that are interesting for one reason or another, but it …
759 listed anywhere (well, except if you are the kind of person that reads &…
760 &lt;p&gt;So kind in the same spirit as my &lt;a href="https://kokada.dev…
761 Go&lt;/a&gt;, here is
762 a list of modules that I find neat in NixOS and are not default already.…
763 the list is unordered since this makes it easier to update in the future…
764 find something else, but also I don't want to think too hard about an or…
765 here.&lt;/p&gt;
766 &lt;p&gt;With all above, let's start.&lt;/p&gt;
767 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/6afb255d976f…
768 &lt;p&gt;&lt;a href="https://www.nftables.org/"&gt;nftables&lt;/a&gt; is…
769 &lt;blockquote&gt;
770 &lt;p&gt;nftables is a subsystem of the Linux kernel providing filtering…
771 classification of network packets/datagrams/frames.&lt;/p&gt;
772 &lt;/blockquote&gt;
773 &lt;p&gt;It is basically a replacement of the venerable
774 &lt;a href="https://en.wikipedia.org/wiki/Iptables"&gt;iptables&lt;/a&gt…
775 default program to configure the famous &lt;code&gt;networking.firewall&…
776 &lt;a href="https://wiki.nixos.org/wiki/Firewall"&gt;Firewall&lt;/a&gt; …
777 &lt;p&gt;To enable, it is simple, just add to your configuration:&lt;/p&…
778 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
779 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
780 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
781 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And thanks t…
782 still work as expect: any service that you set &lt;code&gt;openFirewall …
783 have its ports open, if you set &lt;code&gt;networking.firewall.allowPin…
784 still disable pings like before, etc.&lt;/p&gt;
785 &lt;p&gt;If you look at the documentation of the above option, you will …
786 following warning:&lt;/p&gt;
787 &lt;blockquote&gt;
788 &lt;p&gt;Note that if you have Docker enabled you will not be able to us…
789 without intervention. Docker uses iptables internally to setup NAT for
790 containers. This module disables the ip_tables kernel module, however Do…
791 automatically loads the module. Please see
792 &lt;a href="https://github.com/NixOS/nixpkgs/issues/24318#issuecomment-2…
793 more information.&lt;/p&gt;
794 &lt;/blockquote&gt;
795 &lt;p&gt;I don't use Docker (switched to Podman instead for quite a long…
796 don't know how bad the situation is. Also keep in mind that &lt;code&gt;…
797 offer &lt;code&gt;iptables-compat&lt;/code&gt; for compatibility with ol…
798 most likely Docker doing something weird here.&lt;/p&gt;
799 &lt;p&gt;Now, the actual advantage from the user here is not clear: the …
800 from my point of view (and the reason I used to use in other distros lik…
801 is the improved syntax, however if you are using the declarative NixOS's
802 Firewall you are not interacting with either &lt;code&gt;iptables&lt;/co…
803 anyway. &lt;code&gt;nftables&lt;/code&gt; is supposed to be more efficie…
804 will care about this.&lt;/p&gt;
805 &lt;p&gt;However if you are the kind of person that needs custom rules, …
806 &lt;code&gt;nftables&lt;/code&gt; does bring a few benefits, including
807 &lt;code&gt;networking.nftables.checkRuleset&lt;/code&gt; (enabled by de…
808 ruleset has syntax errors during build time. Really valuable to avoid is…
809 only after switch.&lt;/p&gt;
810 &lt;p&gt;Anyway, this is one of those options that I think it should be …
811 a long time, since most of the new development in NixOS firewall seems t…
812 focusing &lt;code&gt;nftables&lt;/code&gt; for a while.&lt;/p&gt;
813 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/877d19523edc…
814 &lt;p&gt;&lt;a href="https://github.com/NixOS/nixpkgs/pull/308801"&gt;Th…
815 today, but it has been available for a while (~2 months if you're using
816 &lt;code&gt;nixos-unstable&lt;/code&gt;). Finally someone is rewriting
817 &lt;a href="https://github.com/NixOS/nixpkgs/blob/b1eff03c35aa7c90ab3a4d…
818 the Perl script that is called everytime you run &lt;code&gt;nixos-rebui…
819 &lt;p&gt;Now, I am not one of those &amp;quot;rewrite in Rust&amp;quot; …
820 definitely worth it: &lt;code&gt;switch-to-configuration.pl&lt;/code&gt;…
821 code in NixOS that most people avoid touching at the fear of breaking
822 something. There is a reason why
823 &lt;a href="https://github.com/NixOS/nixpkgs/commit/eeb2588a59c938042b74…
824 is as convoluted as it is, because even if it is a messy shell script, m…
825 people preferred to workaround issues from the &lt;code&gt;switch-to-con…
826 inside it than trying to understand the mess that &lt;code&gt;switch-to-…
827 is.&lt;/p&gt;
828 &lt;p&gt;Trying this one is easy:&lt;/p&gt;
829 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
830 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
831 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
832 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
833 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
834 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
835 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Yes, you nee…
836 is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;
837 &lt;p&gt;By the way, what is the reason you would want to set &lt;code&g…
838 and updated by e.g.: image upgrades instead of modifying root.&lt;/p&gt;
839 &lt;p&gt;Enabling &lt;code&gt;switch-to-configuration-ng&lt;/code&gt; ri…
840 but one of the advantages that I saw is that system switches are (slight…
841 faster:&lt;/p&gt;
842 &lt;pre&gt;&lt;code&gt;$ hyperfine &amp;quot;sudo nixos-rebuild switch&a…
843 Benchmark 1: sudo nixos-rebuild switch
844 Time (mean ± σ): 3.576 s ± 0.035 s [User: 0.004 s, System:…
845 Range (min … max): 3.522 s … 3.645 s 10 runs
846 &lt;/code&gt;&lt;p&gt;&lt;code&gt;$ hyperfine &amp;quot;sudo nixos-rebui…
847 Benchmark 1: sudo nixos-rebuild switch
848 Time (mean ± σ): 3.394 s ± 0.080 s [User: 0.004 s, System: 0…
849 Range (min … max): 3.325 s … 3.608 s 10 runs
850 &lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;&lt;p&gt;&lt;/p&gt;
851 &lt;p&gt;But yes, the difference is not enough to make a significant imp…
852 not the objective anyway. The real reason for the rewrite is to make it …
853 to collaborate. I hope one day we also have someone brave enough to rewr…
854 &lt;code&gt;nixos-rebuild&lt;/code&gt; script in something saner.&lt;/p&…
855 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/cce9aef6fd8f…
856 &lt;p&gt;A quick recap on how a modern Linux distro generally boots: the…
857 that the bootloader (say &lt;a href="https://www.gnu.org/software/grub/"…
858 &lt;a href="https://systemd.io/BOOT/"&gt;systemd-boot&lt;/a&gt;) loads i…
859 ramdisk&lt;/em&gt;), a small image that runs from RAM and includes the L…
860 some utilities that are responsible for setting up the main system. For
861 example, one of the responsibilities of the &lt;code&gt;initrd&lt;/code&…
862 start init system (&lt;code&gt;systemd&lt;/code&gt;).&lt;/p&gt;
863 &lt;p&gt;It may surprising that this &lt;code&gt;initrd&lt;/code&gt; ima…
864 &lt;code&gt;systemd&lt;/code&gt;. Traditionally &lt;code&gt;initrd&lt;/c…
865 minimal runtime (e.g.: &lt;a href="https://www.busybox.net/"&gt;busybox&…
866 can also do this job since a long time ago. It is just the role of the d…
867 to integrate &lt;code&gt;systemd&lt;/code&gt; inside the &lt;code&gt;ini…
868 &lt;p&gt;This is what &lt;code&gt;boot.initrd.systemd&lt;/code&gt; does:…
869 It make a few subtle changes:&lt;/p&gt;
870 &lt;ul&gt;
871 &lt;li&gt;If you are using &lt;a href="https://wiki.nixos.org/wiki/Full_…
872 LUKS&lt;/a&gt;, you will get a
873 different password prompt at login&lt;/li&gt;
874 &lt;li&gt;You will get &lt;code&gt;initrd&lt;/code&gt; time information …
875 boot time
876 &lt;ul&gt;
877 &lt;li&gt;You can get even more information (bootloader) if you also use
878 &lt;code&gt;systemd-boot&lt;/code&gt;&lt;/li&gt;
879 &lt;/ul&gt;
880 &lt;/li&gt;
881 &lt;li&gt;You will also get &lt;code&gt;systemd&lt;/code&gt; style statu…
882 only afterwards)&lt;/li&gt;
883 &lt;/ul&gt;
884 &lt;p&gt;But I think the main reason is that since &lt;code&gt;systemd&l…
885 make boot more reliable, especially in challenging situations (like boot…
886 from network). I can't say that I have any system like this to test if i…
887 actually more reliable or not, but I don't remember having any issues si…
888 set &lt;code&gt;boot.initrd.systemd.enable = true&lt;/code&gt;, so there…
889 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/b4a09f1f9d15…
890 &lt;p&gt;If there is something in that list that has a good chance that …
891 already, it is this one, especially if you're using
892 &lt;a href="https://wayland.freedesktop.org/"&gt;Wayland&lt;/a&gt;. Stil…
893 to include in this list since &lt;a href="https://www.pipewire.org/"&gt;…
894 &lt;p&gt;The experience with PipeWire until now for me was seamless: I n…
895 issues with it, all my applications still work exactly as it always work…
896 also didn't had any issues with
897 &lt;a href="https://www.freedesktop.org/wiki/Software/PulseAudio/"&gt;Pu…
898 while, but I still remember when I first tried PulseAudio during the 0.x…
899 Fedora and having tons of issues. So bonus points for PipeWire developer…
900 polishing the experience of enough that most people will feel no differe…
901 &lt;p&gt;To enable PipeWire, I would recommend:&lt;/p&gt;
902 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
903 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
904 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
905 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
906 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
907 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
908 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
909 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
910 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
911 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This enables…
912 compatibility with desktop applications (you can also enable
913 &lt;a href="https://jackaudio.org/"&gt;&lt;code&gt;jack&lt;/code&gt;&lt;…
914 It also enables &lt;a href="https://github.com/heftig/rtkit"&gt;&lt;code…
915 to get (soft) realtime, helping avoiding cracks during high CPU load.&lt…
916 &lt;p&gt;I also recommend taking a look at the &lt;a href="https://wiki.…
917 article&lt;/a&gt;, that has multiple interesting
918 configurations that can be added for low-latency setups or improved code…
919 Bluetooth devices.&lt;/p&gt;
920 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/c9ec8289781a…
921 &lt;p&gt;There is a good change that you're using
922 &lt;a href="https://www.networkmanager.dev/"&gt;&lt;code&gt;NetworkManag…
923 especially for Wi-Fi. And if that is the case, I can't recommend enough
924 changing the backend from the default &lt;code&gt;wpa_supplicant&lt;/cod…
925 &lt;a href="https://iwd.wiki.kernel.org/"&gt;&lt;code&gt;iwd&lt;/code&gt…
926 &lt;p&gt;If you think that your Wi-Fi takes a long time to connect/re-co…
927 because &lt;code&gt;wpa_supplicant&lt;/code&gt;. &lt;code&gt;iwd&lt;/cod…
928 since switching to it I never felt that my Wi-Fi was worse than other OS…
929 generally slightly better than Windows, but keep in mind that this is a
930 non-scientific comparison).&lt;/p&gt;
931 &lt;p&gt;Not saying that I never had Wi-Fi issues since switching to &lt…
932 switching back to &lt;code&gt;wpa_supplicant&lt;/code&gt; in those cases…
933 the same or worse), so I assume either bad hardware or drivers in those …
934 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/d5badef1e041…
935 &lt;p&gt;&lt;em&gt;Added in 2024-08-22&lt;/em&gt;&lt;/p&gt;
936 &lt;p&gt;Most Linux distro nowadays mount &lt;code&gt;/tmp&lt;/code&gt; …
937 &lt;a href="https://en.wikipedia.org/wiki/Tmpfs"&gt;tmpfs&lt;/a&gt;, sto…
938 making them actually temporary, e.g.: does not persist between reboots).…
939 is a &lt;a href="https://lwn.net/Articles/499410/"&gt;long discussion&lt…
940 sense or not, but it is a fact that using &lt;code&gt;/tmp&lt;/code&gt; …
941 generally makes sense.&lt;/p&gt;
942 &lt;p&gt;However, NixOS still stores &lt;code&gt;/tmp&lt;/code&gt; insid…
943 this is because Nix, by default, still builds everything in &lt;code&gt;…
944 defaults to &lt;code&gt;/tmp&lt;/code&gt; if not set). To fix the situat…
945 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
946 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
947 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
948 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
949 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
950 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
951 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This ensures…
952 for large files.&lt;/p&gt;
953 &lt;p&gt;If you don't want to use &lt;code&gt;/tmp&lt;/code&gt; inside t…
954 least setting &lt;code&gt;boot.tmp.cleanOnBoot = true&lt;/code&gt;. This…
955 mistakenly writing a program that depends in &lt;code&gt;/tmp&lt;/code&g…
956 this is the behavior that most other distros expects.&lt;/p&gt;
957 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/68142254d202…
958 &lt;p&gt;&lt;em&gt;Added in 2024-08-22&lt;/em&gt;&lt;/p&gt;
959 &lt;p&gt;Have a system with small amounts of RAM? &lt;del&gt;You can dow…
960 just click this &lt;a href="https://downloadmoreram.com/"&gt;link&lt;/a&…
961 you can actually improve RAM usage by compressing it. This is what
962 &lt;a href="https://en.wikipedia.org/wiki/Zram"&gt;&lt;code&gt;zram&lt;/…
963 device using part of your RAM that will be compressed.&lt;/p&gt;
964 &lt;p&gt;While this means that whatever is in the compressed part can't …
965 (it needs to be decompressed first), it means you can store a lot more
966 information. And since RAM is much faster than disk, this generally is a…
967 trade-off. It is still recommended that you have some swap space though,…
968 to swap pages that are unused.&lt;/p&gt;
969 &lt;p&gt;To enable it, you can do:&lt;/p&gt;
970 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
971 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
972 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
973 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
974 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
975 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
976 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can play…
977 either &lt;code&gt;lz4&lt;/code&gt; or &lt;code&gt;zstd&lt;/code&gt;. It…
978 fast, since you probably want to minimise CPU usage. Well, unless you ha…
979 very good CPU and small amounts of RAM, them it may make sense to use an
980 algorithm that compress better but uses more CPU.&lt;/p&gt;
981 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/5356420466c4…
982 &lt;p&gt;&lt;em&gt;Added in 2024-08-22&lt;/em&gt;&lt;/p&gt;
983 &lt;p&gt;Do you have a SSD? If so, you probably want to
984 &lt;a href="https://en.wikipedia.org/wiki/Trim_(computing)"&gt;trim&lt;/…
985 good performance. This should be as easy as:&lt;/p&gt;
986 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
987 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
988 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
989 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;One caveat t…
990 need to enable &lt;code&gt;boot.initrd.luks.devices.&amp;lt;name&amp;gt;…
991 &lt;code&gt;fstrim&lt;/code&gt; will not work. The reason that this is n…
992 because there are some &lt;a href="https://asalor.blogspot.com/2011/08/t…
993 implications&lt;/a&gt;.
994 It shouldn't be an issue for most people, but if you are paranoid please…
995 your risks first.&lt;/p&gt;
996 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/e83fc891118e…
997 &lt;p&gt;&lt;em&gt;Added in 2024-08-22&lt;/em&gt;&lt;/p&gt;
998 &lt;p&gt;This is one of my favorites. Do you want to have the power to r…
999 other architectures like
1000 &lt;a href="https://en.wikipedia.org/wiki/ARM_architecture_family"&gt;AR…
1001 &lt;a href="https://en.wikipedia.org/wiki/RISC-V"&gt;RISC-V&lt;/a&gt;? I…
1002 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1003 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1004 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1005 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will in…
1006 &lt;a href="https://en.wikipedia.org/wiki/Binfmt_misc"&gt;&lt;code&gt;bi…
1007 automatically detect when a binary from another architecture is run,
1008 running it with the QEMU emulator instead.&lt;/p&gt;
1009 &lt;p&gt;Now, keep in mind that you still need e.g.: libraries for the t…
1010 architecture. However this is where the Nix magic comes in, you can easi…
1011 compile something to another architecture as:&lt;/p&gt;
1012 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1013 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1014 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1015 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1016 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1017 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1018 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1019 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1020 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1021 architecture, everything works as expect.&lt;/p&gt;
1022 &lt;p&gt;You also need to temper your expectations: QEMU emulation is sl…
1023 sufficient fast to build small programs, but if you need to build someth…
1024 bigger, I would recommend you to do it via &lt;a href="https://kokada.de…
1025 instead&lt;/a&gt;.&lt;/p&gt;
1026 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/d9cf6ea6f809…
1027 &lt;p&gt;&lt;em&gt;Added in 2024-08-22&lt;/em&gt;&lt;/p&gt;
1028 &lt;p&gt;Someone in
1029 &lt;a href="https://lobste.rs/s/ymmale/unordered_list_hidden_gems_inside…
1030 remembered me of this gem: &lt;a href="https://github.com/bus1/dbus-brok…
1031 a high performance implementation of
1032 &lt;a href="https://en.wikipedia.org/wiki/D-Bus"&gt;D-Bus&lt;/a&gt;.&lt;…
1033 &lt;p&gt;For those who doesn't know, D-Bus is the &lt;a href="https://en…
1034 Communication&lt;/a&gt;
1035 protocol used mostly in Linux desktop. And distros like
1036 &lt;a href="https://archlinux.org/news/making-dbus-broker-our-default-d-…
1037 and
1038 &lt;a href="https://fedoraproject.org/wiki/Changes/DbusBrokerAsTheDefaul…
1039 already use it to default, so there aren't lots of reason to not use it.…
1040 &lt;h2&gt;&lt;a href="https://github.com/NixOS/nixpkgs/blob/6afb255d976f…
1041 &lt;p&gt;&lt;em&gt;Added in 2024-08-23&lt;/em&gt;&lt;/p&gt;
1042 &lt;p&gt;Here is one that I have no experience but got curious after thi…
1043 &lt;a href="https://lobste.rs/s/ymmale/unordered_list_hidden_gems_inside…
1044 &lt;blockquote&gt;
1045 &lt;p&gt;One more option to add is maybe &lt;code&gt;services.irqbalance…
1046 laptop it’s a life savior: no more freezes of the DE or video playback…
1047 heavy operations like e.g. compilation.&lt;/p&gt;
1048 &lt;/blockquote&gt;
1049 &lt;p&gt;Never tried it before but will give a try!&lt;/p&gt;</descripti…
1050 that you write for yourself. This blog post is the latter kind. What I a…
1051 to talk here is probably something most people know, but I didn't, and t…
1052 documentation is all scattered in the internet. So I am writing mostly to
1053 remember myself, in future, if I have the same kind of issue what I need…
1054 &lt;p&gt;The context: &lt;a href="https://mataroa.blog/"&gt;Mataroa&lt;/…
1055 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt; is hosted …
1056 &lt;a href="https://python-markdown.github.io/"&gt;python-markdown&lt;/a…
1057 &lt;a href="https://commonmark.org/"&gt;CommonMark&lt;/a&gt; specificati…
1058 incompatibilities. One of those incompatibilities with CommonMark is the…
1059 sub lists are handled. From the documentation:&lt;/p&gt;
1060 &lt;blockquote&gt;
1061 &lt;p&gt;The syntax rules clearly state that when a list item consists o…
1062 paragraphs, “each subsequent paragraph in a list item must be indented…
1063 either 4 spaces or one tab” (emphasis added). However, many implementa…
1064 do not enforce this rule and allow less than 4 spaces of indentation. The
1065 implementers of Python-Markdown consider it a bug to not enforce this ru…
1066 &lt;/blockquote&gt;
1067 &lt;p&gt;CommonMark &lt;a href="https://spec.commonmark.org/0.31.2/#list…
1068 restrictions&lt;/a&gt;, allowing a sublist to
1069 be defined with just 2 spaces of indentation.&lt;/p&gt;
1070 &lt;p&gt;So I have automated all posts from this blog &lt;a href="https:…
1071 Go&lt;/a&gt; and
1072 a CommonMark renderer called &lt;a href="https://github.com/yuin/goldmar…
1073 them re-render the Markdown to Mataroa using a &lt;a href="https://githu…
1074 renderer&lt;/a&gt; before publising to
1075 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt;, because t…
1076 transformations in the original Markdown. It mostly works fine except fo…
1077 lists, thanks to the fact that the Markdown renderer I am using renders …
1078 lists with 2 spaces.&lt;/p&gt;
1079 &lt;p&gt;The only reason sub lists are working right now is because
1080 &lt;a href="https://gluer.org/"&gt;@ratsclub&lt;/a&gt; fixed this issue …
1081 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt; runs. But …
1082 the official instance if I ever need to migrate.&lt;/p&gt;
1083 &lt;p&gt;The solution? Let's fix this in a
1084 &lt;a href="https://github.com/teekennedy/goldmark-markdown/pull/21"&gt;…
1085 I have code to fix the issue, how can I use it without waiting upstream …
1086 merge my code?&lt;/p&gt;
1087 &lt;p&gt;If you are using Go modules it is easy, you just need to use th…
1088 directive&lt;/a&gt;:&lt;/p&gt;
1089 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1090 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1091 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1092 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1093 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1094 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1095 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1096 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1097 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1098 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1099 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1100 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1101 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1102 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1103 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1104 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1105 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1106 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1107 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1108 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1109 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will re…
1110 fork in &lt;code&gt;github.com/thiagokokada/goldmark-markdown&lt;/code&g…
1111 reproducibility of modules since Go automatically pins the commit.&lt;/p…
1112 &lt;p&gt;Since the Go format for versions is quite unique, you can just …
1113 desired branch (e.g.: instead of &lt;code&gt;v0.0.0-20240820111219-f3077…
1114 use &lt;code&gt;add-sublist-length-opt&lt;/code&gt; that is the branch n…
1115 fix the format.&lt;/p&gt;</description><pubDate>Tue, 20 Aug 2024 00:00:0…
1116 &lt;a href="https://github.com/elliotchance/orderedmap/"&gt;elliotchance…
1117 choice of ordered maps (since Go &lt;a href="https://kokada.dev/blog/an-…
1118 one&lt;/a&gt; in
1119 standard library yet). I recently did a
1120 &lt;a href="https://github.com/elliotchance/orderedmap/pull/41"&gt;PR&lt…
1121 iterators, because I find them neat, however I was avoiding to use it in…
1122 code that generates this &lt;a href="https://github.com/thiagokokada/blo…
1123 1.23 was just released and is still not the default Go in
1124 &lt;a href="https://github.com/NixOS/nixpkgs"&gt;nixpkgs&lt;/a&gt;.&lt;/…
1125 &lt;p&gt;I decided that I would create a
1126 &lt;a href="https://github.com/thiagokokada/blog/pull/2"&gt;branch&lt;/a…
1127 months, until I decided to try to run the code locally and got this:&lt;…
1128 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1129 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1130 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1131 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1132 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1133 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1134 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1135 page&lt;/a&gt;:&lt;/p&gt;
1136 &lt;blockquote&gt;
1137 &lt;p&gt;Starting in Go 1.21, the Go distribution consists of a go comma…
1138 bundled Go toolchain, which is the standard library as well as the compi…
1139 assembler, and other tools. The go command can use its bundled Go toolch…
1140 as well as other versions that it finds in the local PATH or downloads as
1141 needed.&lt;/p&gt;
1142 &lt;/blockquote&gt;
1143 &lt;p&gt;There are a bunch of rules here that I am not going to enter in…
1144 recommend you to read the official documentation), but a quick summary:&…
1145 &lt;ul&gt;
1146 &lt;li&gt;
1147 &lt;p&gt;Go will download a toolchain when either &lt;code&gt;go&lt;/cod…
1148 is set to a Go version higher than your current &lt;code&gt;go&lt;/code&…
1149 &lt;ul&gt;
1150 &lt;li&gt;But only if your &lt;code&gt;go&lt;/code&gt; binary is at leas…
1151 version that introduces this behavior&lt;/li&gt;
1152 &lt;/ul&gt;
1153 &lt;/li&gt;
1154 &lt;li&gt;
1155 &lt;p&gt;You can force a specific toolchain with &lt;code&gt;GOTOOLCHAIN…
1156 e.g.: &lt;code&gt;GOTOOLCHAIN=1.23&lt;/code&gt;&lt;/p&gt;
1157 &lt;ul&gt;
1158 &lt;li&gt;The default value for &lt;code&gt;GOTOOLCHAIN&lt;/code&gt; is …
1159 behavior described in this post&lt;/li&gt;
1160 &lt;li&gt;You can also set to &lt;code&gt;local&lt;/code&gt; to always u…
1161 previous behaviour pre-1.21 Go&lt;/li&gt;
1162 &lt;li&gt;There is also &lt;code&gt;&amp;lt;name&amp;gt;+auto&lt;/code&g…
1163 docs&lt;/li&gt;
1164 &lt;/ul&gt;
1165 &lt;/li&gt;
1166 &lt;li&gt;
1167 &lt;p&gt;The downloaded toolchains go to whatever your &lt;code&gt;GOPAT…
1168 &lt;code&gt;golang.org/toolchain&lt;/code&gt; module, and version &lt;co…
1169 example:&lt;/p&gt;
1170 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1171 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1172 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1173 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1174 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1175 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1176 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1177 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1178 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1179 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1180 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1181 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1182 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1183 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1184 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1185 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1186 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&…
1187 &lt;/ul&gt;
1188 &lt;p&gt;By the way, this only works well because Go toolchain binaries …
1189 &lt;p&gt;While I don't like a program downloading random binaries from t…
1190 like what Go is doing here. It makes the whole bootstrapping process for…
1191 project much easier: as long as you have a reasonable up-to-date &lt;cod…
1192 your &lt;code&gt;PATH&lt;/code&gt;, you should be ready to go (pun inten…
1193 already reasonable secure, ensuring that each module have a proper check…
1194 long as nobody else can publish modules in &lt;code&gt;golang.org/toolch…
1195 can't see much of a security issue here, but I am not a security expert.…
1196 &lt;p&gt;But if you don't like this behavior, you can always disable it …
1197 &lt;code&gt;GOTOOLCHAIN=local&lt;/code&gt;. And just do not forget to se…
1198 &lt;a href="https://brandur.org/fragments/go-version-matrix"&gt;CI&lt;/a…
1199 about Go versions.&lt;/p&gt;</description><pubDate>Mon, 19 Aug 2024 00:0…
1200 language&lt;/a&gt;, and has some
1201 good qualities that makes up for its flaws. However, this doesn't mean I…
1202 the language couldn't be better, far from it.&lt;/p&gt;
1203 &lt;p&gt;This blog post is a list of things that I miss from Go from oth…
1204 Some of the things here could probably be implemented soon, some other w…
1205 probably need a major revision of the language. The list is unordered, b…
1206 this makes it easier for me to update in the future if I found something…
1207 but also because I don't want to think too hard about giving each point …
1208 rank.&lt;/p&gt;
1209 &lt;p&gt;With all above, let's start.&lt;/p&gt;
1210 &lt;h2&gt;Ordered maps in standard library&lt;/h2&gt;
1211 &lt;p&gt;When I first learned about
1212 &lt;a href="https://docs.python.org/3/library/stdtypes.html#typesmapping…
1213 Python it quickly became one of my favorite data structures ever. They're
1214 extremely versatile, and most modern programming languages have something
1215 similar in its standard library. Go isn't different, it has
1216 &lt;a href="https://go.dev/blog/maps"&gt;&lt;code&gt;map&lt;/code&gt;&lt…
1217 table&lt;/a&gt;. However &lt;code&gt;map&lt;/code&gt; in Go are
1218 quirky, for example:&lt;/p&gt;
1219 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1220 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1221 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1222 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1223 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1224 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1225 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1226 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1227 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1228 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="chroma…
1229 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1230 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1231 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1232 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1233 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1234 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1235 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1236 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1237 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1238 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1239 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1240 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1241 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1242 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1243 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1244 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1245 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1246 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1247 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1248 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1249 elements, but Go actually &lt;a href="https://victoriametrics.com/blog/g…
1250 instance&lt;/a&gt;:&lt;/p&gt;
1251 &lt;blockquote&gt;
1252 &lt;p&gt;But here’s the deal, while the hash function used for maps in…
1253 consistent across all maps with &lt;strong&gt;the same key type&lt;/stro…
1254 that hash function is different for each map instance. So, when you crea…
1255 new map, Go generates a random seed just for that map.&lt;/p&gt;
1256 &lt;/blockquote&gt;
1257 &lt;p&gt;While I understand the reason for this (i.e.: to avoid develope…
1258 specific iteration order), I still find it weird, and I think this is so…
1259 unique for Go. This decision means that even if you don't care about a s…
1260 order, you will still need to sort the map before doing something else i…
1261 want reproducibility, something that I care a lot.&lt;/p&gt;
1262 &lt;p&gt;The fix for this? Go could offer an ordered map implementation …
1263 standard library. An ordered map ensure that the iteration order of the …
1264 the same as the insertion order (that is, by the way, a powerful propert…
1265 allow maps to be used in other contexts, not just my pet peeve above).&l…
1266 &lt;p&gt;Python actually does this for any dictionaries since &lt;a href…
1267 3.6&lt;/a&gt;, but it offered an
1268 &lt;a href="https://docs.python.org/3/library/collections.html#collectio…
1269 before it (and &lt;code&gt;OrderedDict&lt;/code&gt; still has some metho…
1270 that maybe useful in specific cases).&lt;/p&gt;
1271 &lt;p&gt;Before generics it would be impossible to have a type-safe API …
1272 structure without introducing a new data type in the language (like &lt;…
1273 but now Go has generics so it is not an issue anymore. The other issue i…
1274 you would be forced to iterate manually in this new data structure, but …
1275 to the new &lt;a href="https://tip.golang.org/doc/go1.23#language"&gt;&l…
1276 Go 1.23, it means we can iterate in an ordered map as a library almost e…
1277 like we can do as a &lt;code&gt;map&lt;/code&gt;:&lt;/p&gt;
1278 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1279 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1280 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1281 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1282 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1283 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1284 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1285 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1286 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1287 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1288 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1289 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1290 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now, of cour…
1291 with third party implementations, e.g.: I am using this
1292 &lt;a href="https://github.com/elliotchance/orderedmap"&gt;one&lt;/a&gt;…
1293 being in standard library reduces the friction: if there was some
1294 implementation in standard library, I would generally prefer it unless I…
1295 some specific needs. However when the standard library doesn't offer wha…
1296 need, I need to find it myself a suitable library, and this ends up taki…
1297 since generally there are lots of alternatives.&lt;/p&gt;
1298 &lt;h2&gt;Keyword and default arguments for functions&lt;/h2&gt;
1299 &lt;p&gt;Something that comes straight from Python that I miss sometimes…
1300 you can do things like this when declaring a function:&lt;/p&gt;
1301 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1302 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1303 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1304 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1305 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1306 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1307 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class="chroma…
1308 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1309 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1310 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1311 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1312 for Go standard library, for example, &lt;code&gt;string.Replace&lt;/cod…
1313 &lt;blockquote&gt;
1314 &lt;p&gt;&lt;code&gt;func Replace(s, old, new string, n int) string&lt;/…
1315 &lt;p&gt;Replace returns a copy of the string s with the first n non-ove…
1316 instances of old replaced by new. If old is empty, it matches at the
1317 beginning of the string and after each UTF-8 sequence, yielding up to k+1
1318 replacements for a k-rune string. If n &amp;lt; 0, there is no limit on …
1319 of replacements.&lt;/p&gt;
1320 &lt;/blockquote&gt;
1321 &lt;p&gt;If Go had default arguments, &lt;code&gt;Replace&lt;/code&gt; c…
1322 &lt;code&gt;strings.ReplaceAll&lt;/code&gt; (since this is basically wha…
1323 &lt;code&gt;strings.Replace(s, old, new, -1)&lt;/code&gt;).&lt;/p&gt;
1324 &lt;h2&gt;Nullability (or nillability)&lt;/h2&gt;
1325 &lt;p&gt;I talked I little about this in &lt;a href="https://kokada.dev/…
1326 Go&lt;/a&gt;, but I want to
1327 expand here.&lt;/p&gt;
1328 &lt;p&gt;First, I don't think the language needs to support the generic …
1329 nullability, that would be either having proper Union or Sum types. Kotl…
1330 AFAIK doesn't support neither, but my 2 years experience with Kotlin sho…
1331 that just having nullable types already helped a lot in ensuring type sa…
1332 &lt;p&gt;Second, I do feel that Go has less issues with &lt;code&gt;nil&…
1333 because its decision of using zero values instead of &lt;code&gt;nil&lt;…
1334 for example, a string can never be &lt;code&gt;nil&lt;/code&gt;, however…
1335 means that this is fine:&lt;/p&gt;
1336 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1337 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1338 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1339 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;However:&lt;…
1340 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1341 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1342 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1343 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Still, I get…
1344 languages that offer nullables (heck, even Python with
1345 &lt;a href="https://www.mypy-lang.org/"&gt;&lt;code&gt;mypy&lt;/code&gt;…
1346 &lt;p&gt;Sadly this is the change in this post that is more likely to ne…
1347 new revision of the language.
1348 &lt;a href="https://github.com/golang/go/issues/49202"&gt;nillability&lt…
1349 but it is really unlikely it can be done without breaking backwards
1350 compatibility.&lt;/p&gt;
1351 &lt;p&gt;It could be done the Java way by adding a &lt;code&gt;nullable&…
1352 library (&lt;a href="https://jcp.org/en/jsr/detail?id=305"&gt;JSR305&lt;…
1353 &lt;a href="https://stackoverflow.com/questions/2289694/what-is-the-stat…
1354 dead&lt;/a&gt;
1355 by many shows how difficult it is to do something like this without a ma…
1356 change in the language. Dart is the only language that I know that &lt;a…
1357 successfully&lt;/a&gt;, but
1358 definitely it was not without its pains. And the fact that most people t…
1359 program in Dart probably does because of Flutter (that eventually requir…
1360 newer versions with null-safety) is not a good sign.&lt;/p&gt;
1361 &lt;h2&gt;Lambdas&lt;/h2&gt;
1362 &lt;p&gt;&lt;em&gt;Added in 2024-08-18&lt;/em&gt;&lt;/p&gt;
1363 &lt;p&gt;Go is a surprising good language for some functional code, than…
1364 first class functions and closures. Sadly the syntax doesn't help, since…
1365 only way you can use anonymous functions in Go is using &lt;code&gt;func…
1366 the types are complex, this can result in some convoluted code. Take the
1367 example from the &lt;a href="https://go.dev/wiki/RangefuncExperiment"&gt…
1368 experiment&lt;/a&gt;:&lt;/p&gt;
1369 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1370 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1371 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1372 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1373 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1374 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1375 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1376 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1377 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1378 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1379 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1380 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If Go had a …
1381 could be simplified a lot:&lt;/p&gt;
1382 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1383 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1384 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1385 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1386 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1387 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1388 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1389 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1390 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1391 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1392 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1393 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Or even some…
1394 the types to be elided in an unnamed function:&lt;/p&gt;
1395 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1396 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1397 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1398 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1399 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1400 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1401 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1402 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1403 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1404 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1405 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1406 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This feature…
1407 future version of the language, since they didn't close the
1408 &lt;a href="https://github.com/golang/go/issues/21498"&gt;issue&lt;/a&gt…
1409 about the possibility of this feature is still ongoing.&lt;/p&gt;
1410 &lt;h2&gt;Error on unused return values&lt;/h2&gt;
1411 &lt;p&gt;&lt;em&gt;Added in 2024-09-12&lt;/em&gt;&lt;/p&gt;
1412 &lt;p&gt;In a &lt;a href="https://kokada.dev/blog/my-coding-experience-w…
1413 LLMs&lt;/a&gt;, I talked about
1414 this function that I asked ChatGPT to generate to create a socket that a…
1415 a &lt;a href="https://pkg.go.dev/context"&gt;context&lt;/a&gt;:&lt;/p&gt;
1416 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1417 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1418 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1419 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1420 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1421 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1422 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1423 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1424 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1425 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1426 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1427 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1428 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1429 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1430 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1431 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1432 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1433 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1434 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1435 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1436 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1437 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;However whil…
1438 post&lt;/a&gt; about &amp;quot;The Error
1439 Model&amp;quot;, I realised that this function is lacking error check du…
1440 &lt;code&gt;conn.SetReadDeadline()&lt;/code&gt; calls:&lt;/p&gt;
1441 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1442 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1443 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1444 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1445 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1446 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1447 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1448 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1449 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1450 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1451 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1452 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1453 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1454 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1455 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1456 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1457 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1458 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1459 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1460 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1461 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1462 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1463 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1464 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1465 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1466 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1467 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1468 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1469 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1470 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I could blam…
1471 happening even in a Pull Request done by an actual human.&lt;/p&gt;
1472 &lt;p&gt;Ignoring errors is bad, especially because once the error is ig…
1473 gone, forever. You may have strange issues in the code that are impossib…
1474 debug because you can't know about something that doesn't exist. This is…
1475 the reasons I think exceptions are better, since this is the kind of err…
1476 would be impossible to ignore if the language had exceptions, and the ex…
1477 would eventually propagate in your stack until it is captured or you get…
1478 crash (with a stack trace to debug the issue).&lt;/p&gt;
1479 &lt;p&gt;Now, I don't think this is a fault of using error as values ins…
1480 exceptions. Go has the tools to encapsulate the errors and propagate them
1481 properly, like it is shown in the fixed code. But the fact that someone …
1482 this mistake without any warning or error from the compiler is bad.&lt;/…
1483 &lt;p&gt;If Go had a warning or error for unused return values, this wou…
1484 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1485 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1486 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1487 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1488 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now in this …
1489 a good reason. I can ask during a Pull Request why the committer is igno…
1490 it is lacking appropriate context, and maybe even ask for some comments …
1491 added why this would be safe. What can't happen is this being ignored by
1492 mistake.&lt;/p&gt;
1493 &lt;p&gt;I am not completely sure if I want this only for errors or for …
1494 though. There are lots of cases where ignoring non-error values is ok, b…
1495 also don't see the issue of having something like:&lt;/p&gt;
1496 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1497 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1498 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1499 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1500 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If anything,…
1501 only calling this function only for its side-effects.&lt;/p&gt;
1502 &lt;p&gt;By the way, yes, &lt;a href="https://github.com/kisielk/errchec…
1503 but if the language itself doesn't enforce this it means that there are …
1504 libraries that are probably mistakenly ignoring errors. And if the libra…
1505 ignoring errors by mistake, you can't do much when you actually have the…
1506 &lt;a href="https://github.com/NixOS/nixpkgs/blob/bb16119a4a7639ebbc91ad…
1507 option does not receive a derivation like most other packages, but inste…
1508 receives a function and returns an attribute set with all packages. Here…
1509 documentation:&lt;/p&gt;
1510 &lt;blockquote&gt;
1511 &lt;p&gt;This option allows you to override the Linux kernel used by Nix…
1512 things like external kernel module packages are tied to the kernel you�…
1513 using, it also overrides those. This option is a function that takes Nix…
1514 as an argument (as a convenience), and returns an attribute set containi…
1515 the very least an attribute kernel. Additional attributes may be needed
1516 depending on your configuration. For instance, if you use the NVIDIA X
1517 driver, then it also needs to contain an attribute &lt;code&gt;nvidia_x1…
1518 &lt;/blockquote&gt;
1519 &lt;p&gt;The kernel package itself is referenced by the
1520 &lt;a href="https://github.com/NixOS/nixpkgs/blob/bb16119a4a7639ebbc91ad…
1521 derivation inside this attribute set:&lt;/p&gt;
1522 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1523 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1524 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1525 with the same kernel version you are booting.&lt;/p&gt;
1526 &lt;p&gt;However one less obvious consequence about this is that if you …
1527 that come from &lt;code&gt;linuxPackages&lt;/code&gt;, say for example
1528 &lt;a href="https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os…
1529 or
1530 &lt;a href="https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/os…
1531 it is better to do:&lt;/p&gt;
1532 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1533 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1534 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1535 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1536 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1537 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1538 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1539 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Instead of:&…
1540 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1541 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1542 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1543 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1544 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1545 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1546 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1547 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now, I used …
1548 those packages depends in a specific kernel version for a reason, so get…
1549 them from &lt;code&gt;config.boot.kernelPackages&lt;/code&gt; reduces th…
1550 compatibility issue in the future.&lt;/p&gt;</description><pubDate>Thu, …
1551 of the workflow in this blog is &lt;a href="https://kokada.dev/blog/quic…
1552 Go&lt;/a&gt;. I
1553 basically write Markdown files with some special rules inside the
1554 &lt;a href="https://github.com/thiagokokada/blog"&gt;repository&lt;/a&gt…
1555 seconds, the CI (currently &lt;a href="https://github.com/thiagokokada/b…
1556 Actions&lt;/a&gt;)
1557 will take the latest commit, generate some files (since I use the &lt;a …
1558 itself&lt;/a&gt; as a
1559 backup blog) and publish to the &lt;a href="https://kokada.capivaras.dev…
1560 website&lt;/a&gt;.&lt;/p&gt;
1561 &lt;p&gt;Now, considering how much about &lt;a href="https://nixos.org/"…
1562 it should be a surprise that the workflow above has &lt;strong&gt;zero&l…
1563 it. I am not saying this blog will never have it, but I am only going to…
1564 this is necessary, for example if I start using a tool to build this blo…
1565 I generally don't expect it to be installed by the machine I am currently
1566 using. Go is an exception of this rule since it is relatively straightfo…
1567 install (just download the &lt;a href="https://go.dev/doc/install"&gt;bi…
1568 its &lt;a href="https://go.dev/doc/go1compat"&gt;stability guarantee&lt;…
1569 breakage. But most other things I consider moving targets, and I wouldn'…
1570 comfortable to use unless I have Nix to ensure reproducibility.&lt;/p&gt;
1571 &lt;p&gt;This is why the other tool that this blog (ab)uses during its w…
1572 &lt;a href="https://en.wikipedia.org/wiki/Make_(software)"&gt;&lt;code&g…
1573 build automation tool that exist. It is basically available in any *nix …
1574 confuse with &lt;a href="https://nixos.org/"&gt;Nix&lt;/a&gt;) system, f…
1575 macOS, by default. So it is the tool I choose to automatise some tasks i…
1576 blog, even if I consider writing a &lt;code&gt;Makefile&lt;/code&gt; (th…
1577 that &lt;code&gt;Make&lt;/code&gt; uses) kind of a lost, dark art.&lt;/p…
1578 &lt;p&gt;To be clear, the idea of this post is not to be a &lt;code&gt;M…
1579 explain some basic concepts, but if you want an actual tutorial a good o…
1580 be found &lt;a href="https://makefiletutorial.com/"&gt;here&lt;/a&gt;. A…
1581 thanks to the reasons above, you can use many other tools for a similar
1582 objective, like &lt;a href="https://github.com/casey/just"&gt;Justfiles&…
1583 &lt;a href="https://taskfile.dev/"&gt;Taskfiles&lt;/a&gt; (sadly it uses
1584 &lt;a href="https://kokada.dev/blog/generating-yaml-files-with-nix"&gt;Y…
1585 small script written in any language you want. The reason that I am writ…
1586 this post is why you should do it, not how.&lt;/p&gt;
1587 &lt;p&gt;A quick recap on how this blog works: inside the
1588 &lt;a href="https://github.com/thiagokokada/blog"&gt;repository&lt;/a&gt…
1589 Markdown post following the directory structure below
1590 (&lt;a href="https://github.com/thiagokokada/blog/tree/894a388c61ca3a38d…
1591 for the current version of this blog):&lt;/p&gt;
1592 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1593 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1594 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1595 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1596 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1597 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1598 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1599 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1600 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1601 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1602 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1603 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1604 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1605 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1606 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1607 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1608 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1609 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1610 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1611 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1612 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1613 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1614 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1615 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1616 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1617 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1618 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1619 &lt;code&gt;YYYY-MM-DD/XX-title-slug.md&lt;/code&gt; format. It &lt;stro…
1620 that will be automatically extract to be used as the post title, but oth…
1621 there is no other formatting rules. It is a highly optionated structure,…
1622 the nice thing about being optionated is that we can extract lots of
1623 information just from how the files are organised in the filesystem.&lt;…
1624 &lt;p&gt;Most of the magic that converts those Markdown files to actual …
1625 in the Go files that you can see above: &lt;code&gt;blog.go&lt;/code&gt;…
1626 in the repository and extracts the necessary information, &lt;code&gt;ma…
1627 responsible for the &lt;a href="https://capivaras.dev/"&gt;capivaras.dev…
1628 uses &lt;a href="https://mataroa.blog/"&gt;Mataroa&lt;/a&gt; platform), …
1629 responsible to do some transformations in the Markdown files before post…
1630 &lt;p&gt;While I could manage everything by just using &lt;code&gt;go&lt…
1631 commands, to make it easier to manager everything I have the following
1632 &lt;a href="https://github.com/thiagokokada/blog/blob/527466a2a7c8baae53…
1633 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1634 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1635 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1636 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1637 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1638 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1639 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1640 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1641 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1642 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1643 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1644 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1645 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1646 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1647 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1648 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1649 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1650 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1651 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1652 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1653 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1654 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1655 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1656 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1657 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1658 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1659 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1660 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1661 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1662 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1663 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1664 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1665 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1666 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1667 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1668 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1669 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1670 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1671 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1672 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1673 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1674 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For those un…
1675 &lt;a href="https://en.wikipedia.org/wiki/Make_(software)#Makefile"&gt;W…
1676 &lt;blockquote&gt;
1677 &lt;p&gt;Each rule begins with a &lt;em&gt;dependency line&lt;/em&gt; wh…
1678 name followed by a colon (:) and optionally a list of targets on which t…
1679 rule's target depends, its prerequisites.&lt;/p&gt;
1680 &lt;/blockquote&gt;
1681 &lt;p&gt;So if we look for example at the &lt;code&gt;blog&lt;/code&gt; …
1682 &lt;code&gt;.go&lt;/code&gt; files and Go module files like &lt;code&gt;…
1683 &lt;code&gt;blog&lt;/code&gt; binary by running:&lt;/p&gt;
1684 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1685 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1686 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1687 has a newer timestamp than the target file, and only trigger the build a…
1688 there are changes, for example:&lt;/p&gt;
1689 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1690 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1691 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1692 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1693 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1694 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1695 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1696 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1697 target as &lt;code&gt;.PHONY&lt;/code&gt;, that basically instructs &lt;…
1698 target. One classic example is &lt;code&gt;clean&lt;/code&gt; target, th…
1699 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1700 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1701 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1702 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1703 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1704 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1705 dependencies incorrectly, especially in languages that has fast build ti…
1706 like e.g.: Go. The worst thing that can happen is something not being re…
1707 when it needs to. So my recomendation if you are writing your first &lt;…
1708 is to just declare everything as &lt;code&gt;.PHONY&lt;/code&gt;. You ca…
1709 &lt;p&gt;One last basic concept that I want to explain about &lt;code&gt…
1710 target: it is the target that is run if you just run &lt;code&gt;make&lt…
1711 inside the directory that contains a &lt;code&gt;Makefile&lt;/code&gt;. …
1712 generally the first target in the &lt;code&gt;Makefile&lt;/code&gt;. It …
1713 target (that is also marked as &lt;code&gt;.PHONY&lt;/code&gt;) that has…
1714 targets that you want to build by default. In this particular case I dec…
1715 the &lt;code&gt;README.md&lt;/code&gt; and &lt;code&gt;rss.xml&lt;/code&…
1716 depends in &lt;code&gt;blog&lt;/code&gt; binary being build. So once I r…
1717 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1718 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1719 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1720 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1721 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1722 &lt;code&gt;Makefile&lt;/code&gt; or something similar in your projects:…
1723 the exactly steps that you need to get things working. If I see one proj…
1724 mine having a &lt;code&gt;Makefile&lt;/code&gt;, I can be reasonably con…
1725 working by just running &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;
1726 &lt;p&gt;But now let's focus in the other targets that I have in the &lt…
1727 not related to the build process but are there to help me manage my blog…
1728 Remember the rules I explained above? Maybe not, but it should be no pro…
1729 because:&lt;/p&gt;
1730 &lt;pre&gt;&lt;code&gt;$ make post TITLE=&amp;quot;My new blog post&amp;…
1731 mkdir -p &amp;quot;2024-08-13&amp;quot;
1732 ./.scripts/gen-post.sh &amp;quot;2024-08-13&amp;quot; &amp;quot;My new b…
1733 Creating file: 2024-08-13/02-my-new-blog-post.md
1734 &lt;p&gt;$ cat 2024-08-13/02-my-new-blog-post.md&lt;/p&gt;
1735 &lt;h1&gt;My new blog post&lt;/h1&gt;
1736 &lt;/code&gt;&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;/pre&gt;&lt…
1737 &lt;p&gt;This command, &lt;code&gt;make post&lt;/code&gt;, is responsibl…
1738 &lt;ol&gt;
1739 &lt;li&gt;Create a new directory for today, if it doesn't exist&lt;/li&g…
1740 &lt;li&gt;Run the
1741 &lt;a href="https://github.com/thiagokokada/blog/blob/6a3b06970729f7650e…
1742 script, that:
1743 &lt;ol&gt;
1744 &lt;li&gt;Enumerates all posts from the day, so we can number the new po…
1745 &lt;ul&gt;
1746 &lt;li&gt;We already had this post planned for 2024-08-13, so the new po…
1747 &lt;/ul&gt;
1748 &lt;/li&gt;
1749 &lt;li&gt;Slugify the title, so we can create each Markdown file with th…
1750 filename&lt;/li&gt;
1751 &lt;li&gt;Creates a new Markdown file with the title as a &lt;code&gt;h1…
1752 &lt;/ol&gt;
1753 &lt;/li&gt;
1754 &lt;/ol&gt;
1755 &lt;p&gt;The steps above may or may not seen trivial, and for a while I …
1756 manually. But not having to think what is the current date or if I alrea…
1757 posted that day or what is the slug is for the title make (pun intended)…
1758 like much easier.&lt;/p&gt;
1759 &lt;p&gt;Yes, the code is ugly. The way variables works in &lt;code&gt;M…
1760 declare then inside the &lt;code&gt;Makefile&lt;/code&gt;, but they can …
1761 if you pass them. I used this to allow &lt;code&gt;make post&lt;/code&gt…
1762 posts:&lt;/p&gt;
1763 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1764 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1765 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1766 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1767 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1768 instead of default (that would be the current day), and &lt;code&gt;_PAR…
1769 day we use to actually create the directory. We can actually pass any da…
1770 format recognised by
1771 &lt;a href="https://www.gnu.org/software/coreutils/manual/html_node/Exam…
1772 not just &lt;code&gt;YYYY-MM-DD&lt;/code&gt;.&lt;/p&gt;
1773 &lt;p&gt;I have 2 other phony targets that I want to talk, &lt;code&gt;d…
1774 expect a &lt;code&gt;FILE&lt;/code&gt; to be passed, and I use them to e…
1775 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1776 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1777 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1778 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1779 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1780 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1781 ignored&lt;/a&gt;
1782 during my directory parser to mean they're a draft post and not ready to…
1783 published. And the reason I created those targets is because I was tired…
1784 trying to hide or unhide a file manually.&lt;/p&gt;
1785 &lt;p&gt;So that's it, for the same reason you &lt;a href="https://kokad…
1786 everything&lt;/a&gt;,
1787 you also need to have some way to automate your tasks. &lt;code&gt;Makef…
1788 do it, maybe not the best way to do it, but it works and it is available
1789 anywhere.&lt;/p&gt;</description><pubDate>Tue, 13 Aug 2024 00:00:00 +000…
1790 post&lt;/a&gt; talking why
1791 my favorite device is a Chromebook. In this post I want to talk about wh…
1792 makes me this device unhappy, and comment about things that if changed w…
1793 make it a much better device.&lt;/p&gt;
1794 &lt;p&gt;But before talking about the negative aspects, let me talk abou…
1795 aspect that I just briefly talked in the previous post: the screen. It i…
1796 HiDPI screen (2000x1200 resolution in 10.95''), that is unexpected brigh…
1797 nits according to the
1798 &lt;a href="https://www.lenovo.com/us/en/p/laptops/lenovo/lenovo-edu-chr…
1799 It is difficult to find laptops at the same price with a screen that goo…
1800 10.95'' in its default resolution I find it too small (like 1250x750), b…
1801 find the font size acceptable at 115% scale (1087x652). Yes, it result i…
1802 small workspace, but this is not a big issue for what I do in this devic…
1803 is also only 60Hz, but I thought I would miss high refresh rate more tha…
1804 actually miss in this device.&lt;/p&gt;
1805 &lt;p&gt;Update: I forgot to say one thing about the screen: it scratche…
1806 got my screen scratched after the first day of usage, and considering th…
1807 I don't think the screen has a hardened glass. I bought a cheap glass sc…
1808 protector and this did the trick though, even hiding the previous scratc…
1809 I have zero issues with the screen now.&lt;/p&gt;
1810 &lt;p&gt;Now the first aspect that I don't like: the speakers. They soun…
1811 at maximum volume it is not really loud. The speakers is the only reason…
1812 still keep my &lt;a href="https://www.gsmarena.com/xiaomi_pad_5-11042.ph…
1813 because I like to watch animes/videos before sleep and having good speak…
1814 a must.&lt;/p&gt;
1815 &lt;p&gt;The keyboard has that issue that I mentioned in the previous po…
1816 the key get stuck, and I get duplicated characters. But it also has some…
1817 issues that I didn't talked about: the first one is the UK layout that h…
1818 extra keys that I have no use for, but this also makes the keys that I u…
1819 smaller. Very much a &amp;quot;me&amp;quot; problem, since if I had got …
1820 have those issues, but an issue nonetheless that gets worse considering …
1821 small the keyboard is. I am actually suprised how fast I can type consid…
1822 how many issues this keyboard has, so maybe this is a testament that this
1823 keyboard is not actually that bad.&lt;/p&gt;
1824 &lt;p&gt;The other keyboard issue is a problem that affects all Chromebo…
1825 layout. Google replaced a few keys like Fn keys with shortcuts and repla…
1826 Caps Lock with a
1827 &lt;a href="https://chromeunboxed.com/chromebook-launcher-now-everything…
1828 key (that is similar to the Windows Key), while removing Windows Key fro…
1829 place. I actually have less issue with this than I initially though: I d…
1830 care too much about Fn keys (except when using IntelliJ, but that is som…
1831 that I only use at &lt;code&gt;$CURRENT_JOB&lt;/code&gt;), and ChromeOS …
1832 its customisation, allowing you to swap key functionality. I remap Every…
1833 key with Esc, and Esc for the Everything key, and I can get productive i…
1834 &lt;code&gt;neovim&lt;/code&gt; setup.&lt;/p&gt;
1835 &lt;p&gt;And finally, let me talk more about the performance: yes, it is…
1836 bearable once you get used to. The issue is both the CPU and IO. While t…
1837 a &lt;a href="https://www.qualcomm.com/products/mobile/snapdragon/laptop…
1838 2&lt;/a&gt;
1839 is octa-core, it has only 2 high performance CPU cores vs 6 low performa…
1840 ones (2xARM Cortex A76 vs 6xARM Cortex A55). If it was something like 4x…
1841 would be much better. The fact that the cores are old doesn't help eithe…
1842 &lt;p&gt;But the worst part is the IO. Not only it uses a eMMC module, i…
1843 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
1844 &lt;p&gt;I don't know how much more expensive it would be to put a
1845 &lt;a href="https://en.wikipedia.org/wiki/Universal_Flash_Storage"&gt;UF…
1846 this device, but this is probably the choice that would most increase
1847 performance in this device, especially considering how aggressive Chrome…
1848 use (z)swap.&lt;/p&gt;
1849 &lt;p&gt;Update 2: I forgot to talk about the fact that the exterior of …
1850 covered in cloth. I thought I would hate this at first, but nowadays I k…
1851 like it. And it is also nice that it will never get scratched, I don't c…
1852 much about the exterior of this device and it is the only device that I …
1853 home that doesn't have additional protection (except the screen protector
1854 mentioned above).&lt;/p&gt;</description><pubDate>Mon, 12 Aug 2024 00:00…
1855 if I could have the surgery I discovered that I was suffering from dry e…
1856 Thanks to this, my ophthalmologist recommended that every 20 minutes whi…
1857 using screens, I look somewhere 20 feet away for 20 seconds, a technique…
1858 as &lt;a href="https://www.healthline.com/health/eye-health/20-20-20-rul…
1859 &lt;p&gt;I had issues following this rule because I never remembered to …
1860 initially tried to setup an alarm, but this became annoying, so I decide…
1861 try to find a program. I found
1862 &lt;a href="https://tonyh4156.github.io/20-20-20.github.io/"&gt;this&lt;…
1863 worked fine, but it bothered me that it was compiled for x86_64 while I …
1864 using a M1 MacBook Pro at the time, and also I needed something that wor…
1865 Linux.&lt;/p&gt;
1866 &lt;p&gt;Since I never found a good multi-platform alternative, I decide…
1867 own. This became
1868 &lt;a href="https://github.com/thiagokokada/twenty-twenty-twenty/"&gt;tw…
1869 the first &lt;a href="https://kokada.dev/blog/go-a-reasonable-good-langu…
1870 that I ever wrote. I wrote it in Go because I wanted to learn the langua…
1871 also because Go made it easy to build static binaries. And the first ver…
1872 could build static binaries without issues because I was using
1873 &lt;a href="https://github.com/gen2brain/beeep"&gt;beeep&lt;/a&gt;, that…
1874 supported platforms. However, it also meant that the notifications in ma…
1875 looked ugly, since it used
1876 &lt;a href="https://github.com/gen2brain/beeep/blob/master/beep_darwin.g…
1877 &lt;p&gt;I wanted better integration with macOS, so this meant switching…
1878 After searching for a while, the
1879 &lt;a href="https://pkg.go.dev/gioui.org/x/notify"&gt;notify&lt;/a&gt; l…
1880 &lt;a href="https://gioui.org/"&gt;GioUI&lt;/a&gt; is the one that seeme…
1881 implements notification in macOS using its native framework, so it works…
1882 better, but sadly it meant losing static binaries because it depends in …
1883 &lt;p&gt;Not a big loss initially, because I am only depending in Founda…
1884 macOS (that should always be available), and in Linux I could still stat…
1885 compile. However I eventually added more features like sound
1886 (via &lt;a href="https://github.com/gopxl/beep"&gt;beep&lt;/a&gt;) and t…
1887 &lt;a href="https://github.com/fyne-io/systray"&gt;systray&lt;/a&gt;), t…
1888 macOS and Linux.&lt;/p&gt;
1889 &lt;p&gt;Losing static binaries in Linux is a much bigger deal, since Li…
1890 target. The general recommendation for building CGO binaries statically …
1891 using
1892 &lt;a href="https://eli.thegreenplace.net/2024/building-static-binaries-…
1893 but this also means building all dependencies that we need using musl (e…
1894 &lt;a href="https://github.com/ebitengine/oto?tab=readme-ov-file#linux"&…
1895 [beep/oto]). This generally means pain, but Nix makes it easy.&lt;/p&gt;
1896 &lt;p&gt;Let's start by creating a &lt;a href="https://github.com/thiago…
1897 file&lt;/a&gt;
1898 that builds our Go module (simplified below for brevity):&lt;/p&gt;
1899 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1900 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1901 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1902 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1903 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1904 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1905 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1906 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1907 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1908 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1909 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1910 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1911 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1912 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1913 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1914 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1915 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1916 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1917 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1918 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1919 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1920 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1921 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1922 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1923 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1924 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1925 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1926 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1927 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1928 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1929 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1930 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1931 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1932 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1933 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And we can b…
1934 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1935 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1936 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1937 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1938 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1939 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1940 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1941 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1942 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1943 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1944 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1945 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1946 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1947 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1948 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1949 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1950 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1951 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1952 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1953 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1954 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1955 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1956 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1957 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1958 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1959 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1960 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1961 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1962 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1963 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1964 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I think this…
1965 build and a static build the usage of &lt;code&gt;pkgs.pkgsStatic&lt;/co…
1966 automatically builds all packages statically with &lt;code&gt;musl&lt;/c…
1967 some &lt;a href="https://honnef.co/articles/statically-compiled-go-progr…
1968 flags&lt;/a&gt;
1969 to the Go compiler (i.e.: &lt;code&gt;-linkmode external -extldflags &am…
1970 is a requirement from Go.&lt;/p&gt;
1971 &lt;p&gt;So, does it work? Let's test:&lt;/p&gt;
1972 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1973 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1974 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1975 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1976 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1977 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1978 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1979 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1980 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1981 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1982 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1983 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1984 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
1985 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
1986 related because of my usage of PipeWire and the binary may work in a pur…
1987 system, but I don't have access to one. Maybe adding &lt;code&gt;pipewir…
1988 &lt;code&gt;buildInputs&lt;/code&gt; would fix this issue, but I can't g…
1989 statically (because of its dependencies). I think this is a good show ho…
1990 it is to statically compilation is in Nix, but also how complex static b…
1991 are to get correctly.&lt;/p&gt;
1992 &lt;p&gt;Bonus points for
1993 &lt;a href="https://nix.dev/tutorials/cross-compilation.html"&gt;cross-c…
1994 easily cross-compile by using &lt;code&gt;pkgsCross&lt;/code&gt;:&lt;/p&…
1995 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
1996 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1997 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1998 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
1999 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2000 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2001 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2002 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2003 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2004 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2005 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2006 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2007 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2008 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2009 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2010 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2011 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The idea of …
2012 &lt;code&gt;aarch64-multiplatform&lt;/code&gt;) and use it as any other …
2013 &lt;code&gt;pkgsStatic&lt;/code&gt; to statically cross compile binaries…
2014 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2015 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2016 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2017 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2018 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</descri…
2019 bits&lt;/a&gt; post in this
2020 blog, I gave that title prefix without much thought: I knew it was suppo…
2021 be a quicker post than my previous one, but I never thought too deeply a…
2022 it. But after:&lt;/p&gt;
2023 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2024 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2025 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2026 quick bits really quick, or at least quicker? Let's see:&lt;/p&gt;
2027 &lt;pre&gt;&lt;code&gt;$ wc -w **/*.md
2028 1107 2024-07-26/01-writing-nixos-tests-for-fun-and-profit.md
2029 1220 2024-07-26/02-using-github-as-a-bad-blog-platform.md
2030 286 2024-07-27/01-quick-bits-nix-shell-is-cursed.md
2031 387 2024-07-29/01-quick-bits-why-you-should-automate-everything.md
2032 1060 2024-07-29/02-go-a-reasonable-good-language.md
2033 1380 2024-07-30/01-first-impressions-fpgbc.md
2034 1238 2024-07-31/01-generating-yaml-files-with-nix.md
2035 2308 2024-08-01/01-troubleshooting-zsh-lag-and-solutions-with-nix.md
2036 504 2024-08-01/02-quick-bits-realise-nix-symlinks.md
2037 834 2024-08-04/01-make-nixd-modules-completion-work-anywhere-with-flak…
2038 1147 2024-08-05/01-my-favorite-device-is-a-chromebook.md
2039 394 2024-08-07/01-quick-bits-is-crostini-a-microvm.md
2040 120 README.md
2041 11985 total
2042 &lt;/code&gt;&lt;/pre&gt;
2043 &lt;p&gt;While using &lt;code&gt;wc&lt;/code&gt; is probably not the bes…
2044 in this blog, since I tend to write lots of code snippets), I think this…
2045 least it gives me a good insight: yes, quick bits are quicker, and they'…
2046 basically posts with a soft limit around 500 words. So expect in future …
2047 limit to be used.&lt;/p&gt;
2048 &lt;p&gt;By the way, at:&lt;/p&gt;
2049 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2050 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2051 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2052 too much. And yes, that last block of code is also meta ;).&lt;/p&gt;</d…
2053 conclusion I got after some searching.&lt;/p&gt;
2054 &lt;p&gt;Someone asked me in my &lt;a href="https://kokada.dev/blog/my-f…
2055 post&lt;/a&gt; about my
2056 Chromebook if Crostini could be considered a micro VM. This was a intere…
2057 question, so I decided to do another post.&lt;/p&gt;
2058 &lt;p&gt;To start, it is really difficult to get a good definition of wh…
2059 is. &lt;a href="https://firecracker-microvm.github.io/"&gt;Firecracker&l…
2060 micro VM, and describes itself in its website as:&lt;/p&gt;
2061 &lt;blockquote&gt;
2062 &lt;p&gt;Firecracker is a virtual machine monitor (VMM) that uses the Li…
2063 Kernel-based Virtual Machine (KVM) to create and manage microVMs. Firecr…
2064 has a minimalist design. It excludes unnecessary devices and guest
2065 functionality to reduce the memory footprint and attack surface area of …
2066 microVM. This improves security, decreases the startup time, and increas…
2067 hardware utilization.&lt;/p&gt;
2068 &lt;/blockquote&gt;
2069 &lt;p&gt;Now looking at Crostini, its heart is a VMM called
2070 &lt;a href="https://crosvm.dev/"&gt;crosvm&lt;/a&gt;. It is described in…
2071 &lt;a href="https://chromium.googlesource.com/chromiumos/platform/crosvm…
2072 as:&lt;/p&gt;
2073 &lt;blockquote&gt;
2074 &lt;p&gt;crosvm is a virtual machine monitor (VMM) based on Linux’s KV…
2075 with a focus on simplicity, security, and speed. crosvm is intended to r…
2076 Linux guests, originally as a security boundary for running native
2077 applications on the ChromeOS platform. Compared to QEMU, crosvm doesn’t
2078 emulate architectures or real hardware, instead concentrating on
2079 paravirtualized devices, such as the virtio standard.&lt;/p&gt;
2080 &lt;/blockquote&gt;
2081 &lt;p&gt;Similar descriptions right? Actually Firecracker website says i…
2082 Chromium OS's Virtual Machine Monitor, crosvm, an open source VMM writte…
2083 Rust&amp;quot;. So I would say it is safe to say crosvm itself is a micr…
2084 &lt;p&gt;But
2085 &lt;a href="https://www.chromium.org/chromium-os/developer-library/guide…
2086 itself is a combination of virtualization AND containerization. Basically
2087 inside the VM it runs a Linux kernel and &lt;a href="https://linuxcontai…
2088 that can start arbitrary containers inside it. From the Crostini documen…
2089 this choice seems to be to keep startup times down, and also to increase
2090 security (e.g.: in case of a security issue inside the container).&lt;/p…
2091 &lt;p&gt;This is definitely an interesting choice, since containers allo…
2092 of each distro that you run inside Crostini to be low, and the main VM i…
2093 (called
2094 &lt;a href="https://chromium.googlesource.com/chromiumos/overlays/board-…
2095 should have low overhead too thanks to crosvm.&lt;/p&gt;
2096 &lt;p&gt;By the way, if you want to learn more how &amp;quot;devices&amp…
2097 like crosvm, I recommend &lt;a href="https://prilik.com/blog/post/crosvm…
2098 post&lt;/a&gt; talking about
2099 paravirtualized devices in crosvm.&lt;/p&gt;</description><pubDate>Wed, …
2100 &amp;quot;personal computing&amp;quot; that I do nowadays is mostly done…
2101 unremarkable devices that I own: a cheap &lt;a href="https://www.lenovo.…
2102 3&lt;/a&gt;,
2103 that I bought for around EUR300. I was thinking why, because it is woefu…
2104 underpowered: a &lt;a href="https://www.anandtech.com/show/16696/qualcom…
2105 2&lt;/a&gt;,
2106 a CPU that was already considered slow 3 years ago, coupled with an eMMC…
2107 storage, that is not much faster than a HDD. At least I have the 8GB RAM
2108 version instead of the 4GB one.&lt;/p&gt;
2109 &lt;p&gt;It is a hybrid device, one that can be used as either a tablet …
2110 it is compromised experience in both cases: as a tablet, it lacks the be…
2111 touch optimised interface from iOS or Android; as a laptop, you have to …
2112 on the stand to adjust the screen, and the detachable keyboard is worse …
2113 any laptop I have ever owned: getting keys stucked and characters being
2114 duplicated as a result is a common occurence. It is not so bad that I ca…
2115 things done though. About the trackpad: its biggest quality is that I ne…
2116 feel the need to use the touchscreen in laptop mode, that is to say that…
2117 acceptable. Just crank up the pointer speed in ChromeOS settings, otherw…
2118 never get anywhere since the trackpad is so small. There is also an acti…
2119 stylus, that helped me sometimes when I needed to sign something but oth…
2120 I can't comment too much.&lt;/p&gt;
2121 &lt;p&gt;But I really love this device. It is generally the only device …
2122 trips nowadays, because while it is compromised it works well enough: I …
2123 to consume media in tablet mode (the fact that ChromeOS supports Android…
2124 is a plus in those cases), browse the web and even do Linux stuff (more …
2125 this later). The fact that it is small (the size remembers me of a
2126 &lt;a href="https://en.wikipedia.org/wiki/Netbook"&gt;netbook&lt;/a&gt;)…
2127 the keyboard), has a good screen (that is bright and HiDPI) and good bat…
2128 life (I don't have numbers but I almost never worry about it) is what ma…
2129 this device the perfect companion to trips.&lt;/p&gt;
2130 &lt;p&gt;Also, it has 2 USB-C ports and supports DisplayPort alt-mode, s…
2131 can charge it, connect to a external display and peripherals, all at the…
2132 time. Sadly, the maximum output resolution I got was 1080p (2560x1080),
2133 although some people at Reddit &lt;a href="https://www.reddit.com/r/chro…
2134 success&lt;/a&gt;
2135 at 1440p, and the specs suggests it supports 4k. It may be my Dell S3423…
2136 monitor being wonky, the fact that it is Ultrawide or the cable, who kno…
2137 even tried to change the monitor to &amp;quot;High Resolution&amp;quot; …
2138 no avail.&lt;/p&gt;
2139 &lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; looking at the &lt;a href="https:/…
2140 brief&lt;/a&gt;
2141 for Snapdragon 7c Gen 2, it seems it supports up to QHD@60Hz (1440p) for…
2142 external display, and not 4k. This explains why it doesn't work at maxim…
2143 resolution in my Dell S3423DWC, since while it is 1440p it is Ultrawide,…
2144 resolution is bigger than QHD (3440x1440 vs 2560x1440).&lt;/p&gt;
2145 &lt;p&gt;ChromeOS is also really interesting nowadays. To start, it is d…
2146 ground up to be a &lt;a href="https://support.google.com/chromebook/answ…
2147 environment&lt;/a&gt;, probably
2148 the most secure OS for consumers right now. Being a Chrome-first OS make…
2149 compromised experience, for example, it is the only device that I use Ch…
2150 my main browser (since I personally prefer Firefox). But having a OS tha…
2151 fast is great: I never worry about OS updates because I know the device …
2152 ready in seconds after a reboot. And the whole desktop experience inside…
2153 ChromeOS desktop is good, having shortcuts for many operations so you ca…
2154 things done fast, and support for virtual desktops (ChromeOS call it &am…
2155 means you can organise your windows as much as you want.&lt;/p&gt;
2156 &lt;p&gt;And what I think makes ChromeOS really powerful is
2157 &lt;a href="https://chromeos.dev/en/linux"&gt;Crostini&lt;/a&gt;, a full…
2158 inside ChromeOS. It runs Debian (it seems you can &lt;a href="https://ww…
2159 distros&lt;/a&gt;
2160 though) with a deep integration with ChromeOS, so you can run even graph…
2161 programs without issues (including OpenGL!):&lt;/p&gt;
2162 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
2163 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
2164 &lt;p&gt;This is all thanks to
2165 &lt;a href="https://chromium.googlesource.com/chromiumos/platform2/+/HEA…
2166 a nested Wayland compositor that runs inside Crostini and allow both Way…
2167 and X11 applications to be forwarded to ChromeOS. The integration is so …
2168 that I can run Firefox inside Crostini and works well enough, but sadly …
2169 is too slow in this device (I am not sure if the issue is ChromeOS or Fi…
2170 but I suspect the later since Google does some optimisation per device).…
2171 &lt;p&gt;One interesting tidbit about the OpenGL situation in this devic…
2172 be the first Chromebook to ship with open source drivers, thanks to Free…
2173 There is &lt;a href="https://www.youtube.com/watch?v=8mnjSmN03VM"&gt;thi…
2174 presentation done by Rob Clark in XDC 2021, that I recommended anyone
2175 interested in free drivers to watch (the reference design of Duet 3 is
2176 &lt;a href="https://chromeunboxed.com/chromebook-tablet-snapdragon-7c-ho…
2177 &lt;p&gt;The Crostini integration is probably the best VM integration wi…
2178 saw in an OS: you can manage files inside the VM, share directories betw…
2179 OS and VM, copy and paste works between the two, GUI applications instal…
2180 inside the VM appear in the ChromeOS menu, memory allocation inside the …
2181 transparent, etc. Even the themes for Linux GUI applications are customi…
2182 match ChromeOS. It is unironically one of the best Linux desktop experie…
2183 ever had.&lt;/p&gt;
2184 &lt;p&gt;Of course I am using Nix, but since the Crostini integration de…
2185 services being configured and installed, I decided to run Nix inside Deb…
2186 instead of NixOS and run &lt;a href="https://nix-community.github.io/hom…
2187 standalone&lt;/a&gt;.
2188 I recommend checking the official &lt;a href="https://wiki.nixos.org/wik…
2189 Crostini&lt;/a&gt;, that details
2190 how to register applications in ChromeOS (so desktop applications appear…
2191 menu) and use &lt;a href="https://github.com/nix-community/nixGL"&gt;nix…
2192 applications work.&lt;/p&gt;
2193 &lt;p&gt;Like I said at the start of the article, the device is woefully…
2194 its CPU and eMMC. It does mean that, for example, activating my Home-Man…
2195 configuration takes a while (around 1 minute, vs a few seconds in my lap…
2196 But it is much faster than say,
2197 &lt;a href="https://github.com/nix-community/nix-on-droid-app"&gt;nix-on…
2198 last time I tried in a much more powerful device (&lt;a href="https://ww…
2199 5&lt;/a&gt;), took 30 minutes until I
2200 just decided to cancel the operation. Having a proper VM instead of
2201 &lt;a href="https://wiki.termux.com/wiki/PRoot"&gt;proot&lt;/a&gt; makes…
2202 &lt;p&gt;I can even do some light programming here: using my
2203 &lt;a href="https://kokada.dev/blog/troubleshoting-zsh-lag-and-solutions…
2204 and neovim configuration (including LSP for coding) is reasonable fast. …
2205 example, I did most of the code that &lt;a href="https://kokada.dev/blog…
2206 blog&lt;/a&gt;
2207 using this Chromebook. If I need more power, I can use the &lt;a href="h…
2208 Android&lt;/a&gt; to connect to any
2209 other of my hosts via SSH. Yes, the Tailscale app works in Crostini, sad…
2210 without MagicDNS, so you need to use the internal Tailscale IPs instead.…
2211 &lt;p&gt;Until Google decides to give us a proper VM or user namespaces …
2212 release a hybrid Chromebook device with better specs, this small Chromeb…
2213 will probably stay as my travel companion, and is one of my favorite dev…
2214 result&amp;quot;).&lt;/p&gt;
2215 &lt;p&gt;I recently switched from &lt;a href="https://github.com/oxalica…
2216 &lt;a href="https://github.com/nix-community/nixd"&gt;nixd&lt;/a&gt; as …
2217 was curious in &lt;code&gt;nixd&lt;/code&gt; for a long time since the f…
2218 means it can offer much more powerful completion than the &lt;code&gt;ni…
2219 analysis, however it used to be difficult to setup. Nowadays it is much …
2220 basically doing the right thing as long as you have &lt;code&gt;NIX_PATH…
2221 get both package and NixOS modules completion.&lt;/p&gt;
2222 &lt;p&gt;Getting Home-Manager modules though needs some setup. The recom…
2223 setup accordingly to the &lt;a href="https://github.com/nix-community/ni…
2224 documentation&lt;/a&gt;
2225 is to use the following for Flake based configurations (using neovim
2226 configuration here, but it should be easy to adapt to other editors):&lt…
2227 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2228 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2229 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2230 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2231 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2232 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2233 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2234 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2235 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2236 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2237 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2238 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2239 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2240 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2241 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This works, …
2242 will only work if you open your editor in your &lt;a href="https://githu…
2243 repository&lt;/a&gt;. For any other
2244 repository, &lt;code&gt;nixosConfigurations.miku-nixos&lt;/code&gt; or &…
2245 will not exist and the completion will not work.&lt;/p&gt;
2246 &lt;p&gt;It may look like this is easy to fix if you have
2247 &lt;a href="https://nixos.org/manual/nixos/unstable/options#opt-_module.…
2248 (or &lt;code&gt;extraSpecialArgs&lt;/code&gt; in Home-Manager) set to ha…
2249 Flakes inputs, but:&lt;/p&gt;
2250 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2251 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2252 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2253 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2254 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2255 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2256 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2257 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2258 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2259 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2260 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2261 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2262 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2263 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Well, it was…
2264 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2265 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2266 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2267 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2268 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2269 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;But while it…
2270 impure, since there is no &lt;code&gt;flake.lock&lt;/code&gt;).&lt;/p&gt;
2271 &lt;p&gt;The default configuration for &lt;code&gt;nixd&lt;/code&gt; mak…
2272 of my configuration repo, and it is fast. How? I decided to take a look …
2273 &lt;code&gt;nixd&lt;/code&gt; source code and found
2274 &lt;a href="https://github.com/nix-community/nixd/blob/d938026c55c7c36a6…
2275 (formatted here for legibility):&lt;/p&gt;
2276 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2277 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2278 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2279 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2280 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2281 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2282 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2283 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2284 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2285 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2286 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Interesting,…
2287 said above, it depends in &lt;code&gt;NIX_PATH&lt;/code&gt; being correc…
2288 use our Flake inputs instead? After some tries in the Nix REPL, I got the
2289 following:&lt;/p&gt;
2290 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2291 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2292 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2293 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2294 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2295 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2296 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2297 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2298 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2299 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2300 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So we can ad…
2301 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2302 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2303 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2304 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2305 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2306 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2307 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2308 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This was eas…
2309 to take a look at the Home-Manager &lt;a href="https://github.com/nix-co…
2310 code&lt;/a&gt;
2311 to find the answer:&lt;/p&gt;
2312 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2313 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2314 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2315 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2316 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2317 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2318 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2319 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2320 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2321 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2322 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2323 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2324 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The interest…
2325 system (including &lt;code&gt;evalModules&lt;/code&gt;). This includes e…
2326 Home-Manager only. Also, we need to disable &lt;code&gt;checks&lt;/code&…
2327 some validations (e.g.: missing &lt;code&gt;stateVersion&lt;/code&gt;). …
2328 any issue for module completion yet, I may set it in the future.&lt;/p&g…
2329 &lt;p&gt;And for the final result:&lt;/p&gt;
2330 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2331 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2332 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2333 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2334 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2335 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2336 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2337 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2338 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2339 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2340 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2341 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2342 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2343 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Yes, it is q…
2344 repository, as long as you're using Flakes. And it is fast, since it doe…
2345 need any network access. Since we are already here, let's define &lt;cod…
2346 not depend in the &lt;code&gt;NIX_PATH&lt;/code&gt; being set too.&lt;/p…
2347 Tavis&lt;/a&gt;, I decided to document my own
2348 recent journey of reducing terminal (ZSH) lag startup. This post is way …
2349 interesting than the one from Tavis that uses a debugger to patch applic…
2350 on the fly, but should still be interesting for some. And it also shows …
2351 powerful Nix can be for some things.&lt;/p&gt;
2352 &lt;p&gt;For context, I have basically 3 systems where I interact with t…
2353 frequently:&lt;/p&gt;
2354 &lt;ul&gt;
2355 &lt;li&gt;&lt;a href="https://www.notebookcheck.net/Lenovo-ThinkPad-P14s…
2356 running NixOS, with a reasonable fast CPU (&lt;a href="https://www.noteb…
2357 4750U&lt;/a&gt;)
2358 and disk (NVMe)&lt;/li&gt;
2359 &lt;li&gt;&lt;a href="https://everymac.com/systems/apple/macbook_pro/spe…
2360 Pro&lt;/a&gt;
2361 with a really fast CPU (M1 Pro) and disk, but of course running macOS, b…
2362 phased-out since this is a job owned machine and I am changing jobs right
2363 now, but should be replaced with another one soon™&lt;/li&gt;
2364 &lt;li&gt;&lt;a href="https://chromeunboxed.com/lenovo-chromebook-duet-3…
2365 3&lt;/a&gt;
2366 running ChromeOS, with slow CPU (&lt;a href="https://www.notebookcheck.n…
2367 2&lt;/a&gt;)
2368 and disk (eMMC, really?)&lt;/li&gt;
2369 &lt;/ul&gt;
2370 &lt;p&gt;My experience is similar to Tavis, at around 300ms of startup t…
2371 too much, but around 500ms+ is where I start to notice. I never had any …
2372 with startup time in NixOS itself (I had issues with macOS before, but i…
2373 not actually the fault of macOS), but in the Chromebook it was awful: 60…
2374 with &lt;a href="https://www.instabug.com/blog/understanding-cold-hot-an…
2375 start&lt;/a&gt;,
2376 while cold start it could take multiple seconds.&lt;/p&gt;
2377 &lt;p&gt;We can check how long ZSH takes to start by using:&lt;/p&gt;
2378 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2379 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2380 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2381 use of ZSH. Without this flag ZSH will ignore your &lt;code&gt;~/.zshrc&…
2382 results will be meaningless.&lt;/p&gt;
2383 &lt;p&gt;To do a more interesting benchmark, we can use
2384 &lt;a href="https://github.com/sharkdp/hyperfine"&gt;&lt;code&gt;hyperfi…
2385 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2386 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2387 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2388 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2389 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2390 shell startup time. A really great tool to have in your toolbox by the w…
2391 I digress.&lt;/p&gt;
2392 &lt;p&gt;So let's do a little time travelling. Going back to commit
2393 &lt;a href="https://github.com/thiagokokada/nix-configs/tree/b12757f9088…
2394 from &lt;a href="https://github.com/thiagokokada/nix-configs/"&gt;nix-co…
2395 &lt;code&gt;hyperfine&lt;/code&gt; like above from my NixOS laptop, we h…
2396 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2397 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2398 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2399 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2400 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2401 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2402 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2403 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2404 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2405 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2406 benchmark (so it is a hot start). The cold start times were above 3s. So…
2407 investigate what is happening here. We can profile what is taking time d…
2408 the startup of ZSH using &lt;a href="https://www.bigbinary.com/blog/zsh-…
2409 You can add the following in your &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;…
2410 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2411 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2412 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2413 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2414 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2415 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2416 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2417 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Or if using …
2418 &lt;a href="https://nix-community.github.io/home-manager/options.xhtml#o…
2419 option. Once we restart ZSH, we will have something like:&lt;/p&gt;
2420 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2421 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2422 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2423 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2424 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2425 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2426 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2427 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2428 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2429 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2430 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2431 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2432 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2433 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2434 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2435 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2436 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2437 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2438 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2439 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2440 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2441 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2442 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2443 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2444 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I ommited so…
2445 &lt;a href="https://github.com/zimfw/zimfw"&gt;zimfw&lt;/a&gt;, the fram…
2446 my ZSH (similar to Oh-My-Zsh). I actually don't use &lt;code&gt;zimfw&lt…
2447 just load some modules that I find useful, like the &lt;code&gt;zim-comp…
2448 &lt;code&gt;zim-ssh&lt;/code&gt; that we can see above. By the way, Zim …
2449 optimised for startup time, but those 2 modules are kind slow.&lt;/p&gt;
2450 &lt;p&gt;For &lt;a href="https://github.com/zimfw/completion"&gt;&lt;cod…
2451 look at it, there isn't much I could do. It seems that the reason
2452 &lt;code&gt;zim-completion&lt;/code&gt; takes so long during startup is …
2453 if it needs to recompile the completions (and replacing it with just a n…
2454 &lt;code&gt;autoload -U compinit &amp;amp;&amp;amp; compinit&lt;/code&gt…
2455 may eventually replace it for something else, but I really like what Zim…
2456 here, so I decided to not touch it for now.&lt;/p&gt;
2457 &lt;p&gt;However &lt;a href="https://github.com/zimfw/ssh"&gt;&lt;code&g…
2458 reason I used it is to start a &lt;code&gt;ssh-agent&lt;/code&gt; and ke…
2459 sessions. It shouldn't have that much influence in startup time. So I to…
2460 look the code (since it is small, I am reproducing it here):&lt;/p&gt;
2461 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2462 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2463 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2464 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2465 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2466 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2467 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2468 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2469 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2470 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2471 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2472 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2473 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2474 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2475 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2476 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2477 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2478 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2479 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2480 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2481 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2482 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2483 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2484 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2485 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2486 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2487 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2488 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2489 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2490 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2491 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2492 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2493 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2494 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2495 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Well, this i…
2496 already running but you open a new shell instance (that doesn't have the
2497 connection info yet so it will need to load). This will run &lt;code&gt;…
2498 times. How long does &lt;code&gt;ssh-add&lt;/code&gt; takes to run?&lt;/…
2499 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2500 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2501 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2502 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2503 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2504 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2505 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2506 command being tested is too fast.&lt;/p&gt;
2507 &lt;p&gt;In average we have 4x4ms=16ms of startup time. But keep in mind…
2508 can be much worse. The question is, how can we improve the situation her…
2509 &lt;p&gt;After taking a look, I decided to write my own code, based in s…
2510 from &lt;a href="https://github.com/ohmyzsh/ohmyzsh/blob/67581c53c645856…
2511 plugin&lt;/a&gt;.
2512 Here is final version of my
2513 &lt;a href="https://github.com/thiagokokada/nix-configs/blob/e45a888f2bf…
2514 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2515 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2516 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2517 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2518 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2519 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2520 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2521 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2522 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2523 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2524 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2525 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2526 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2527 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2528 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2529 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2530 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2531 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2532 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2533 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2534 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2535 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2536 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2537 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2538 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2539 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2540 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2541 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2542 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2543 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2544 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2545 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2546 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2547 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2548 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2549 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2550 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2551 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2552 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2553 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The idea her…
2554 &lt;a href="https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-…
2555 module from ZSH itself to check if the &lt;code&gt;ssh-agent&lt;/code&gt…
2556 executing &lt;code&gt;ssh-add -l&lt;/code&gt;. The only case we run any …
2557 agent itself if needed. Let's run &lt;code&gt;hyperfine&lt;/code&gt; aga…
2558 &lt;pre&gt;&lt;code&gt;$ hyperfine &amp;quot;zsh -ic exit&amp;quot;
2559 Benchmark 1: zsh -ic exit
2560 Time (mean ± σ): 188.3 ms ± 8.2 ms [User: 61.1 ms, System:…
2561 Range (min … max): 170.9 ms … 198.4 ms 16 runs
2562 &lt;/code&gt;&lt;/pre&gt;
2563 &lt;p&gt;Got a good improvement here already. Let's see &lt;code&gt;zpro…
2564 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2565 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2566 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2567 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2568 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2569 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2570 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2571 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2572 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2573 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2574 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2575 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2576 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2577 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2578 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2579 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2580 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2581 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2582 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2583 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2584 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2585 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2586 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2587 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2588 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Well, there …
2589 still the main culprit, but nothing to do for now. Instead of looking at
2590 &lt;code&gt;zproof&lt;/code&gt;, let's take a look at my &lt;code&gt;~/.…
2591 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2592 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2593 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2594 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2595 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2596 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2597 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2598 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2599 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2600 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2601 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2602 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2603 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2604 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So you see, …
2605 startup considerable. Not necessary for commands fast like &lt;code&gt;f…
2606 written in Go), but let's see
2607 &lt;a href="https://github.com/haslersn/any-nix-shell"&gt;&lt;code&gt;an…
2608 in shell script:&lt;/p&gt;
2609 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2610 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2611 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2612 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2613 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2614 in mind that there is a difference between the cold and hot start again.…
2615 example, &lt;code&gt;fzf&lt;/code&gt;:&lt;/p&gt;
2616 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2617 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2618 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2619 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2620 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2621 6.8ms can be noticiable, especially if this accumulates with other slow
2622 starting apps.&lt;/p&gt;
2623 &lt;p&gt;And the thing is, all those commands are just generating in the…
2624 output, at least for the current version of the program. Can we pre-gene…
2625 them instead? If using Nix, of course we can:&lt;/p&gt;
2626 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2627 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2628 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2629 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2630 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2631 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2632 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2633 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2634 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2635 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2636 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2637 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2638 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2639 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2640 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2641 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2642 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2643 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2644 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2645 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2646 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2647 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2648 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2649 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2650 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2651 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2652 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2653 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2654 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2655 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2656 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2657 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2658 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2659 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So we can us…
2660 &lt;code&gt;source&lt;/code&gt; the result. &lt;code&gt;fzf&lt;/code&gt;…
2661 already generated in the package. I think this is one of those things th…
2662 really shows the power of Nix: I wouldn't do something similar if I didn…
2663 Nix because the risk of breaking something later is big (e.g.: forgettin…
2664 update the generated files), but Nix makes those things trivial.&lt;/p&g…
2665 &lt;p&gt;Let's run &lt;code&gt;hyperfine&lt;/code&gt; again:&lt;/p&gt;
2666 &lt;pre&gt;&lt;code&gt;$ hyperfine &amp;quot;zsh -ic exit&amp;quot;
2667 Benchmark 1: zsh -ic exit
2668 Time (mean ± σ): 162.3 ms ± 4.9 ms [User: 52.7 ms, System:…
2669 Range (min … max): 153.0 ms … 173.4 ms 19 runs
2670 &lt;/code&gt;&lt;/pre&gt;
2671 &lt;p&gt;Another good improvement. The last change I did is switching be…
2672 &lt;a href="https://github.com/zsh-users/zsh-syntax-highlighting"&gt;&lt…
2673 to
2674 &lt;a href="https://github.com/zdharma-continuum/fast-syntax-highlightin…
2675 that is supposed to be faster and have better highlighting too. I got th…
2676 &lt;code&gt;_zsh_highlight_load_highlighters&lt;/code&gt; using 26% of t…
2677 And for the final &lt;code&gt;hyperfine&lt;/code&gt; in my laptop:&lt;/p…
2678 &lt;pre&gt;&lt;code&gt;$ hyperfine &amp;quot;zsh -ic exit&amp;quot;
2679 Benchmark 1: zsh -ic exit
2680 Time (mean ± σ): 138.3 ms ± 7.1 ms [User: 47.5 ms, System:…
2681 Range (min … max): 123.8 ms … 157.9 ms 21 runs
2682 &lt;/code&gt;&lt;/pre&gt;
2683 &lt;p&gt;A ~36% improvement, not bad. Let's see how it fares in my Chrom…
2684 &lt;pre&gt;&lt;code&gt;$ hyperfine &amp;quot;zsh -ic exit&amp;quot;
2685 Benchmark 1: zsh -ic exit
2686 Time (mean ± σ): 278.2 ms ± 46.9 ms [User: 88.0 ms, System:…
2687 Range (min … max): 204.7 ms … 368.5 ms 11 runs
2688 &lt;/code&gt;&lt;/pre&gt;
2689 &lt;p&gt;An even more impressive ~59% improvement. And yes, the shell st…
2690 much better.&lt;/p&gt;</description><pubDate>Thu, 01 Aug 2024 00:00:00 +…
2691 &lt;a href="https://github.com/nix-community/home-manager/"&gt;Home-Mana…
2692 when you want to test something or maybe debug some issue in your
2693 configuration. Those times it would be really convenient if you could av…
2694 rebuild of your Home-Manager configuration, since this takes time until
2695 evaluation and activation.&lt;/p&gt;
2696 &lt;p&gt;For those times I have this small script in my Nix configuratio…
2697 &lt;code&gt;realise-symlinks&lt;/code&gt;, that is defined as:&lt;/p&gt;
2698 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2699 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2700 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2701 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2702 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2703 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2704 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2705 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2706 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2707 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2708 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2709 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2710 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2711 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2712 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2713 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2714 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2715 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2716 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2717 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2718 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2719 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2720 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2721 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2722 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2723 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2724 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2725 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2726 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2727 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2728 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The idea of …
2729 store and it will realise, e.g.: convert to an &amp;quot;actual&amp;quot…
2730 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2731 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2732 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2733 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2734 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2735 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2736 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2737 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2738 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2739 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2740 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2741 By the way, it also works with directories:&lt;/p&gt;
2742 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2743 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2744 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2745 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2746 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2747 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2748 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2749 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2750 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2751 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2752 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2753 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2754 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2755 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2756 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2757 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2758 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2759 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2760 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2761 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2762 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2763 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2764 can just delete those files and re-run your Home-Manager activation:&lt;…
2765 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2766 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2767 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2768 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2769 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2770 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2771 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2772 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2773 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2774 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2775 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2776 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2777 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2778 OS level configuration.&lt;/p&gt;</description><pubDate>Thu, 01 Aug 2024…
2779 &lt;a href="https://noyaml.com/"&gt;noyaml.com&lt;/a&gt;. In my personal…
2780 preferring either JSON, &lt;a href="https://toml.io/en/"&gt;TOML&lt;/a&g…
2781 &lt;a href="https://en.wikipedia.org/wiki/INI_file"&gt;INI&lt;/a&gt; fil…
2782 However the ship has sailed already, there are tons of projects everywhe…
2783 uses YAML: from most CI systems (&lt;a href="https://docs.github.com/en/…
2784 Actions&lt;/a&gt;,
2785 &lt;a href="https://circleci.com/docs/introduction-to-yaml-configuration…
2786 &lt;a href="https://docs.travis-ci.com/user/build-config-yaml"&gt;Travis…
2787 &lt;a href="https://man.sr.ht/builds.sr.ht/"&gt;builds.sr.ht&lt;/a&gt;),…
2788 &lt;a href="https://kubernetes.io/docs/concepts/overview/working-with-ob…
2789 or in almost every
2790 &lt;a href="https://guides.rubyonrails.org/configuring.html#configuring-…
2791 application.&lt;/p&gt;
2792 &lt;p&gt;One way to avoid at least some issues with the language is to w…
2793 another language. I will show my solution in one of my &lt;a href="https…
2794 repositories&lt;/a&gt;, writing Nix to
2795 generate GitHub Actions configuration files. Bonus points for validating…
2796 result against the schema of GitHub Actions, so the famous &amp;quot;thi…
2797 be string instead of a list of strings&amp;quot; is gone.&lt;/p&gt;
2798 &lt;p&gt;Let's start with the basics: YAML is supposed to be a &lt;a hre…
2799 JSON&lt;/a&gt;. What that means is that a JSON file
2800 &lt;a href="https://yaml.org/spec/1.2-old/spec.html#id2759572"&gt;can be…
2801 parser. And Nix itself generates JSON natively, after all, Nix can be im…
2802 as &lt;a href="https://nix.dev/tutorials/nix-language.html"&gt;&amp;quot…
2803 &lt;p&gt;To make things easier, I will assume that you have the &lt;code…
2804 &lt;code&gt;flakes&lt;/code&gt; enabled as &lt;code&gt;experimental-feat…
2805 go &lt;a href="https://wiki.nixos.org/wiki/Flakes"&gt;here&lt;/a&gt;.&lt…
2806 &lt;p&gt;Using the &lt;code&gt;nix eval&lt;/code&gt; command, we can gen…
2807 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2808 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2809 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2810 impractical. We can write the following code inside a &lt;code&gt;foo.ni…
2811 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2812 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2813 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2814 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And:&lt;/p&g…
2815 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2816 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2817 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2818 not the &lt;a href="https://metacpan.org/pod/JSON::XS#JSON-and-YAML"&gt;…
2819 maybe not), Nix has no native functionality to export data to YAML. Howe…
2820 since we are using Nix, it is trivial to use &lt;code&gt;nixpkgs&lt;/cod…
2821 convert from JSON to YAML.&lt;/p&gt;
2822 &lt;p&gt;To start, let's create a new directory, move our &lt;code&gt;fo…
2823 new &lt;code&gt;flake.nix&lt;/code&gt; file and put the following conten…
2824 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2825 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2826 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2827 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2828 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2829 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2830 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2831 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2832 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2833 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2834 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2835 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2836 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2837 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2838 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2839 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2840 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2841 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2842 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2843 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2844 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2845 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2846 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2847 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2848 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2849 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2850 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We are loadi…
2851 &lt;code&gt;builtins.toJSON&lt;/code&gt; function, and finally, using &l…
2852 &lt;code&gt;passAsFile&lt;/code&gt; option to load the contents of the J…
2853 &lt;a href="https://github.com/sclevine/yj"&gt;yj&lt;/a&gt;, that conver…
2854 formats (&lt;code&gt;-jy&lt;/code&gt; flag means &amp;quot;JSON to YAML&…
2855 because it is a single binary Go program, but you can use whatever you p…
2856 &lt;p&gt;By the way, there is a
2857 &lt;a href="https://github.com/NixOS/nixpkgs/blob/9f918d616c5321ad374ae6…
2858 inside &lt;code&gt;nixpkgs.lib&lt;/code&gt;, but as of the day of this p…
2859 &lt;code&gt;lib.strings.toJSON&lt;/code&gt; (that in turn, calls &lt;cod…
2860 really help here. Another option would be &lt;code&gt;pkgs.formats.yaml.…
2861 converts between formats, but it calls
2862 &lt;a href="https://github.com/NixOS/nixpkgs/blob/008ceae1a2b47a84d7aa01…
2863 (in Python), so not my favorite choice.&lt;/p&gt;
2864 &lt;p&gt;If we run the following commands, we can see the result:&lt;/p&…
2865 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2866 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2867 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2868 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
2869 &lt;a href="https://github.com/thiagokokada/blog/blob/4e3f25485c6682f3e0…
2870 that builds this blog, to Nix:&lt;/p&gt;
2871 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2872 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2873 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2874 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2875 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2876 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2877 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2878 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2879 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2880 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2881 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2882 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2883 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2884 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2885 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2886 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2887 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2888 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2889 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2890 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2891 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2892 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2893 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2894 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2895 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2896 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2897 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2898 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2899 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2900 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2901 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2902 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2903 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2904 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Some interes…
2905 need to quote it. Not a problem, but something to be aware. And the temp…
2906 string in GitHub Actions uses the same &lt;code&gt;${}&lt;/code&gt; that…
2907 escape.&lt;/p&gt;
2908 &lt;p&gt;And after running the following commands:&lt;/p&gt;
2909 &lt;pre&gt;&lt;code&gt;$ nix build .#packages.x86_64-linux.toYAML
2910 $ cat result/go.yaml
2911 jobs:
2912 build:
2913 permissions:
2914 contents: write
2915 runs-on: ubuntu-latest
2916 steps:
2917 - uses: actions/checkout@v4
2918 - name: Set up Go
2919 uses: actions/checkout@v4
2920 with:
2921 go-version: &amp;quot;1.21&amp;quot;
2922 - name: Update
2923 run: make
2924 - env:
2925 MATAROA_TOKEN: ${{ secrets.MATAROA_TOKEN }}
2926 name: Publish
2927 run: make publish
2928 - name: Commit
2929 uses: stefanzweifel/git-auto-commit-action@v5
2930 with:
2931 commit_message: README/rss:update
2932 name: Go
2933 &amp;quot;on&amp;quot;:
2934 push:
2935 branches:
2936 - main
2937 &lt;/code&gt;&lt;/pre&gt;
2938 &lt;p&gt;Yes, the keys are not in the same order as we defined, since Ni…
2939 programming languages (with the exception of
2940 &lt;a href="https://mail.python.org/pipermail/python-dev/2017-December/1…
2941 do not guarantee the insertion order in maps/dicts/attrsets/whatever. Bu…
2942 really hope whatever is consuming your YAML is not relying in the order …
2943 keys are defined (this would be more cursed than YAML already is).&lt;/p…
2944 &lt;p&gt;So that is basically it. For the bonus points that I talked at …
2945 post, we can modify &lt;code&gt;pkgs.runCommand&lt;/code&gt; to run some…
2946 &lt;a href="https://github.com/mpalmer/action-validator"&gt;&lt;code&gt;…
2947 particularly packaged in
2948 &lt;a href="https://github.com/NixOS/nixpkgs/pull/260217"&gt;nixpkgs&lt;…
2949 But you could use e.g.: a validator of Kubernetes YAML. Or a generic YAM…
2950 like this &lt;a href="https://github.com/adrienverge/yamllint"&gt;one&lt…
2951 endless.&lt;/p&gt;
2952 &lt;p&gt;Let's modify our &lt;code&gt;flake.nix&lt;/code&gt; to add the …
2953 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2954 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2955 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2956 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2957 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2958 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2959 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2960 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2961 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2962 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2963 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2964 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2965 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2966 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2967 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2968 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2969 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2970 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2971 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2972 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2973 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2974 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2975 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And let's ad…
2976 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
2977 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2978 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2979 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2980 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2981 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2982 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2983 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2984 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2985 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2986 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
2987 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2988 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
2989 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Finally, let…
2990 &lt;pre&gt;&lt;code&gt;$ nix build .#packages.x86_64-linux.toYAML
2991 error: builder for '/nix/store/j8wr6j1pvyf986sf74hqw8k31lvlzac5-toYAML.d…
2992 last 25 log lines:
2993 &amp;gt; &amp;quot;Additional pro…
2994 &amp;gt; ),
2995 &amp;gt; path: &amp;quot;/jobs/build&…
2996 &amp;gt; title: &amp;quot;Property co…
2997 &amp;gt; },
2998 &amp;gt; Properties {
2999 &amp;gt; code: &amp;quot;properties&a…
3000 &amp;gt; detail: Some(
3001 &amp;gt; &amp;quot;Additional pro…
3002 &amp;gt; ),
3003 &amp;gt; path: &amp;quot;/jobs/build&…
3004 &amp;gt; title: &amp;quot;Property co…
3005 &amp;gt; },
3006 &amp;gt; Required {
3007 &amp;gt; code: &amp;quot;required&amp…
3008 &amp;gt; detail: None,
3009 &amp;gt; path: &amp;quot;/jobs/build/…
3010 &amp;gt; title: &amp;quot;This proper…
3011 &amp;gt; },
3012 &amp;gt; ],
3013 &amp;gt; },
3014 &amp;gt; ],
3015 &amp;gt; },
3016 &amp;gt; ],
3017 &amp;gt; }
3018 For full logs, run 'nix log /nix/store/j8wr6j1pvyf986sf74hqw8k31l…
3019 &lt;/code&gt;&lt;/pre&gt;
3020 &lt;p&gt;Yes, the output of &lt;code&gt;action-validator&lt;/code&gt; is…
3021 better than making &lt;a href="https://x.com/eric_sink/status/1430954572…
3022 hour&amp;quot;&lt;/a&gt;.&lt;/p&gt;
3023 &lt;p&gt;If you are interested in how a more advantage usage of this tec…
3024 including usage of functions and constants to share common steps between
3025 different actions, please take a look at the
3026 &lt;a href="https://github.com/thiagokokada/nix-configs/tree/master/acti…
3027 (&lt;a href="https://github.com/thiagokokada/nix-configs/tree/fbbc8f935c…
3028 in my &lt;code&gt;nix-config&lt;/code&gt; repository.&lt;/p&gt;</descrip…
3029 Color&lt;/a&gt; made of completely new
3030 parts for a friend: here is the
3031 &lt;a href="https://funnyplaying.com/products/fpgbc-kit"&gt;FPGBC&lt;/a&…
3032 &lt;p&gt;The &lt;em&gt;FP&lt;/em&gt; part of the name comes from
3033 &lt;a href="https://en.wikipedia.org/wiki/Field-programmable_gate_array"…
3034 instead of software emulation this device use FPGA to reproduce the devi…
3035 While I am not convinced that FPGA is necessary more accurate than a good
3036 software emulator, one advantage of FPGA is the (possible) lower input l…
3037 thanks to the avoidance of complexity to handle the user input (e.g.: the
3038 Operational System). A quick playthrough against &lt;a href="https://en.…
3039 Maniacs&lt;/a&gt; seems to be fine, but
3040 I can't see much difference from my &lt;a href="https://retrogamecorps.c…
3041 Mini+&lt;/a&gt; (I will do
3042 more comparisons between the two devices later), that is a software emul…
3043 device.&lt;/p&gt;
3044 &lt;p&gt;But I think focusing in accuracy is wrong, the main reason of g…
3045 like this one is for nostalgia, and this definitely hit the mark. The qu…
3046 of the case is as good as I remember the original, and most of the detai…
3047 replicate perfectly, including reproduction stickers in the back of the …
3048 The only differences that I can find is the usage of USB-C port for char…
3049 place of the barrel jack power adapter (thanks!), and the fact that the …
3050 bezels are smaller compared to the original (because the screen is bigge…
3051 doesn't include the Game Boy Color logo (that is fine in my opinion, sin…
3052 would look weird in the fine bezels). It even has a supposedly working &…
3053 Cable&lt;/a&gt; (I don't have another
3054 Game Boy to test). Sadly it is missing the infrared sensor, but the usag…
3055 that was pretty limited anyway.&lt;/p&gt;
3056 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
3057 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
3058 &lt;p&gt;So how well does it work? I can't say for sure. I don't have an…
3059 with me, so I am relying in backups and a
3060 &lt;a href="https://en.wikipedia.org/wiki/Flashcard"&gt;flashcard&lt;/a&…
3061 tested works fine, a few of them have graphical issues that can be fixed…
3062 menu (more about it later), and some of them doesn't boot. But I don't k…
3063 the issue with the games not booting are because of the roms, the flashc…
3064 the device itself.&lt;/p&gt;
3065 &lt;p&gt;By the way, the flashcard I am using is a cheap knockoff of an …
3066 GB&lt;/a&gt;. This FPGBC came with
3067 firmware v1.09, while there is an update available for v1.10 in the
3068 &lt;a href="https://funnyplaying.com/products/fpgbc-kit"&gt;website&lt;/…
3069 the new firmware where no games would boot with this knockoff Everdrive …
3070 had to go back to v1.09, but again, I am not sure if the issue was fact …
3071 am using a knockoff device or this would happen with an original Everdri…
3072 If you are going to buy a proper Everdrive, you probably wouldn't get a
3073 Everdrive GB anyway since it is discontinued, and it seems the &lt;a hre…
3074 versions&lt;/a&gt;
3075 have better compatibility with FPGBC.&lt;/p&gt;
3076 &lt;p&gt;Sadly that the update didn't work, since there is this
3077 &lt;a href="https://github.com/makhowastaken/GWGBC_FW"&gt;repository&lt;…
3078 firmware to boot the original logo instead of the ugly FPGBC one. And ye…
3079 some reason the v1.09 firmware from this repository still doesn't work w…
3080 knockoff Everdrive.&lt;/p&gt;
3081 &lt;p&gt;By the way, it seems the device is not easy to brick: I borked …
3082 update process once while trying to downgrade back to v1.09, resulting i…
3083 black screen when I turned on the console. But just connecting the devic…
3084 the computer and powering on, I could flash the firmware again and the d…
3085 came back to life.&lt;/p&gt;
3086 &lt;p&gt;About the features of the device: if you press the volume butto…
3087 press it now), it opens the following menu:&lt;/p&gt;
3088 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
3089 &lt;p&gt;The first 2 options are the LCD backlight (&lt;code&gt;BKLT&lt;…
3090 those, but the LCD screen seems to be IPS, and the quality is really goo…
3091 also looks bright enough to play even under bad lightining conditions. A…
3092 speaker has good quality, the sound is better than I remember, but sadly…
3093 maximum volume is kind low. Still should be enough for playing in a quie…
3094 &lt;p&gt;&lt;code&gt;DISPMOD&lt;/code&gt; is probably the most controver…
3095 scale you want. Anything with &lt;code&gt;EMU&lt;/code&gt; at the end me…
3096 colors, and as far I remember it gets really close. You can also chose b…
3097 &lt;code&gt;X4&lt;/code&gt;, &lt;code&gt;X4P&lt;/code&gt; and &lt;code&g…
3098 image fills the whole screen at the cost of non-integer scaling. &lt;cod…
3099 integer scaling, however the image doesn't fill the whole screen. The &l…
3100 also includes a pixel effect that makes the image closer than the origin…
3101 screen. It actually looks good, but the fact that I chose a white border…
3102 this FPGBC makes the border really distracting. Maybe the black one is a…
3103 choice if you want integer scale.&lt;/p&gt;
3104 &lt;p&gt;&lt;code&gt;CORE&lt;/code&gt; is simple: you can choose between…
3105 Color). For those who don't know, you can run Game Boy games in Game Boy…
3106 and they will be automatically colorised. Some people don't like this and
3107 prefer the colors of &lt;code&gt;GB&lt;/code&gt;, so you have this optio…
3108 to chose the color in GB mode, for example, the green-ish colors from the
3109 original Game Boy or the blue-ish colors from &lt;a href="https://ninten…
3110 Light&lt;/a&gt;. And yes, you can
3111 choose the color palette for Game Boy games running in &lt;code&gt;GBC&l…
3112 &lt;a href="https://gbstudiocentral.com/tips/game-boy-color-modes/"&gt;b…
3113 the boot screen, but it seems not working in my unit and again, not sure…
3114 fault is my knockoff Everdrive.&lt;/p&gt;
3115 &lt;p&gt;&lt;code&gt;FRAME_MIX&lt;/code&gt; basically is an option that …
3116 in &lt;a href="https://en.wikipedia.org/wiki/Wave_Race"&gt;Wave Race&lt;…
3117 introducing blurriness. The reason for this is that those effects depend…
3118 the fact that the Game Boy screen was slow refresh, so you could rely on…
3119 rapidly changing pixels to create some interesting effects, but sadly th…
3120 effects doesn't work well in modern displays.&lt;/p&gt;
3121 &lt;p&gt;&lt;code&gt;GB_CLRFIX&lt;/code&gt; is the option I mentioned be…
3122 get completely wrong colors for some reason, e.g.: &lt;a href="https://e…
3123 Family&lt;/a&gt;. Turning
3124 on fixes those games, but I am not sure if this option breaks other game…
3125 &lt;p&gt;Finally, &lt;code&gt;SPD&lt;/code&gt; allows you to increase or…
3126 speeding up the games (including the sound). The result can be hilarious…
3127 think this is a nice addition to the features. Sadly you can't know what…
3128 default speed is, so you need to rely on sound to adjust back to the def…
3129 &lt;p&gt;So in the end, can I recommend a FPGBC? I am not sure. If you w…
3130 play games, I still think something like a Miyoo Mini+ is a better choic…
3131 only you will have access to more games from different platforms, you al…
3132 don't need to rely on flashcards or cartridges. Also it has way more fea…
3133 than FPGBC, like wireless multiplayer,
3134 &lt;a href="https://retroachievements.org/"&gt;RetroArchivements&lt;/a&g…
3135 &lt;p&gt;But the actual reason to get a FPGBC is nostalgia, and for that…
3136 FPGBC is difficult to beat. The price of the &lt;a href="https://funnypl…
3137 assemble&lt;/a&gt; ($69.90) is cheaper than
3138 most Game Boy's in good condition you can find in eBay, and you get for …
3139 price a rechargable battery, an amazing quality screen, the PCB and the
3140 speaker. You need to buy separately the case and the buttons, but in tot…
3141 will still end up paying less, and allows you to fully customise your bu…
3142 And the result device is not only in mint condition, it is really conven…
3143 too: recharging batteries (via USB-C even) is much more convenient than …
3144 AA batteries, and the screen not only is better but it even has backligh…
3145 can also buy a fully built console for
3146 &lt;a href="https://funnyplaying.com/products/fpgbc-console"&gt;$99.00&l…
3147 options of customisation.&lt;/p&gt;
3148 &lt;p&gt;This is the classic case of do what I say, don't do what I do. …
3149 gift, and I will buy another one soon. Can't wait to play &lt;a href="ht…
3150 Gold&lt;/a&gt; in (almost)
3151 original hardware again.&lt;/p&gt;
3152 &lt;p&gt;&lt;a href="https://github.com/thiagokokada/blog/raw/main/posts…
3153 blog&lt;/a&gt; without I ever touching the
3154 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt; website. I…
3155 script&lt;/a&gt; to Go
3156 (&lt;a href="https://github.com/thiagokokada/blog/blob/3c39e0f7cd58b1af8…
3157 since my attempt to generate proper description to the RSS feed resulted…
3158 slow startup times (not because of Python, but because of my usage of
3159 &lt;code&gt;nix-shell&lt;/code&gt; since I didn't want to deal with
3160 &lt;a href="https://docs.python.org/3/library/venv.html"&gt;venv&lt;/a&g…
3161 Python dependencies).&lt;/p&gt;
3162 &lt;p&gt;My previous workflow of this blog already involved me writing t…
3163 &lt;a href="https://neovim.io/"&gt;neovim&lt;/a&gt;, copying and pasting…
3164 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt; website an…
3165 that bad, except that it seems I have a heavy tendency of editing my pos…
3166 multiple times. Copying and pasting data between neovim and the website …
3167 tedious, so I decided to give up and automate the whole process.&lt;/p&g…
3168 &lt;p&gt;&lt;a href="https://mataroa.blog/"&gt;Mataroa&lt;/a&gt; (the bl…
3169 &lt;a href="https://capivaras.dev"&gt;capivaras.dev&lt;/a&gt; run) has a…
3170 &lt;a href="https://mataroa.blog/api/docs/"&gt;API&lt;/a&gt;, and it onl…
3171 version of publishing working (it would take less if
3172 &lt;a href="https://www.djangoproject.com/"&gt;Django&lt;/a&gt;, the fra…
3173 not have a weird behavior with URLs missing a trailing &lt;code&gt;/&lt;…
3174 lines of
3175 &lt;a href="https://github.com/thiagokokada/blog/blob/51b20612335c7f4312…
3176 to make GitHub Actions trigger a pipeline and now I should never have to
3177 manually update my blog again.&lt;/p&gt;
3178 &lt;p&gt;I could have not done this. I mean, I probably wasted more time…
3179 automation than I actually wasted publishing manually. But the manual pr…
3180 is easy to miss, and I already did multiple mistakes publishing in the m…
3181 method. For example, when writing the Markdown files, each post is writt…
3182 particular format, where the first header is considered the title, so I …
3183 remove it from the contents during publication. But of course, this is e…
3184 miss, and I had to fix this multiple times already.&lt;/p&gt;
3185 &lt;p&gt;So yes, I think this is a good lesson on why you should automat…
3186 is more than just about &lt;a href="https://xkcd.com/1205/"&gt;time savi…
3187 reducing mistakes and even documenting (even if poorly) a process. I mea…
3188 code I wrote is not that great, but I can definitely rely on it in the f…
3189 to remember what I need to do. It will be much faster than trying to lea…
3190 scratch again.&lt;/p&gt;</description><pubDate>Mon, 29 Jul 2024 00:00:00…
3191 got the hang of it. I first got interested in the language when I was in…
3192 first job, between 2016-2018. At the time the language was a completely
3193 different beast: no modules, no generics, no easy way to error wrap yet,…
3194 &lt;p&gt;Go forward 2023 (no pun indented), I wrote my &lt;a href="https…
3195 Go&lt;/a&gt;, wrote some scripts
3196 at &lt;code&gt;$CURRENT_JOB&lt;/code&gt; in the language, and now wrote …
3197 library&lt;/a&gt; (with an &lt;a href="https://kokada.dev/blog/writing-n…
3198 way to run
3199 CI&lt;/a&gt;). I am also
3200 writing more
3201 &lt;a href="https://github.com/thiagokokada/nix-configs/blob/8c559527ed1…
3202 in the language, where I would prefer to use Bash or Python before. Heck…
3203 this blog is automatically published with a &lt;a href="https://kokada.d…
3204 script&lt;/a&gt;,
3205 that used to be a &lt;a href="https://kokada.dev/blog/using-github-as-a-…
3206 one&lt;/a&gt; before. I can
3207 say that nowadays it is another language in my toolbox, and while it is …
3208 love and hate relationship, recently it is more about love and less abou…
3209 &lt;p&gt;The points that I love about Go is probably obvious for some, b…
3210 interesting to talk about anyway. The fact that the language generates s…
3211 binaries by default and have fast compilation times is something that I
3212 apreciate since I first heard about the language, and now that I am usin…
3213 language frequently, are points thatI appreciate even more. Something ab…
3214 getting almost instant feedback after changing a line of code and runnin…
3215 main reason why I am using the language more frequently for scripts.&lt;…
3216 &lt;p&gt;Then we have the fast startup times. I am kind of sensitive to …
3217 especially of command line utilities that need to answer fast when I exp…
3218 them to be fast (e.g.: &lt;code&gt;foo --help&lt;/code&gt;). This is one…
3219 issues in Python, especially for more complex programs, but in Go it is …
3220 an issue.&lt;/p&gt;
3221 &lt;p&gt;Modules are also fantastic. It is not without its weirdness (li…
3222 Go ecossystem), but the fact that it is so easy to add and manage depend…
3223 in a project using only the &lt;code&gt;go&lt;/code&gt; CLI is great. I …
3224 hash of every dependency, making it reproducible (well, probably not at …
3225 level, but still reproducible).&lt;/p&gt;
3226 &lt;p&gt;Since I started to talk about &lt;code&gt;go&lt;/code&gt; CLI, …
3227 can manage dependencies, generate documentation, format code, lint, run
3228 tests/&lt;a href="https://blog.logrocket.com/benchmarking-golang-improve…
3229 check code for &lt;a href="https://go.dev/doc/articles/race_detector"&gt…
3230 with just the &amp;quot;compiler&amp;quot; for the language is excelent.…
3231 the best developer experiences I know in any programming language.&lt;/p…
3232 &lt;p&gt;I will not even talk about the things that everyone talks about…
3233 &lt;a href="https://go.dev/doc/effective_go#goroutines"&gt;goroutines&lt…
3234 think I can add anything interesting to the topic.&lt;/p&gt;
3235 &lt;p&gt;Now for the parts that I like less, the test part still quirks …
3236 not based in assertions, but thankfully it is easy to write assertions w…
3237 generics nowadays:&lt;/p&gt;
3238 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3239 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3240 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3241 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3242 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3243 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3244 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3245 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3246 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3247 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3248 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3249 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3250 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3251 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3252 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3253 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
3254 about &lt;a href="https://github.com/stretchr/testify"&gt;testify&lt;/a&…
3255 libraries, but quoting &lt;a href="https://www.youtube.com/watch?v=PAAkC…
3256 Pike&lt;/a&gt; here, &amp;quot;a little
3257 copying is better than a little dependency&amp;quot;. As long the code y…
3258 trivial, it is better to duplicate the code than try to import a depende…
3259 &lt;p&gt;About another piece of code that generics allows me to write an…
3260 up re-writing in every project is the &lt;code&gt;must*&lt;/code&gt; fam…
3261 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3262 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3263 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3264 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3265 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3266 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3267 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3268 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3269 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3270 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3271 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3272 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3273 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3274 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3275 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3276 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3277 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3278 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
3279 want to handle each error: if I have an error, I want the program to hal…
3280 print a stack trace (exactly as I would have with a language with except…
3281 It basically allow me to convert code from:&lt;/p&gt;
3282 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3283 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3284 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3285 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3286 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To:&lt;/p&gt;
3287 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3288 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This brings …
3289 something great.&lt;/p&gt;
3290 &lt;p&gt;Finally, for the things that I hate, well the biggest one curre…
3291 of nullability (or in Go terms,
3292 &lt;a href="https://github.com/golang/go/issues/49202"&gt;nillability&lt…
3293 languages that has it, like Kotlin, or even something like
3294 &lt;a href="https://www.mypy-lang.org/"&gt;mypy&lt;/a&gt;, this is one o…
3295 changes the developer experience. I also still don't like the error hand…
3296 (but &lt;code&gt;must*&lt;/code&gt; goes far by improving the situation,…
3297 it), especially because it is easy to lose context on it:&lt;/p&gt;
3298 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3299 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3300 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3301 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3302 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3303 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3304 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3305 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3306 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3307 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3308 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3309 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3310 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3311 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3312 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3313 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3314 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3315 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I also have …
3316 prefer immutability by default, but I find that in general as long as yo…
3317 your functions at a reasonable size it is generally fine.&lt;/p&gt;
3318 &lt;p&gt;And for a language that is supposed to be straightforward, it i…
3319 much magic the language relies on, in the form of things like &lt;a href…
3320 &lt;code&gt;main&lt;/code&gt;&lt;/a&gt; packages, name capitalisation to
3321 indicate visibility (&lt;code&gt;private&lt;/code&gt; vs &lt;code&gt;Pub…
3322 (e.g.: &lt;code&gt;foo_amd64.go&lt;/code&gt;, &lt;code&gt;bar_linux.go&l…
3323 etc.&lt;/p&gt;
3324 &lt;p&gt;I expect to write more Go code going forward. Not because it is…
3325 language or whatever, but just because it a is language that has some re…
3326 good qualities that makes the language attractive even with the issues t…
3327 have. That makes it a reasonable good language, and at least for me this…
3328 good enough.&lt;/p&gt;</description><pubDate>Mon, 29 Jul 2024 00:00:00 +…
3329 ecosystem work, I just wanted to get it to run.&lt;/p&gt;
3330 &lt;p&gt;The easiest way to get a script to run if you use Nix is to use…
3331 many of you probably know, you can add &lt;code&gt;nix-shell&lt;/code&gt…
3332 to run them as &lt;code&gt;./script&lt;/code&gt;. This was a PHP script …
3333 Easy right?&lt;/p&gt;
3334 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3335 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3336 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3337 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3338 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And:&lt;/p&g…
3339 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3340 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3341 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
3342 script if used. I removed &lt;code&gt;declare(strict_types=1)&lt;/code&g…
3343 I don't have enough expertise in PHP to know if this would be safe or no…
3344 &lt;p&gt;I decided to try something that initially looked really dumb:&l…
3345 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3346 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3347 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3348 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3349 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
3350 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3351 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3352 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt…
3353 &lt;p&gt;Eventually I found this
3354 &lt;a href="https://github.com/NixOS/nix/issues/2570#issuecomment-446220…
3355 Nix issue talking about cases where &lt;code&gt;nix-shell&lt;/code&gt; s…
3356 like the classic case of a &lt;a href="https://github.com/NixOS/nix/issu…
3357 feature&lt;/a&gt;.&lt;/p&gt;
3358 &lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; after posting this in
3359 &lt;a href="https://lobste.rs/s/gkcgza/quick_bits_nix_shell_is_cursed"&g…
3360 someone decided to open a &lt;a href="https://github.com/NixOS/nix/pull/…
3361 Request&lt;/a&gt; to document this behavior.
3362 Also the equivalent for the new &lt;a href="https://nix.dev/manual/nix/2…
3363 CLI&lt;/a&gt;
3364 explicitly documents this behavior:&lt;/p&gt;
3365 &lt;blockquote&gt;
3366 &lt;p&gt;Note that the &lt;code&gt;#! nix&lt;/code&gt; lines don't need …
3367 accomodate other interpreters.&lt;/p&gt;
3368 &lt;/blockquote&gt;</description><pubDate>Sat, 27 Jul 2024 00:00:00 +000…
3369 &lt;a href="https://gluer.org/"&gt;@ratsclub&lt;/a&gt; to give me free a…
3370 &lt;a href="https://capivaras.dev/"&gt;capivaras.dev&lt;/a&gt;. But cons…
3371 platform is supposed to be, I want to have at least somewhere to have a …
3372 of my posts. I know &lt;a href="https://mataroa.blog/"&gt;Mataroa&lt;/a&…
3373 &lt;a href="https://capivaras.dev/"&gt;capivaras.dev&lt;/a&gt; runs, has…
3374 I want something more reliable.&lt;/p&gt;
3375 &lt;p&gt;I am writing all my posts in Markdown (the format that &lt;a hr…
3376 supports&lt;/a&gt;) files inside
3377 &lt;a href="https://neovim.io/"&gt;neovim&lt;/a&gt; anyway, so why not s…
3378 Git? So this is what I did, I now have an unofficial mirror in
3379 &lt;a href="https://github.com/thiagokokada/blog"&gt;GitHub&lt;/a&gt;.&l…
3380 &lt;p&gt;While I am here, why not overcomplicate? Can I make an usable b…
3381 from GitHub? And by that I don't mean GitHub pages, the repository itsel…
3382 mean, it already renders Markdown files by default, so no need to do any…
3383 in that space. To reach feature parity with
3384 &lt;a href="https://capivaras.dev/"&gt;capivaras.dev&lt;/a&gt;, I only n…
3385 (since comments are not supported anyway). No need for newsletter since …
3386 has a &lt;a href="https://docs.github.com/en/account-and-profile/managin…
3387 feature&lt;/a&gt;
3388 already.&lt;/p&gt;
3389 &lt;p&gt;After a couple of hours hacking a Python script, you can see th…
3390 monstrosity &lt;a href="https://github.com/thiagokokada/blog"&gt;here&lt…
3391 &lt;code&gt;gen_blog.py&lt;/code&gt;, is available at the same repositor…
3392 &lt;a href="https://github.com/thiagokokada/blog/blob/c8986d1ab1b94c0986…
3393 It automatically generates an index at
3394 &lt;a href="https://github.com/thiagokokada/blog/blob/main/README.md"&gt…
3395 each blog post and a
3396 &lt;a href="https://raw.githubusercontent.com/thiagokokada/blog/main/rss…
3397 file at the root of the repository.&lt;/p&gt;
3398 &lt;p&gt;Instead of trying to explain the code, I am going to explain th…
3399 because I think that if you want to replicate this idea it is better to …
3400 it in a way that you understand. It shouldn't take more than 2 hours in …
3401 decent programming language. But if you really want, the script itself is
3402 licensed in &lt;a href="https://en.wikipedia.org/wiki/WTFPL"&gt;WTFPL&lt…
3403 uses Python 3's standard library and should work in any relatively recent
3404 version (anything newer than 3.9 should work).&lt;/p&gt;
3405 &lt;p&gt;So the idea is basically to organise the repository and the Mar…
3406 easy way that makes it trivial to parse in a deterministic way. For exam…
3407 repository is organised in the following way:&lt;/p&gt;
3408 &lt;pre&gt;&lt;code&gt;.
3409 ├── 2024-07-26
3410 │ ├── 01-writing-nixos-tests-for-fun-and-profit.md
3411 │ └── 02-using-github-as-a-bad-blog-platform.md &amp;lt;- this…
3412 ├── gen_blog.py
3413 ├── README.md
3414 └── rss.xml
3415 &lt;/code&gt;&lt;/pre&gt;
3416 &lt;p&gt;Each day that you write a new blog post will be on its own dire…
3417 nice because Markdown files may include extra files than the posts thems…
3418 e.g.: images, and this organisation make it trivial to organise everythi…
3419 &lt;p&gt;Each post has its own Markdown file. I put a two digit number b…
3420 to ensure that when publishing multiple posts at the same day I keep the…
3421 the same order of publishing. But if you don't care about it, you can ju…
3422 the files whatever you want.&lt;/p&gt;
3423 &lt;p&gt;Also, I am assuming that each Markdown file has a header starti…
3424 and that is the title of the blog post.&lt;/p&gt;
3425 &lt;p&gt;Using the above organisation, I have this function that scrapes…
3426 and collect the necessary information to generate the index and RSS file…
3427 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3428 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3429 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3430 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3431 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3432 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3433 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3434 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3435 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3436 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3437 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3438 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3439 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3440 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3441 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3442 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3443 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3444 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3445 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3446 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3447 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3448 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3449 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3450 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3451 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3452 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3453 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3454 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3455 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3456 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3457 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Some interes…
3458 is a draft post, and ignore it from my scraper. I added a bunch of &lt;c…
3459 prints to make sure that the me in the future doesn't do anything dumb. …
3460 sorting in reverse since reverse chronological order is the one most peo…
3461 expect in blogs (i.e.: more recent blog posts at top).&lt;/p&gt;
3462 &lt;p&gt;After running the function above, I have a resulting dictionary…
3463 to generate either a &lt;code&gt;README.md&lt;/code&gt; file or Markdown…
3464 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3465 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3466 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3467 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3468 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3469 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3470 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3471 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3472 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3473 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3474 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3475 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3476 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3477 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3478 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3479 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3480 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3481 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3482 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3483 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3484 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3485 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3486 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3487 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3488 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3489 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3490 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3491 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3492 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3493 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3494 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3495 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3496 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3497 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3498 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3499 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3500 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3501 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3502 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3503 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3504 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3505 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3506 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3507 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To publish a…
3508 &lt;blockquote&gt;
3509 &lt;p&gt;README.md` at the root of the repository, and see the magic hap…
3510 &lt;/blockquote&gt;
3511 &lt;p&gt;It works much better than I initially anticipated. The &lt;code…
3512 populated with the titles and links. The RSS is kind of empty since it h…
3513 description, but it seems to work fine (at least in
3514 &lt;a href="https://www.inoreader.com/"&gt;Inoreader&lt;/a&gt;, my RSS r…
3515 probably fill the post description with more information if I really wan…
3516 it is enough for now (update: it is working now, you just need to render…
3517 Markdown as HTML and escape the tags;
3518 &lt;a href="https://github.com/thiagokokada/blog/blob/9506051cc3d49f2033…
3519 for the updated script). Not sure who is that interested in my writing t…
3520 will want to use this RSS feed instead the one available in
3521 &lt;a href="https://kokada.capivaras.dev/rss/"&gt;capivaras.dev&lt;/a&gt…
3522 &lt;p&gt;Also, while I am using GitHub here, the same idea would work in…
3523 sr.ht or whatever. As long as your source hub supports Markdown files it…
3524 work.&lt;/p&gt;
3525 &lt;p&gt;So that is it. I am not saying this is a good idea for your pri…
3526 platform or whatever, and I still prefer to publish to a platform that d…
3527 track users or have tons of JavaScript or whatever. But if you want a ba…
3528 your posts and you are already writing Markdown anyway, well, there are …
3529 ways to do it I think.&lt;/p&gt;
3530 &lt;p&gt;&lt;em&gt;Update:&lt;/em&gt; I rewrote the script again using Go
3531 (&lt;a href="https://github.com/thiagokokada/blog/blob/3ece3853e7dd32977…
3532 The reason for it is because when I started rendering Markdown (for
3533 descriptions) the Python version got quite slow (not the fault of Python
3534 itself, mostly because of the usage of &lt;code&gt;nix-shell&lt;/code&gt…
3535 something that Go doesn't need). Took about half an hour, showing how ea…
3536 is to do the same.&lt;/p&gt;</description><pubDate>Fri, 26 Jul 2024 00:0…
3537 project&lt;/a&gt; writing an IPC library in
3538 Go for &lt;a href="https://hyprland.org/"&gt;Hyprland&lt;/a&gt;, a Windo…
3539 &lt;p&gt;Once I got past the Work-in-Progress phase, I realise I had an …
3540 some tests, but I was running then inside my system running Hyprland. An…
3541 tests themselves were annoying: since they send commands to the current …
3542 Hyprland instance, I was having programs being opened and settings being
3543 changed, because this was the only way to have a reasonable good confide…
3544 that what I was doing was correct. So I need to do like any good develop…
3545 implement a CI, but how?&lt;/p&gt;
3546 &lt;p&gt;One approach would be to create something like a mock client an…
3547 my mock. Since this mock wouldn't need a running Hyprland instance the t…
3548 could run everywhere (even in non-Linux systems!), but they wouldn't be …
3549 useful. Mocks are great for testing business logic, but not really for m…
3550 sure everything is working correctly.&lt;/p&gt;
3551 &lt;p&gt;I need something more akin to an integration test, but this is …
3552 not like I am doing integration with e.g.: PostgreSQL that has thousands…
3553 libraries available to make integration tests easier, I am doing integra…
3554 with a Window Manager that is a moving target with multiple breaking cha…
3555 each release. And this is where NixOS tests enter, a way to run tests in…
3556 Virtual Machines configured in Nix.&lt;/p&gt;
3557 &lt;p&gt;I am a long time NixOS user and commiter, but I never wrote a N…
3558 outside of &lt;a href="https://github.com/NixOS/nixpkgs"&gt;nixpkgs&lt;/…
3559 it was possible, and after doing a quick reading of the &lt;a href="http…
3560 entry&lt;/a&gt; about it, I was ready to
3561 start.&lt;/p&gt;
3562 &lt;p&gt;The first part is to call &lt;code&gt;pkgs.testers.runNixOSTest…
3563 as any other NixOS system, e.g.:&lt;/p&gt;
3564 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3565 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3566 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3567 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3568 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3569 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3570 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3571 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3572 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3573 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3574 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3575 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3576 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3577 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3578 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3579 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3580 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3581 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3582 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3583 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3584 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3585 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3586 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3587 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3588 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3589 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3590 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3591 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3592 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3593 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3594 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3595 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3596 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3597 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3598 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3599 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3600 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3601 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3602 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3603 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3604 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3605 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A few detail…
3606 is to setup things like a normal user account, add some extra packages w…
3607 for testing, add Hyprland itself and configure auto-login. I have no ide…
3608 painful it would be to automatise all those steps in e.g.: Ansible, but …
3609 are in a few lines of Nix code. This is, of course, thanks to all the
3610 contributors to nixpkgs that implement something that help their own use…
3611 but once combined make it greater than the sum of the parts.&lt;/p&gt;
3612 &lt;p&gt;Second is something that I took a while to figure out: how to e…
3613 acceleration inside the VM. You see, Hyprland, different from other Wind…
3614 Managers, requires OpenGL support. This is basically why the flag &lt;co…
3615 rendering via LLVMPipe, that while being slow since it is rendered in CP…
3616 sufficient for this case.&lt;/p&gt;
3617 &lt;p&gt;Putting the above code inside a
3618 &lt;a href="https://wiki.nixos.org/wiki/Flakes"&gt;&lt;code&gt;flake.nix…
3619 something similar to:&lt;/p&gt;
3620 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3621 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3622 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3623 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3624 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3625 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3626 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3627 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3628 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3629 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3630 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3631 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3632 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3633 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3634 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3635 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3636 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3637 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3638 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3639 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3640 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I can now ru…
3641 VM. However it is not really useful right now, since we didn't add any u…
3642 code in &lt;code&gt;testScript&lt;/code&gt;, the core of the NixOS test …
3643 &lt;code&gt;nix build .#checks.x86_64-linux.testVm.driverInteractive&lt;…
3644 &lt;code&gt;./result/bin/nixos-test-driver&lt;/code&gt;: this will start…
3645 manually play with the VM (try typing &lt;code&gt;start_all()&lt;/code&g…
3646 &lt;p&gt;The &lt;code&gt;testScript&lt;/code&gt; is a sequence of Python…
3647 actions, such as starting VMs, executing commands in the VMs, and so on.…
3648 about it in the official
3649 &lt;a href="https://nixos.org/manual/nixos/stable/index.html#sec-nixos-t…
3650 For our case we can start with something like this:&lt;/p&gt;
3651 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3652 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3653 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3654 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3655 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3656 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3657 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3658 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3659 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first st…
3660 one, called &lt;code&gt;machine&lt;/code&gt;. We send two further comman…
3661 &lt;code&gt;wait_for_unit(&amp;quot;multi-user.target&amp;quot;)&lt;/cod…
3662 &lt;code&gt;wait_for_file(&amp;quot;/home/alice/test-finished&amp;quot;)…
3663 &lt;p&gt;The first command waits until systemd's &lt;code&gt;multi-user.…
3664 way to ensure that the system is ready for further commands. The second …
3665 wait for a file called &lt;code&gt;test-finished&lt;/code&gt; to appear …
3666 a canary), but how can we generate this file?&lt;/p&gt;
3667 &lt;p&gt;Remember that we added &lt;code&gt;programs.bash.loginShellInit…
3668 automatically starts Hyprland when Alice logs in. We need to modify that
3669 command to run the Go tests from our library. The good thing is that Hyp…
3670 configuration file supports a
3671 &lt;a href="https://wiki.hyprland.org/Configuring/Keywords/#executing"&g…
3672 command that runs a command during Hyprland launch. We can abuse this to…
3673 a terminal emulator and run our tests:&lt;/p&gt;
3674 &lt;pre class="chroma"&gt;&lt;code&gt;&lt;span class="line"&gt;&lt;span …
3675 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3676 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3677 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3678 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3679 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3680 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3681 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3682 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3683 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3684 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3685 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3686 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3687 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3688 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3689 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3690 &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span…
3691 &lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&g…
3692 &lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So we are ba…
3693 &lt;a href="https://sw.kovidgoyal.net/kitty/"&gt;Kitty&lt;/a&gt; termina…
3694 a shell script that runs the test. Since we have no way to get the resul…
3695 the test, we pipe the output to a file that we can collect later (e.g.:
3696 &lt;code&gt;machine.succeded(&amp;quot;cat /home/alice/test.log&amp;quot…
3697 create the canary file &lt;code&gt;$HOME/test-finished&lt;/code&gt;, tha…
3698 knows that the test finished and it can destroy the VM safely.&lt;/p&gt;
3699 &lt;p&gt;If you want to take a look at the final result, it is
3700 &lt;a href="https://github.com/thiagokokada/hyprland-go/blob/v0.0.1/flak…
3701 tests run in any Linux machine that supports KVM, and also works in &lt;…
3702 Actions&lt;/a&gt;
3703 thanks to the the
3704 &lt;a href="https://github.com/DeterminateSystems/nix-installer-action"&…
3705 &lt;p&gt;And now I have a proper CI pipeline in a way that I never imagi…
3706
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.