<feed xmlns="http://www.w3.org/2005/Atom"><id>https://hugosum.com/atom-feed.xml</id><title>Hugo Sum</title><link>https://hugosum.com</link><updated>Mon, 01 Sep 2025 04:41:58 GMT</updated><rights>Copyright 2025, Hugo Sum</rights><icon>https://hugosum.com/favicon.ico</icon><logo>https://hugosum.com/favicon.ico</logo><author><name>Hugo Sum</name></author><entry><id>https://hugosum.com/blog/how-do-i-search-and-replace-text-in-neovim</id><title>How do I search and replace text in Neovim</title><link>https://hugosum.com/blog/how-do-i-search-and-replace-text-in-neovim</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Searching and replacing text is something a developer would do frequently. Unlike other editors such as Visual Studio Code, Neovim doesn’t come with a search box for you to search and replace text in a file or in a workspace, and it has it own unique mechanism. In this post I want to share how do I search and replace text efficiently in Neovim.&lt;/p&gt; &lt;h2 id=&quot;searching-and-replacing-text-in-a-buffer-with-substitute-command&quot;&gt;&lt;a href=&quot;#searching-and-replacing-text-in-a-buffer-with-substitute-command&quot;&gt;Searching and replacing text in a buffer with &lt;code&gt;:substitute&lt;/code&gt; command&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Searching and replacing text in Neovim is a bit different from what you might be used to in other editors. Instead of a search box, you use the powerful &lt;code&gt;:substitute&lt;/code&gt; command, which gives you fine-grained control over your replacements.&lt;/p&gt; &lt;p&gt;To replace all occurrences of &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; in the entire file, you can use:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:%s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/g&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;ul&gt;&lt;li&gt;&lt;code&gt;:%&lt;/code&gt; means the whole file.&lt;/li&gt; &lt;li&gt;&lt;code&gt;s&lt;/code&gt; stands for substitute.&lt;/li&gt; &lt;li&gt;&lt;code&gt;/foo/bar/&lt;/code&gt; is the pattern and replacement.&lt;/li&gt; &lt;li&gt;&lt;code&gt;g&lt;/code&gt; means “global”—replace all matches on each line.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you only want to replace in a specific range, say lines 10 to 20:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;20s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/g&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Sometimes, you want to confirm each replacement before it happens. Add the &lt;code&gt;c&lt;/code&gt; flag:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:%s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/gc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Neovim will prompt you for each match, letting you decide whether to replace it.&lt;/p&gt; &lt;p&gt;You can also ignore cases by adding the &lt;code&gt;i&lt;/code&gt; flag:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:%s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/gci&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;For a deeper dive into the &lt;code&gt;:substitute&lt;/code&gt; command, the official &lt;a href=&quot;https://neovim.io/doc/user/change.html#:%20substitute&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Neovim documentation&lt;/a&gt; is a great resource.&lt;/p&gt; &lt;h2 id=&quot;searching-and-replacing-text-in-a-buffer-with-gn-motion&quot;&gt;&lt;a href=&quot;#searching-and-replacing-text-in-a-buffer-with-gn-motion&quot;&gt;Searching and replacing text in a buffer with &lt;code&gt;gn&lt;/code&gt; motion&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;While the &lt;code&gt;:substitute&lt;/code&gt; command is powerful, sometimes you want a more interactive way to search and replace text—especially when you only want to change some matches, not all. That’s where the &lt;code&gt;gn&lt;/code&gt; motion comes in.&lt;/p&gt; &lt;p&gt;The workflow is simple:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Search for the text you want to replace using &lt;code&gt;/pattern&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Use &lt;code&gt;n&lt;/code&gt; to jump to the next match.&lt;/li&gt; &lt;li&gt;Use &lt;code&gt;cgn&lt;/code&gt; to change the current match. Type your replacement, then hit &lt;code&gt;&amp;lt;Esc&gt;&lt;/code&gt;.&lt;/li&gt; &lt;li&gt;Use &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;N&lt;/code&gt; to jump to the next or previous match.&lt;/li&gt; &lt;li&gt;Hit &lt;code&gt;.&lt;/code&gt; (dot) to repeat the last change on the next match.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;For example, to replace &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; interactively:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/foo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;cgnbar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;Esc&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;n&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;n &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; skip the previous match and don&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&apos;t change it&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;This lets you skip matches you don’t want to change, and quickly apply the same edit to others. You can also use other operators with &lt;code&gt;gn&lt;/code&gt;, such as &lt;code&gt;dgn&lt;/code&gt; to delete matches, or &lt;code&gt;ygn&lt;/code&gt; to yank them.&lt;/p&gt; &lt;p&gt;What’s great about this approach is that the change becomes repeatable with the dot command, making it much faster than running &lt;code&gt;:substitute&lt;/code&gt; with confirmation for every match.&lt;/p&gt; &lt;h2 id=&quot;searching-and-replacing-text-across-buffers-with-quickfix-list&quot;&gt;&lt;a href=&quot;#searching-and-replacing-text-across-buffers-with-quickfix-list&quot;&gt;Searching and replacing text across buffers with Quickfix list&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Sometimes you need to search and replace text across multiple files or buffers. Neovim makes this possible with the Quickfix list and the powerful &lt;code&gt;:cdo&lt;/code&gt; and &lt;code&gt;:cfdo&lt;/code&gt; commands.&lt;/p&gt; &lt;h3 id=&quot;insert-buffers-into-quickfix-list-with-grep-command&quot;&gt;&lt;a href=&quot;#insert-buffers-into-quickfix-list-with-grep-command&quot;&gt;Insert buffers into Quickfix list with &lt;code&gt;:grep&lt;/code&gt; command&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;One classic way to batch search and replace is to use the built-in &lt;code&gt;:grep&lt;/code&gt; command to populate the Quickfix list. This approach is simple and works out of the box.&lt;/p&gt; &lt;p&gt;To search for &lt;code&gt;foo&lt;/code&gt; in all &lt;code&gt;.js&lt;/code&gt; files and load the results into the Quickfix list:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:grep foo **/*.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:copen&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;This will open the Quickfix window with all matches. You can then use &lt;code&gt;:cdo&lt;/code&gt; to run a substitute command on every matching line:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:cdo s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/gc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Or use &lt;code&gt;:cfdo&lt;/code&gt; to run a command on every buffer in the list:&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;:cfdo %s&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;/foo/&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;bar/gc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Always review the Quickfix list before running these commands to avoid unwanted changes. You can close the Quickfix window with &lt;code&gt;:cclose&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;For more details, see the &lt;a href=&quot;https://neovim.io/doc/user/quickfix.html&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Neovim Quickfix documentation&lt;/a&gt;.&lt;/p&gt; &lt;h3 id=&quot;insert-buffers-into-quickfix-list-with-picker-of-snacksnvim&quot;&gt;&lt;a href=&quot;#insert-buffers-into-quickfix-list-with-picker-of-snacksnvim&quot;&gt;Insert buffers into Quickfix list with picker of &lt;code&gt;snacks.nvim&lt;/code&gt;&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;If you prefer a more interactive workflow, modern Neovim plugins like &lt;a href=&quot;https://github.com/folke/snacks.nvim&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;snacks.nvim&lt;/code&gt;&lt;/a&gt; let you use fuzzy pickers to select files and load them into the Quickfix list. This is my favourite way to batch search and replace, as it gives you full control over which files to operate on.&lt;/p&gt; &lt;p&gt;For example, you can use the grep picker from &lt;code&gt;snacks.nvim&lt;/code&gt; to search for a pattern, select the files you want, and send them to the Quickfix list. Once the list is populated, you can use the same &lt;code&gt;:cdo&lt;/code&gt; or &lt;code&gt;:cfdo&lt;/code&gt; commands as above.&lt;/p&gt; &lt;p&gt;This workflow also works with other pickers like &lt;a href=&quot;https://github.com/nvim-telescope/telescope.nvim&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Telescope&lt;/a&gt; or &lt;a href=&quot;https://github.com/ibhagwan/fzf-lua&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;fzf-lua&lt;/a&gt;. The flexibility to preview and select files before running replacements makes it much safer and more efficient.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>neovim</term><scheme>https://hugosum.com/tag/neovim</scheme><label>Neovim</label></category><summary>In this post I want to share how do I search and replace text efficiently in Neovim.</summary><published>Sat, 30 Aug 2025 00:00:00 GMT</published><updated>Sat, 30 Aug 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/how-to-start-neovim-with-minimal-configuration</id><title>How to start Neovim with minimal configuration</title><link>https://hugosum.com/blog/how-to-start-neovim-with-minimal-configuration</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;In the past, I would install &lt;code&gt;vim&lt;/code&gt; alongside &lt;code&gt;nvim&lt;/code&gt; in my system as a backup, so I have a terminal editor to fix the configuration of Neovim whenever I broke it and some annoying errors are populated through an &lt;code&gt;autocmd&lt;/code&gt; after every keystroke. Since the errors always come from my configuration(&lt;code&gt;init.lua&lt;/code&gt;) or the plugins I installed, I wonder if I could start &lt;code&gt;nvim&lt;/code&gt; without any configuration, then I can use the vanilla Neovim to fix the issue.&lt;/p&gt; &lt;h2 id=&quot;disable-all-configuration-and-plugins-with---clean&quot;&gt;&lt;a href=&quot;#disable-all-configuration-and-plugins-with---clean&quot;&gt;Disable all configuration and plugins with &lt;code&gt;--clean&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Going through the documentation of Neovim, I notice a &lt;code&gt;--clean&lt;/code&gt; option is added in 0.8.0, that would &lt;a href=&quot;https://neovim.io/doc/user/starting.html#--clean&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;prevent loading configuration files and user’s plugins&lt;/a&gt; when starting Neovim. At the same time, built-in plugins for Neovim would be loaded as usual.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nvim&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --clean&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;use-an-alternative-configuration-file-with--u&quot;&gt;&lt;a href=&quot;#use-an-alternative-configuration-file-with--u&quot;&gt;Use an alternative configuration file with &lt;code&gt;-u&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If you do not like to work with a vanilla Neovim, you can also start it with an alternative configuration file with &lt;code&gt;-u&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nvim&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; -u&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;$XDG_CONFIG_HOME&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/nvim/minimal.lua&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I found this much more useful than simply running &lt;code&gt;--clean&lt;/code&gt;, as I can run some essential plugins such as &lt;a href=&quot;https://github.com/nvim-treesitter/nvim-treesitter&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nvim-treesitter&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://github.com/neovim/nvim-lspconfig&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nvim-lspconfig&lt;/code&gt;&lt;/a&gt; in this alternative configuration.&lt;/p&gt; &lt;p&gt;The obvious drawback for this approach is you have to manage another configuration, and you have to make sure it is working.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>neovim</term><scheme>https://hugosum.com/tag/neovim</scheme><label>Neovim</label></category><summary>In this post I will show you how to start Neovim with minimal configuration, so you can fix your Neovim&apos;s configuration with it when it is generating some annoying errors for you.</summary><published>Tue, 18 Mar 2025 00:00:00 GMT</published><updated>Tue, 18 Mar 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/adding-types-to-your-neovim-configuration</id><title>Adding types to your Neovim configuration</title><link>https://hugosum.com/blog/adding-types-to-your-neovim-configuration</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Once again I have started customizing my Neovim’s configuration, so that I can improve my productivity and enjoy every single click on my keyboard at work. After spending hours updating my &lt;code&gt;init.lua&lt;/code&gt; and checked out some plugins I have never heard of, I noticed quite a few plugins now include an annotation comment &lt;code&gt;@type&lt;/code&gt; for typing their configuration’s arguments.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;gray&quot; d=&quot;m16.5 30l-.011-.321c.4-.014.8-.045 1.19-.094l.039.319c-.406.048-.818.08-1.218.096m-1.222-.011c-.4-.021-.814-.061-1.216-.118l.045-.318c.393.055.793.094 1.188.115Zm3.642-.289l-.067-.314c.387-.083.776-.184 1.155-.3l.094.307c-.388.118-.786.222-1.182.307m-6.063-.053q-.599-.137-1.177-.326l.1-.306c.377.122.764.23 1.15.319Zm8.4-.665l-.121-.3c.364-.148.728-.314 1.08-.493h.006l.145.286q-.553.28-1.114.507Zm-10.718-.088a14 14 0 0 1-1.1-.524l.15-.284c.35.186.713.358 1.078.512Zm12.893-1.021l-.17-.273c.337-.21.668-.437.984-.675l.193.257q-.494.367-1.011.691Zm-15.053-.122c-.341-.22-.676-.459-1-.708l.2-.253c.312.243.64.476.972.691Zm17-1.346l-.215-.239q.443-.4.851-.836l.235.219c-.278.297-.571.585-.872.851Zm-18.925-.153c-.3-.276-.585-.569-.856-.87l.239-.215c.265.294.547.58.836.85Zm20.587-1.632l-.253-.2c.244-.312.476-.639.692-.972l.27.175q-.333.516-.709.997M4.82 24.439a14 14 0 0 1-.692-1.007l.272-.17c.21.337.438.668.676.984Zm23.547-1.867l-.284-.151c.186-.35.358-.713.513-1.078l.3.125a15 15 0 0 1-.528 1.104Zm-24.841-.2l-.006-.012a13 13 0 0 1-.5-1.1l.3-.121c.147.362.312.724.491 1.074l.006.012Zm25.794-2.047l-.306-.1c.122-.377.23-.764.319-1.15l.313.072c-.091.396-.2.792-.326 1.178m-26.712-.218c-.12-.388-.223-.786-.308-1.182l.314-.067c.083.387.184.776.3 1.155Zm27.262-2.161l-.318-.045c.056-.393.094-.793.115-1.188l.321.017a14 14 0 0 1-.118 1.216M2.1 17.72c-.05-.4-.082-.812-.1-1.218l.321-.011c.014.4.046.8.094 1.19Zm27.582-2.2c-.014-.4-.045-.8-.093-1.19l.319-.039c.049.4.082.813.1 1.218ZM2.331 15.3l-.321-.02c.021-.405.061-.814.117-1.216l.318.045c-.055.391-.093.791-.114 1.191m27.057-2.144a14 14 0 0 0-.3-1.155l.312-.101c.119.388.223.786.307 1.183Zm-26.725-.222l-.313-.072q.137-.599.326-1.177l.306.1c-.123.376-.23.763-.319 1.149m26.026-2.062a13 13 0 0 0-.5-1.086l.286-.146c.185.363.355.736.507 1.111ZM3.4 10.665l-.3-.125c.158-.374.334-.745.524-1.1l.284.15c-.184.347-.356.71-.508 1.075m1.113-2.108l-.27-.174q.332-.513.707-1l.254.2q-.367.475-.691.974m1.464-1.881l-.235-.219c.276-.3.569-.585.87-.857l.215.239c-.294.261-.58.547-.85.837m1.77-1.6l-.193-.257c.323-.244.662-.477 1.007-.692l.17.272c-.337.215-.668.442-.984.68Zm15.705-.558l-.018-.012l.175-.27l.018.011Zm-1.047-.616a13 13 0 0 0-1.078-.512l.125-.3c.374.158.745.334 1.1.524ZM9.769 3.815l-.146-.286l.018-.009c.356-.181.724-.349 1.093-.5l.121.3c-.361.147-.72.311-1.068.488Zm10.44-.838a13 13 0 0 0-1.151-.317l.072-.313q.6.137 1.178.325Zm-8.229-.06l-.094-.307a14 14 0 0 1 1.182-.308l.067.314a14 14 0 0 0-1.155.301m5.9-.473a14 14 0 0 0-1.188-.113l.016-.321c.405.021.814.059 1.216.115Zm-3.572-.026l-.04-.319c.4-.05.812-.083 1.218-.1l.012.321c-.392.017-.793.049-1.186.098Z&quot;&gt;&lt;/path&gt;&lt;circle cx=&quot;16&quot; cy=&quot;15.998&quot; r=&quot;10.708&quot; fill=&quot;navy&quot;&gt;&lt;/circle&gt;&lt;circle cx=&quot;20.435&quot; cy=&quot;11.562&quot; r=&quot;3.136&quot; fill=&quot;#fff&quot;&gt;&lt;/circle&gt;&lt;circle cx=&quot;26.708&quot; cy=&quot;5.29&quot; r=&quot;3.137&quot; fill=&quot;navy&quot;&gt;&lt;/circle&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M13.1 21.352v-.79H9.629v-6.236h-.9v7.026zm4.816 0V16.3h-.8v2.785c0 1.031-.54 1.706-1.378 1.706A.95.95 0 0 1 14.7 19.8v-3.5h-.8v3.817c0 .838.626 1.378 1.609 1.378a1.86 1.86 0 0 0 1.687-.925v.781h.723m5.872-.018v-.607a.7.7 0 0 1-.173.019c-.279 0-.434-.145-.434-.4v-2.809c0-.9-.655-1.378-1.9-1.378c-1.224 0-1.976.472-2.024 1.638h.81c.067-.617.434-.9 1.185-.9c.723 0 1.128.27 1.128.752v.212c0 .337-.2.482-.838.559a5.8 5.8 0 0 0-1.619.308a1.33 1.33 0 0 0-.887 1.311c0 .916.636 1.455 1.658 1.455a2.36 2.36 0 0 0 1.715-.742a.855.855 0 0 0 .829.665a2 2 0 0 0 .549-.087m-1.407-1.725a1.366 1.366 0 0 1-1.513 1.185c-.626 0-.993-.222-.993-.771c0-.53.357-.761 1.214-.887a4 4 0 0 0 1.291-.279v.752&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;~/.config/nvim/init.lua&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;lazy&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;    spec&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;        &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;folke/snacks.nvim&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;          priority&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 1000&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;          lazy&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;          ---&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;@type&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7;font-style:italic&quot;&gt; snacks.Config&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;          opts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;          &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;        &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;As Lua is a weakly-typed language, just like Javascript, adding type support to it is a non-trivial task. Instead of replacing Lua with a typed superset, for example &lt;a href=&quot;https://github.com/teal-language/tl&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Teal&lt;/a&gt;, using annotations is a much more straight-forward approach, as users do not need to rewrite their code and adapt a building process that compiles codes from a typed variant back to Lua. They only need to set up LSP diagnostics support with the editor to enjoy those typings. I believe that is the right approach for improving Lua, given its relative small community.&lt;/p&gt; &lt;p&gt;Rather than getting type suggestions from &lt;code&gt;lua-language-server&lt;/code&gt; after adding the annotation, I got the following LSP warning.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Undefined type or alias &amp;#96;snacks.Config&amp;#96;. Lua Diagnostics. (undefined-doc-name)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I tried to require &lt;code&gt;snacks&lt;/code&gt; before that type annotation, but &lt;code&gt;lua-language-server&lt;/code&gt; still refused to pick up the type. At the end, I found out that I have to update the configuration of &lt;code&gt;lua-language-server&lt;/code&gt;, so it can analyze all libraries that are imported in a workspace. As I am using &lt;code&gt;lazy.nvim&lt;/code&gt; to manage my plugins, all plugins are installed at &lt;code&gt;$XDG_DATA_HOME/nvim/lazy&lt;/code&gt;, so I just need to add that path to the configuration.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;gray&quot; d=&quot;m16.5 30l-.011-.321c.4-.014.8-.045 1.19-.094l.039.319c-.406.048-.818.08-1.218.096m-1.222-.011c-.4-.021-.814-.061-1.216-.118l.045-.318c.393.055.793.094 1.188.115Zm3.642-.289l-.067-.314c.387-.083.776-.184 1.155-.3l.094.307c-.388.118-.786.222-1.182.307m-6.063-.053q-.599-.137-1.177-.326l.1-.306c.377.122.764.23 1.15.319Zm8.4-.665l-.121-.3c.364-.148.728-.314 1.08-.493h.006l.145.286q-.553.28-1.114.507Zm-10.718-.088a14 14 0 0 1-1.1-.524l.15-.284c.35.186.713.358 1.078.512Zm12.893-1.021l-.17-.273c.337-.21.668-.437.984-.675l.193.257q-.494.367-1.011.691Zm-15.053-.122c-.341-.22-.676-.459-1-.708l.2-.253c.312.243.64.476.972.691Zm17-1.346l-.215-.239q.443-.4.851-.836l.235.219c-.278.297-.571.585-.872.851Zm-18.925-.153c-.3-.276-.585-.569-.856-.87l.239-.215c.265.294.547.58.836.85Zm20.587-1.632l-.253-.2c.244-.312.476-.639.692-.972l.27.175q-.333.516-.709.997M4.82 24.439a14 14 0 0 1-.692-1.007l.272-.17c.21.337.438.668.676.984Zm23.547-1.867l-.284-.151c.186-.35.358-.713.513-1.078l.3.125a15 15 0 0 1-.528 1.104Zm-24.841-.2l-.006-.012a13 13 0 0 1-.5-1.1l.3-.121c.147.362.312.724.491 1.074l.006.012Zm25.794-2.047l-.306-.1c.122-.377.23-.764.319-1.15l.313.072c-.091.396-.2.792-.326 1.178m-26.712-.218c-.12-.388-.223-.786-.308-1.182l.314-.067c.083.387.184.776.3 1.155Zm27.262-2.161l-.318-.045c.056-.393.094-.793.115-1.188l.321.017a14 14 0 0 1-.118 1.216M2.1 17.72c-.05-.4-.082-.812-.1-1.218l.321-.011c.014.4.046.8.094 1.19Zm27.582-2.2c-.014-.4-.045-.8-.093-1.19l.319-.039c.049.4.082.813.1 1.218ZM2.331 15.3l-.321-.02c.021-.405.061-.814.117-1.216l.318.045c-.055.391-.093.791-.114 1.191m27.057-2.144a14 14 0 0 0-.3-1.155l.312-.101c.119.388.223.786.307 1.183Zm-26.725-.222l-.313-.072q.137-.599.326-1.177l.306.1c-.123.376-.23.763-.319 1.149m26.026-2.062a13 13 0 0 0-.5-1.086l.286-.146c.185.363.355.736.507 1.111ZM3.4 10.665l-.3-.125c.158-.374.334-.745.524-1.1l.284.15c-.184.347-.356.71-.508 1.075m1.113-2.108l-.27-.174q.332-.513.707-1l.254.2q-.367.475-.691.974m1.464-1.881l-.235-.219c.276-.3.569-.585.87-.857l.215.239c-.294.261-.58.547-.85.837m1.77-1.6l-.193-.257c.323-.244.662-.477 1.007-.692l.17.272c-.337.215-.668.442-.984.68Zm15.705-.558l-.018-.012l.175-.27l.018.011Zm-1.047-.616a13 13 0 0 0-1.078-.512l.125-.3c.374.158.745.334 1.1.524ZM9.769 3.815l-.146-.286l.018-.009c.356-.181.724-.349 1.093-.5l.121.3c-.361.147-.72.311-1.068.488Zm10.44-.838a13 13 0 0 0-1.151-.317l.072-.313q.6.137 1.178.325Zm-8.229-.06l-.094-.307a14 14 0 0 1 1.182-.308l.067.314a14 14 0 0 0-1.155.301m5.9-.473a14 14 0 0 0-1.188-.113l.016-.321c.405.021.814.059 1.216.115Zm-3.572-.026l-.04-.319c.4-.05.812-.083 1.218-.1l.012.321c-.392.017-.793.049-1.186.098Z&quot;&gt;&lt;/path&gt;&lt;circle cx=&quot;16&quot; cy=&quot;15.998&quot; r=&quot;10.708&quot; fill=&quot;navy&quot;&gt;&lt;/circle&gt;&lt;circle cx=&quot;20.435&quot; cy=&quot;11.562&quot; r=&quot;3.136&quot; fill=&quot;#fff&quot;&gt;&lt;/circle&gt;&lt;circle cx=&quot;26.708&quot; cy=&quot;5.29&quot; r=&quot;3.137&quot; fill=&quot;navy&quot;&gt;&lt;/circle&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M13.1 21.352v-.79H9.629v-6.236h-.9v7.026zm4.816 0V16.3h-.8v2.785c0 1.031-.54 1.706-1.378 1.706A.95.95 0 0 1 14.7 19.8v-3.5h-.8v3.817c0 .838.626 1.378 1.609 1.378a1.86 1.86 0 0 0 1.687-.925v.781h.723m5.872-.018v-.607a.7.7 0 0 1-.173.019c-.279 0-.434-.145-.434-.4v-2.809c0-.9-.655-1.378-1.9-1.378c-1.224 0-1.976.472-2.024 1.638h.81c.067-.617.434-.9 1.185-.9c.723 0 1.128.27 1.128.752v.212c0 .337-.2.482-.838.559a5.8 5.8 0 0 0-1.619.308a1.33 1.33 0 0 0-.887 1.311c0 .916.636 1.455 1.658 1.455a2.36 2.36 0 0 0 1.715-.742a.855.855 0 0 0 .829.665a2 2 0 0 0 .549-.087m-1.407-1.725a1.366 1.366 0 0 1-1.513 1.185c-.626 0-.993-.222-.993-.771c0-.53.357-.761 1.214-.887a4 4 0 0 0 1.291-.279v.752&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;~/.config/nvim/init.lua&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;require&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;lazy&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;    spec&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;        &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;neovim/nvim-lspconfig&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;            version&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1.6.0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;            event&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;BufReadPre&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;BufNewFile&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot; &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;            config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                local&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; lspconfig&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; require&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;lspconfig&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                lspconfig&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.lua_ls.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                    capabilities&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; capabilities&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;                    on_init&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;client&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                        client&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.server_capabilities.semanticTokensProvider &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                        if&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; client&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.workspace_folders &lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                            local&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; path&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; client&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.workspace_folders[&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;].name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                            if&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                                path&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ~=&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; vim&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.fn.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;stdpath&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                                and&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                                    vim&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.loop.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;fs_stat&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ..&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/.luarc.json&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                                    or&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; vim&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.loop.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;fs_stat&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ..&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/.luarc.jsonc&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                                )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                            then&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                                return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                            end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                        end&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                        client&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.config.settings.Lua &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; vim&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;tbl_deep_extend&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                            &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;force&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                            client&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.config.settings.Lua,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                            &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                              runtime&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                                version&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;LuaJIT&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                              &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                              workspace&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                                checkThirdParty&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;                                library&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                                  &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$VIMRUNTIME&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                                  &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$XDG_DATA_HOME/nvim/lazy&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                                  &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$&amp;#123;3rd&amp;#125;/luv/library&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                              &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                            &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                        &amp;#125;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                    end&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;                &amp;#125;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            end&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;        &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;After updating my configuration, the LSP is able to pick up types and give suggestions, even without an explicit type annotation.&lt;/p&gt; &lt;h2 id=&quot;avoid-global-configuration-with-luarcjson&quot;&gt;&lt;a href=&quot;#avoid-global-configuration-with-luarcjson&quot;&gt;Avoid global configuration with &lt;code&gt;.luarc.json&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Configuration for &lt;code&gt;lua-language-server&lt;/code&gt; in &lt;code&gt;init.lua&lt;/code&gt; is global, and it will load and analyze types from &lt;code&gt;$XDG_DATA_HOME/nvim/lazy&lt;/code&gt;, even if your project does not require any module from it, slowing down the LSP server start up time. A better option is to use &lt;code&gt;.luarc.json&lt;/code&gt; to customize &lt;code&gt;lua-language-server&lt;/code&gt;. By creating this configuration file at the root level of your project, only libraries specific to that project will be analyzed.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fbc02d&quot; d=&quot;M4.014 14.976a2.5 2.5 0 0 0 1.567-.518a2.38 2.38 0 0 0 .805-1.358a15.3 15.3 0 0 0 .214-2.944q.012-2.085.075-2.747a5.2 5.2 0 0 1 .418-1.686a3 3 0 0 1 .755-1.018A3.05 3.05 0 0 1 9 4.125A6.8 6.8 0 0 1 10.544 4h.7v1.96h-.387a2.34 2.34 0 0 0-1.723.468a3.4 3.4 0 0 0-.425 2.092a36 36 0 0 1-.137 4.133a4.7 4.7 0 0 1-.768 2.06A4.6 4.6 0 0 1 6.1 16a3.8 3.8 0 0 1 1.992 1.754a8.9 8.9 0 0 1 .618 3.865q0 2.435.05 2.9a1.76 1.76 0 0 0 .504 1.181a2.64 2.64 0 0 0 1.592.337h.387V28h-.7a5.7 5.7 0 0 1-1.773-.2a2.97 2.97 0 0 1-1.324-.93a3.35 3.35 0 0 1-.681-1.63a24 24 0 0 1-.165-3.234a16.5 16.5 0 0 0-.214-3.106a2.4 2.4 0 0 0-.805-1.361a2.5 2.5 0 0 0-1.567-.524Zm23.972 2.035a2.5 2.5 0 0 0-1.567.524a2.4 2.4 0 0 0-.805 1.361a16.5 16.5 0 0 0-.212 3.109a24 24 0 0 1-.169 3.234a3.35 3.35 0 0 1-.681 1.63a2.97 2.97 0 0 1-1.324.93a5.7 5.7 0 0 1-1.773.2h-.7V26.04h.387a2.64 2.64 0 0 0 1.592-.337a1.76 1.76 0 0 0 .506-1.186q.05-.462.05-2.9a8.9 8.9 0 0 1 .618-3.865A3.8 3.8 0 0 1 25.9 16a4.6 4.6 0 0 1-1.7-1.286a4.7 4.7 0 0 1-.768-2.06a36 36 0 0 1-.137-4.133a3.4 3.4 0 0 0-.425-2.092a2.34 2.34 0 0 0-1.723-.468h-.387V4h.7a6.8 6.8 0 0 1 1.54.125a3.05 3.05 0 0 1 1.149.581a3 3 0 0 1 .755 1.018a5.2 5.2 0 0 1 .418 1.686q.062.662.075 2.747a15.3 15.3 0 0 0 .212 2.947a2.38 2.38 0 0 0 .805 1.355a2.5 2.5 0 0 0 1.567.518Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;~/.config/nvim/.luarc.json&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &quot;&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;$schema&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &quot;&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;workspace.library&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$VIMRUNTIME&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$XDG_DATA_HOME/nvim/lazy&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$&amp;#123;3rd&amp;#125;/luv/library&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>lua</term><scheme>https://hugosum.com/tag/lua</scheme><label>Lua</label></category><category><term>neovim</term><scheme>https://hugosum.com/tag/neovim</scheme><label>Neovim</label></category><summary>In this post I will show you how to add types and its related LSP diagnostics to your Neovim configuration, so you can have a better experience customizing it.</summary><published>Mon, 10 Feb 2025 00:00:00 GMT</published><updated>Mon, 10 Feb 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/conditionally-add-values-into-list-or-map-in-nix</id><title>Conditionally add values into list or map in Nix</title><link>https://hugosum.com/blog/conditionally-add-values-into-list-or-map-in-nix</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;I often find myself conditionally adding values into a list or map when writing configurations and derivations in Nix. In this post I want to show you how to conditionally add values into list or map in Nix.&lt;/p&gt; &lt;p&gt;Similar to many other functional languages, all values are immutable, and no statement exists in Nix. Instead of relying on method such as &lt;code&gt;push()&lt;/code&gt; that would mutate an object, you have to use composition to add values into a list or map.&lt;/p&gt; &lt;h2 id=&quot;conditionally-add-values-into-a-list-in-nix&quot;&gt;&lt;a href=&quot;#conditionally-add-values-into-a-list-in-nix&quot;&gt;Conditionally add values into a list in Nix&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To conditionally add values into a list in Nix, we can use the list concatenation operator &lt;code&gt;++&lt;/code&gt; together with a &lt;code&gt;if&lt;/code&gt; expression. Remember &lt;code&gt;if&lt;/code&gt; in Nix is an expression instead of statement, therefore it can &lt;strong&gt;return value&lt;/strong&gt;. The following example shows you how to add &lt;code&gt;c&lt;/code&gt; and &lt;code&gt;d&lt;/code&gt; into the list of &lt;code&gt;foo&lt;/code&gt;, if &lt;code&gt;acceptAdditional&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;example.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;   acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ++&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    (if&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;bar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If we evaluate the above file with &lt;code&gt;nix repl&lt;/code&gt;, we can see that the value of &lt;code&gt;foo&lt;/code&gt; evaluated to the combination of &lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;bar&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;❯&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; repl&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --file&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; example.nix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Welcome&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; to&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; 2.18.1.&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Type&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; :?&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; help.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Loading&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; installable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Added&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; variables.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nix-repl&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&gt; &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;foo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;We can simplify our code with the helper function &lt;a href=&quot;https://ryantm.github.io/nixpkgs/functions/library/lists/#function-library-lib.lists.optional&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;lib.lists.optionals&lt;/code&gt;&lt;/a&gt; for the same effect, where an empty list will be returned, if the condition is not true.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;example.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;   acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ++&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    (if&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; else&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#FF5370&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;lists&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;optionals&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#FF5370&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;c&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#FF5370&quot;&gt; ]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;conditionally-add-values-into-a-map-in-nix&quot;&gt;&lt;a href=&quot;#conditionally-add-values-into-a-map-in-nix&quot;&gt;Conditionally add values into a map in Nix&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To conditionally add values into a map in Nix, we can use the &lt;a href=&quot;https://nix.dev/manual/nix/2.18/language/operators#update&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Update operator &lt;code&gt;//&lt;/code&gt;&lt;/a&gt;. The attributes of the map in the right-hand side of the operator, will be merged into the map in the left-hand side.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;example.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (if&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    one&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    two&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;By evaluating it, we can see that attribute &lt;code&gt;one&lt;/code&gt; and &lt;code&gt;two&lt;/code&gt; is now merged into &lt;code&gt;foo&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;❯&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; repl&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --file&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; example.nix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Welcome&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; to&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; 2.18.1.&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Type&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; :?&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; help.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Loading&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; installable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Added&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; variables.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nix-repl&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&gt; &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;foo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; one&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; two&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If any attribute on the right-hand side’s map is identical with the left-hand side’s map, it will overwrite its value. This is really useful for conditionally setting value of attributes in a map.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;example.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (if&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; then&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    one&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    two&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;new value&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; else&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;As you can see, the value of &lt;code&gt;a&lt;/code&gt; has been overwritten into the value of the same attribute of the right-hand side map.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;❯&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; repl&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --file&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; example.nix&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Welcome&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; to&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Nix&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; 2.18.1.&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Type&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; :?&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; for&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; help.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Loading&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; installable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Added&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; variables.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nix-repl&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&gt; &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;foo&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; a&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;new value&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; one&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; two&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;To simplify our code and avoid writing &lt;code&gt;if&lt;/code&gt; expression, we can use the helper function &lt;a href=&quot;https://ryantm.github.io/nixpkgs/functions/library/attrsets/#function-library-lib.attrsets.optionalAttrs&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;lib.attrsets.optionalAttrs&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;example.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;e&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;attrsets&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;optionalAttrs&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; acceptAdditional&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    one&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    two&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    a&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;new value&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;The limitation for &lt;code&gt;\\&lt;/code&gt; operator is that it &lt;strong&gt;cannot merge recursively&lt;/strong&gt;. If you want a recursive merge, you can use the helper function &lt;a href=&quot;https://ryantm.github.io/nixpkgs/functions/library/attrsets/#function-library-lib.attrsets.recursiveUpdate&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;lib.attrsets.recursiveUpdate&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;h2 id=&quot;practical-use-cases-for-adding-values-conditionally&quot;&gt;&lt;a href=&quot;#practical-use-cases-for-adding-values-conditionally&quot;&gt;Practical use cases for adding values conditionally&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;&lt;a href=&quot;https://wiki.archlinux.org/title/Plymouth&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;plymouth&lt;/code&gt;&lt;/a&gt; is an application that allows you to display a custom splash screen when you boot a Linux machine. To make &lt;code&gt;plymouth&lt;/code&gt; useful and avoid disrupting the splash screen with logs, we have to set &lt;code&gt;quiet&lt;/code&gt; and &lt;code&gt;splash&lt;/code&gt; at &lt;code&gt;boot.kernelParams&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;Instead of setting it directly at &lt;code&gt;boot.kernelParams&lt;/code&gt;, and comment it out when we disable &lt;code&gt;plymouth&lt;/code&gt;, we can use the aforementioned technique, and add those parameters to &lt;code&gt;boot.kernelParams&lt;/code&gt; when &lt;code&gt;config.boot.plymouth.enable&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  boot&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;plymouth&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  boot&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;kernelParams&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    ++&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lists&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;optionals&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;boot&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;plymouth&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;quiet&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;splash&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><summary>In this post I want to show you how to conditionally add values into list or map in Nix.</summary><published>Wed, 05 Feb 2025 00:00:00 GMT</published><updated>Wed, 05 Feb 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/optimize-sveltekit-performance-with-brotli-compression</id><title>Optimize SvelteKit performance with brotli compression</title><link>https://hugosum.com/blog/optimize-sveltekit-performance-with-brotli-compression</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;In my post of &lt;a href=&quot;/blog/dockerize-sveltekit-with-adaptor-static-and-nginx&quot;&gt;building Docker image for static SvelteKit application with &lt;code&gt;nginx&lt;/code&gt;&lt;/a&gt;, I have covered almost everything, except serving &lt;code&gt;brotli&lt;/code&gt; compressed assets. &lt;code&gt;brotli&lt;/code&gt; generally compress files better than traditional &lt;code&gt;gzip&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;Today I want to share how to optimize SvelteKit’s performance with &lt;code&gt;brotli&lt;/code&gt; compression, and serve those pre-compressed assets with &lt;code&gt;nginx&lt;/code&gt;.&lt;/p&gt; &lt;h2 id=&quot;enable-pre-compression-in-sveltekit&quot;&gt;&lt;a href=&quot;#enable-pre-compression-in-sveltekit&quot;&gt;Enable pre-compression in SvelteKit&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;As we are building a static site, we can compress all our assets with &lt;code&gt;brotli&lt;/code&gt; during the build time. To enable pre-compression, you need to set &lt;code&gt;precompress: true&lt;/code&gt; in your adapter.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#F0DB4F&quot; d=&quot;M1.408 1.408h125.184v125.185H1.408z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#323330&quot; d=&quot;M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981c-3.832-1.761-8.104-3.022-9.377-5.926c-.452-1.69-.512-2.642-.226-3.665c.821-3.32 4.784-4.355 7.925-3.403c2.023.678 3.938 2.237 5.093 4.724c5.402-3.498 5.391-3.475 9.163-5.879c-1.381-2.141-2.118-3.129-3.022-4.045c-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235c-5.926 6.724-4.236 18.492 2.975 23.335c7.104 5.332 17.54 6.545 18.873 11.531c1.297 6.104-4.486 8.08-10.234 7.378c-4.236-.881-6.592-3.034-9.139-6.949c-4.688 2.713-4.688 2.713-9.508 5.485c1.143 2.499 2.344 3.63 4.26 5.795c9.068 9.198 31.76 8.746 35.83-5.176c.165-.478 1.261-3.666.38-8.581M69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149c-1.713 3.558-6.152 3.117-8.175 2.427c-2.059-1.012-3.106-2.451-4.319-4.485c-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901c4.462 2.678 10.459 3.499 16.731 2.059c4.082-1.189 7.604-3.652 9.448-7.401c2.666-4.915 2.094-10.864 2.07-17.444c.06-10.735.001-21.468.001-32.237&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;svelte.config.js&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/adapter-static&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;/** &lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;@type&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;import(&apos;@sveltejs/kit&apos;).Config&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;&amp;#125; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    adapter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      precompress&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;enable-brotli-support-in-nginx&quot;&gt;&lt;a href=&quot;#enable-brotli-support-in-nginx&quot;&gt;Enable &lt;code&gt;brotli&lt;/code&gt; support in &lt;code&gt;nginx&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;By default, &lt;code&gt;nginx&lt;/code&gt; does not support &lt;code&gt;brotli&lt;/code&gt; compression, and it won’t serve pre-compressed &lt;code&gt;brotli&lt;/code&gt; assets as well. To enable that, you have to install &lt;a href=&quot;https://github.com/google/ngx_brotli&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ngx_brotli&lt;/code&gt; module&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Luckily there is a &lt;a href=&quot;https://github.com/KiweeEu/nginx-brotli&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Docker image with &lt;code&gt;ngx_brotli&lt;/code&gt; pre-installed&lt;/a&gt;. We are going to modify our &lt;a href=&quot;/blog/dockerize-sveltekit-with-adaptor-static-and-nginx#build-sveltekit-in-docker&quot;&gt;Docker image that build SvelteKit with static adapter and serve with &lt;code&gt;nginx&lt;/code&gt;&lt;/a&gt;, and use that image.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3c1.2-.4 2.6-1 3.8-1.7c-1.6-2.1-2.4-4.7-2.6-7.3c-.3-3.5.4-8.1 2.8-10.8l1.2-1.4l1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4c4.3-1.3 9.3-1 13.1 1.2l1.5.9l-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8c-9.8 24.3-31 35.8-56.8 35.8c-13.3 0-25.5-5-32.5-16.8l-.1-.2l-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6V50.8h11.3V39.6h22.5V28.3h13.5z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00AADA&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7H18.6c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5 1.1-8.3 1.3h-.6c-1.3.1-2.7.1-4.2.1c-1.6 0-3.1 0-4.9-.1c6 6.8 15.4 10.8 27.2 10.8c25 0 46.2-11.1 55.5-35.9c6.7.7 13.1-1 16-6.7c-4.5-2.7-10.5-1.8-13.9-.1&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#28B8EB&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1c15.8-6.1 30.6-17.7 40.9-30.9c-.2.1-.4.1-.5.2&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#028BB8&quot; d=&quot;M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1c-1.6 0-3.2 0-4.9-.1c6 6.8 15.5 10.8 27.3 10.8c21.4 0 40-8.1 50.8-26H18.7z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#019BC6&quot; d=&quot;M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.6 1.4c8.5 4.4 20.8 4.3 34.9-1.1c8.5-3.3 16.8-8.2 24.2-14.1z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M28.4 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3-12h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M39.6 52.7h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 41.5h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3.1 10.4H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 41.5H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 30.2H72V40h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.5 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7s-1.2 2.7-2.7 2.7s-2.7-1.2-2.7-2.7s1.2-2.7 2.7-2.7&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 79.1c.2 0 .5 0 .7.1c-.2.1-.4.4-.4.7c0 .4.4.8.8.8c.3 0 .6-.2.7-.4c.1.2.1.5.1.7c0 1.1-.9 1.9-1.9 1.9c-1.1 0-1.9-.9-1.9-1.9s.8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2c-5 5.7-16.9 4-20 1.2c-3.4 4.9-23 3-24.3-.8c-4.2 5-17.3 5-21.5 0c-1.4 3.8-21 5.7-24.3.8c-3 2.8-15 4.5-20-1.2c1.1 3.5-4.9 4.5-7.6 5.2&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#BFDBE0&quot; d=&quot;M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2c-2.5.7-5.5 1.2-8.9 1.4c-1.3.1-2.7.1-4.1.1c-1.7 0-3.4 0-5.2-.1c6 6 13.6 10.7 27.5 10.8z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; d=&quot;M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3c-2.5.7-5.5 1.2-8.9 1.4c2.3 1.2 5.7 2.4 11.4 2.9&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;Dockerfile&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; base &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; prerelease&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; --from=install /temp/dev/node_modules node_modules&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; . .&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; NODE_ENV=production&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; npm run build&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# the nginx Docker image with brotli modules installed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; KiweeEu/nginx-brotli &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; release&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; --from=prerelease --chown=nginx:nginx /usr/src/app/build /usr/share/nginx/html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; nginx.conf /etc/nginx/conf.d/default.conf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;EXPOSE&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; 8080&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;CMD&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;nginx&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;-g&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;daemon off;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And finally we just need to allow &lt;code&gt;nginx&lt;/code&gt; to serve &lt;code&gt;brotli&lt;/code&gt; compressed content, by modifying &lt;code&gt;nginx.conf&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# load the ngx_brotli module&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;load_module &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;modules/ngx_http_brotli_filter_module.so&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;load_module &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;modules/ngx_http_brotli_static_module.so&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # some usual nginx config&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    listen &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;8080&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    listen &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;[::]:8080&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    root &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/usr/share/nginx/html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    server_name &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    try_files &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.html &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;=404&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    brotli_static&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; on&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # allow serving brotli compressed files &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>docker</term><scheme>https://hugosum.com/tag/docker</scheme><label>Docker</label></category><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><category><term>svelte</term><scheme>https://hugosum.com/tag/svelte</scheme><label>Svelte</label></category><category><term>nginx</term><scheme>https://hugosum.com/tag/nginx</scheme><label>Nginx</label></category><summary>In this post I will show you how to optimize the performance of a SvelteKit project by using brotli compression and serve those assets.</summary><published>Sun, 02 Feb 2025 00:00:00 GMT</published><updated>Sun, 02 Feb 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/using-glob-on-cli-that-does-not-support-variadic-arguments</id><title>Using glob on CLI that does not support variadic arguments</title><link>https://hugosum.com/blog/using-glob-on-cli-that-does-not-support-variadic-arguments</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Recently I need to use &lt;a href=&quot;https://github.com/getsops/sops&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;sops&lt;/code&gt;&lt;/a&gt; to encrypt and decrypt a set of secret files for deploying Kubernetes workload using the GitOps approach. All of these files has an extension of &lt;code&gt;sops&lt;/code&gt;, for example &lt;code&gt;secret.sops.yaml&lt;/code&gt;. For a simple task like this, I was expecting everything can be done in a single line using glob.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;sops&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --encrypt&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt; **&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;.sops.&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # encrypt all files with a sub extension of sops&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Unfortunately, &lt;code&gt;sops&lt;/code&gt; cannot handle variadic arguments. Only the first argument is handled, and the rest are simply ignored. As a glob will be expanded by the shell into a space separated string, and array in shell can be created based on a space separated string as well, I wonder if I can turn a glob into an array, and then iterate all its items in a loop.&lt;/p&gt; &lt;p&gt;I started off by verifying that I can build an array from glob, using a really simple example.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;touch&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; foo.md&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; bar.md&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;.md&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;$&amp;#123;#&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;arr&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&quot;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # getting the length of the array, and it prints 2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And then, I tried to run a &lt;code&gt;for&lt;/code&gt; loop on this array, and it worked.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; file&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; $list&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;[@&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; echo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; done&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # foo.md bar.md&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I thought I have reached an optimal solution already, until I found out that you can use &lt;code&gt;for&lt;/code&gt; loop without an array! We can use glob directly on a &lt;code&gt;for&lt;/code&gt; loop, and everything is nice and clean.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; file&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; *.md&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; do&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; echo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;$file&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; done&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # foo.md bar.md&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;allowing-glob-to-fail-gracefully&quot;&gt;&lt;a href=&quot;#allowing-glob-to-fail-gracefully&quot;&gt;Allowing glob to fail gracefully&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Everything seems to be working so far. I have then implemented my script in the actual project, and found out that my script will break when the glob pattern cannot match anything. I thought it would be expanded to an empty string, yet it exited right away.&lt;/p&gt; &lt;p&gt;After searching for a while, I found that you could set &lt;code&gt;shopt -s nullglob&lt;/code&gt; in bash and zsh and prevent an unmatched glob from exiting.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>bash</term><scheme>https://hugosum.com/tag/bash</scheme><label>bash</label></category><category><term>zsh</term><scheme>https://hugosum.com/tag/zsh</scheme><label>zsh</label></category><summary>In this post I will show you how to use glob on CLI that does not support variadic arugments.</summary><published>Fri, 31 Jan 2025 00:00:00 GMT</published><updated>Fri, 31 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/end-to-end-type-safety-with-svelte5-and-sveltekit2</id><title>End-to-end type safety with Svelte 5 and SvelteKit 2</title><link>https://hugosum.com/blog/end-to-end-type-safety-with-svelte5-and-sveltekit2</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Back in Svelte 4 and SvelteKit 1, you can use &lt;code&gt;PageData&lt;/code&gt; and &lt;code&gt;LayoutData&lt;/code&gt; to annotate the type of data passed from a load function in &lt;code&gt;+page.svelte&lt;/code&gt; and &lt;code&gt;+layout.svelte&lt;/code&gt; respectively to achieve end-to-end type safety. These two types are generated by SvelteKit based on the value returned by the load function.&lt;/p&gt; &lt;p&gt;For example, assuming we fetch data from an API in a load function as the following.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+page.server.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;PageServerLoad&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./$types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; load&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageServerLoad&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; params&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; route&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; parent&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; cat&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; dog&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; getAnimals&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;// cat has type Cat, dog has type Dog&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;        cat&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; cat&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;        dog&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; dog&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;You can then import &lt;code&gt;PageData&lt;/code&gt; to annotate the &lt;code&gt;data&lt;/code&gt; props in your component.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#ff3e00&quot; d=&quot;M110.43 16.936C98.553-.076 75.09-5.118 58.13 5.696l-29.792 19a34.2 34.2 0 0 0-15.48 22.897a25.478 30.64 0 0 0-.572 6.396a36.15 36.15 0 0 0 4.163 16.73A34.4 34.4 0 0 0 11.34 83.5a25.348 30.483 0 0 0 .345 14.412a36.5 36.5 0 0 0 5.9 13.152c11.878 17.01 35.394 22.053 52.3 11.24l29.762-19.001a34.13 34.13 0 0 0 15.438-22.918a35.5 35.5 0 0 0 .572-6.386a36.2 36.2 0 0 0-4.112-16.71a34.4 34.4 0 0 0 5.112-12.77c.369-2.11.557-4.245.562-6.386a36.4 36.4 0 0 0-6.787-21.178z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M55.219 112.662a28.463 34.23 0 0 1-5.954.76a23.64 23.64 0 0 1-19.435-10.187a21.9 21.9 0 0 1-4.08-12.74a15.658 18.83 0 0 1 .333-3.833a15.425 18.55 0 0 1 .72-2.782l.561-1.708l1.52 1.156a38.7 38.7 0 0 0 11.658 5.834l1.104.333l-.104 1.104v.573a6.63 6.63 0 0 0 1.228 3.854a7.1 7.1 0 0 0 2.538 2.288a8.262 9.936 0 0 0 3.312.837a8.251 9.923 0 0 0 1.79-.229a7.272 8.745 0 0 0 1.833-.802l29.76-19.094a6.26 6.26 0 0 0 2.904-5.302a6.62 6.62 0 0 0-1.26-3.844a7.14 7.14 0 0 0-2.553-2.252a8.313 9.997 0 0 0-3.307-.81a8.246 9.917 0 0 0-1.79.23a6.938 8.344 0 0 0-1.822.801l-11.346 7.25a24.376 29.314 0 0 1-6.048 2.656a23.64 23.64 0 0 1-25.39-9.416a21.94 21.94 0 0 1-4.08-12.74c.002-1.285.114-2.567.333-3.833a20.65 20.65 0 0 1 9.286-13.781l29.792-18.99a21.9 21.9 0 0 1 6.048-2.667a24 24 0 0 1 5.954-.75A23.68 23.68 0 0 1 98.22 24.745a21.94 21.94 0 0 1 4.029 12.75a15.748 18.939 0 0 1-.334 3.844a15.407 18.529 0 0 1-.718 2.781l-.562 1.708l-1.52-1.114a38.4 38.4 0 0 0-11.658-5.834l-1.104-.343l.104-1.105v-.572a6.7 6.7 0 0 0-1.228-3.865a7.1 7.1 0 0 0-2.55-2.25a8.309 9.992 0 0 0-3.3-.813a8.221 9.887 0 0 0-1.77.271a6.819 8.2 0 0 0-1.831.802l-29.793 18.99a5.88 7.071 0 0 0-1.836 1.79a4.75 5.713 0 0 0-.963 2.377a5.037 6.057 0 0 0-.136 1.104a6.62 6.62 0 0 0 1.228 3.844a7.1 7.1 0 0 0 2.549 2.25a8.299 9.98 0 0 0 3.301.812a8.247 9.918 0 0 0 1.79-.23a6.943 8.35 0 0 0 1.833-.801l11.367-7.292a24.218 29.125 0 0 1 6.048-2.656a28.526 34.305 0 0 1 5.954-.76A23.66 23.66 0 0 1 96.566 60.61a21.94 21.94 0 0 1 3.737 16.614a20.6 20.6 0 0 1-9.286 13.781l-29.74 18.99a24.308 29.233 0 0 1-6.057 2.667z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+page.svelte&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;	import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;PageData&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./$types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;	export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageData&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; // the type here will be &amp;#123; cat: Cat, dog: Dog &amp;#125; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;type-safety-with-props-rune-in-svelte-5&quot;&gt;&lt;a href=&quot;#type-safety-with-props-rune-in-svelte-5&quot;&gt;Type safety with &lt;code&gt;$props()&lt;/code&gt; rune in Svelte 5&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;In Svelte 5, with the introduction of &lt;code&gt;$props()&lt;/code&gt; rune, every Svelte component only accepts a single object as its props. Since the type of &lt;code&gt;$props()&lt;/code&gt; returns &lt;code&gt;any&lt;/code&gt; by default, and does not accept type parameters, you have to add a type annotation to the variable to achieve type safety.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#ff3e00&quot; d=&quot;M110.43 16.936C98.553-.076 75.09-5.118 58.13 5.696l-29.792 19a34.2 34.2 0 0 0-15.48 22.897a25.478 30.64 0 0 0-.572 6.396a36.15 36.15 0 0 0 4.163 16.73A34.4 34.4 0 0 0 11.34 83.5a25.348 30.483 0 0 0 .345 14.412a36.5 36.5 0 0 0 5.9 13.152c11.878 17.01 35.394 22.053 52.3 11.24l29.762-19.001a34.13 34.13 0 0 0 15.438-22.918a35.5 35.5 0 0 0 .572-6.386a36.2 36.2 0 0 0-4.112-16.71a34.4 34.4 0 0 0 5.112-12.77c.369-2.11.557-4.245.562-6.386a36.4 36.4 0 0 0-6.787-21.178z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M55.219 112.662a28.463 34.23 0 0 1-5.954.76a23.64 23.64 0 0 1-19.435-10.187a21.9 21.9 0 0 1-4.08-12.74a15.658 18.83 0 0 1 .333-3.833a15.425 18.55 0 0 1 .72-2.782l.561-1.708l1.52 1.156a38.7 38.7 0 0 0 11.658 5.834l1.104.333l-.104 1.104v.573a6.63 6.63 0 0 0 1.228 3.854a7.1 7.1 0 0 0 2.538 2.288a8.262 9.936 0 0 0 3.312.837a8.251 9.923 0 0 0 1.79-.229a7.272 8.745 0 0 0 1.833-.802l29.76-19.094a6.26 6.26 0 0 0 2.904-5.302a6.62 6.62 0 0 0-1.26-3.844a7.14 7.14 0 0 0-2.553-2.252a8.313 9.997 0 0 0-3.307-.81a8.246 9.917 0 0 0-1.79.23a6.938 8.344 0 0 0-1.822.801l-11.346 7.25a24.376 29.314 0 0 1-6.048 2.656a23.64 23.64 0 0 1-25.39-9.416a21.94 21.94 0 0 1-4.08-12.74c.002-1.285.114-2.567.333-3.833a20.65 20.65 0 0 1 9.286-13.781l29.792-18.99a21.9 21.9 0 0 1 6.048-2.667a24 24 0 0 1 5.954-.75A23.68 23.68 0 0 1 98.22 24.745a21.94 21.94 0 0 1 4.029 12.75a15.748 18.939 0 0 1-.334 3.844a15.407 18.529 0 0 1-.718 2.781l-.562 1.708l-1.52-1.114a38.4 38.4 0 0 0-11.658-5.834l-1.104-.343l.104-1.105v-.572a6.7 6.7 0 0 0-1.228-3.865a7.1 7.1 0 0 0-2.55-2.25a8.309 9.992 0 0 0-3.3-.813a8.221 9.887 0 0 0-1.77.271a6.819 8.2 0 0 0-1.831.802l-29.793 18.99a5.88 7.071 0 0 0-1.836 1.79a4.75 5.713 0 0 0-.963 2.377a5.037 6.057 0 0 0-.136 1.104a6.62 6.62 0 0 0 1.228 3.844a7.1 7.1 0 0 0 2.549 2.25a8.299 9.98 0 0 0 3.301.812a8.247 9.918 0 0 0 1.79-.23a6.943 8.35 0 0 0 1.833-.801l11.367-7.292a24.218 29.125 0 0 1 6.048-2.656a28.526 34.305 0 0 1 5.954-.76A23.66 23.66 0 0 1 96.566 60.61a21.94 21.94 0 0 1 3.737 16.614a20.6 20.6 0 0 1-9.286 13.781l-29.74 18.99a24.308 29.233 0 0 1-6.057 2.667z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+page.svelte&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;    import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;PageData&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./$types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;    export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageData&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#73DACA&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageData &lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;simplify-type-annotation-with-pageprops&quot;&gt;&lt;a href=&quot;#simplify-type-annotation-with-pageprops&quot;&gt;Simplify type annotation with &lt;code&gt;PageProps&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;With the release of &lt;a href=&quot;https://github.com/sveltejs/kit/releases/tag/%40sveltejs%2Fkit%402.16.0&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;SvelteKit 2.16.0&lt;/a&gt;, new types &lt;code&gt;PageProps&lt;/code&gt; and &lt;code&gt;LayoutProps&lt;/code&gt; are introduced to simplify the type annotation for props in &lt;code&gt;+page.svelte&lt;/code&gt; and &lt;code&gt;+layout.svelte&lt;/code&gt; respectively.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#ff3e00&quot; d=&quot;M110.43 16.936C98.553-.076 75.09-5.118 58.13 5.696l-29.792 19a34.2 34.2 0 0 0-15.48 22.897a25.478 30.64 0 0 0-.572 6.396a36.15 36.15 0 0 0 4.163 16.73A34.4 34.4 0 0 0 11.34 83.5a25.348 30.483 0 0 0 .345 14.412a36.5 36.5 0 0 0 5.9 13.152c11.878 17.01 35.394 22.053 52.3 11.24l29.762-19.001a34.13 34.13 0 0 0 15.438-22.918a35.5 35.5 0 0 0 .572-6.386a36.2 36.2 0 0 0-4.112-16.71a34.4 34.4 0 0 0 5.112-12.77c.369-2.11.557-4.245.562-6.386a36.4 36.4 0 0 0-6.787-21.178z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M55.219 112.662a28.463 34.23 0 0 1-5.954.76a23.64 23.64 0 0 1-19.435-10.187a21.9 21.9 0 0 1-4.08-12.74a15.658 18.83 0 0 1 .333-3.833a15.425 18.55 0 0 1 .72-2.782l.561-1.708l1.52 1.156a38.7 38.7 0 0 0 11.658 5.834l1.104.333l-.104 1.104v.573a6.63 6.63 0 0 0 1.228 3.854a7.1 7.1 0 0 0 2.538 2.288a8.262 9.936 0 0 0 3.312.837a8.251 9.923 0 0 0 1.79-.229a7.272 8.745 0 0 0 1.833-.802l29.76-19.094a6.26 6.26 0 0 0 2.904-5.302a6.62 6.62 0 0 0-1.26-3.844a7.14 7.14 0 0 0-2.553-2.252a8.313 9.997 0 0 0-3.307-.81a8.246 9.917 0 0 0-1.79.23a6.938 8.344 0 0 0-1.822.801l-11.346 7.25a24.376 29.314 0 0 1-6.048 2.656a23.64 23.64 0 0 1-25.39-9.416a21.94 21.94 0 0 1-4.08-12.74c.002-1.285.114-2.567.333-3.833a20.65 20.65 0 0 1 9.286-13.781l29.792-18.99a21.9 21.9 0 0 1 6.048-2.667a24 24 0 0 1 5.954-.75A23.68 23.68 0 0 1 98.22 24.745a21.94 21.94 0 0 1 4.029 12.75a15.748 18.939 0 0 1-.334 3.844a15.407 18.529 0 0 1-.718 2.781l-.562 1.708l-1.52-1.114a38.4 38.4 0 0 0-11.658-5.834l-1.104-.343l.104-1.105v-.572a6.7 6.7 0 0 0-1.228-3.865a7.1 7.1 0 0 0-2.55-2.25a8.309 9.992 0 0 0-3.3-.813a8.221 9.887 0 0 0-1.77.271a6.819 8.2 0 0 0-1.831.802l-29.793 18.99a5.88 7.071 0 0 0-1.836 1.79a4.75 5.713 0 0 0-.963 2.377a5.037 6.057 0 0 0-.136 1.104a6.62 6.62 0 0 0 1.228 3.844a7.1 7.1 0 0 0 2.549 2.25a8.299 9.98 0 0 0 3.301.812a8.247 9.918 0 0 0 1.79-.23a6.943 8.35 0 0 0 1.833-.801l11.367-7.292a24.218 29.125 0 0 1 6.048-2.656a28.526 34.305 0 0 1 5.954-.76A23.66 23.66 0 0 1 96.566 60.61a21.94 21.94 0 0 1 3.737 16.614a20.6 20.6 0 0 1-9.286 13.781l-29.74 18.99a24.308 29.233 0 0 1-6.057 2.667z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+page.svelte&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;    import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;PageData&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./$types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;    import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;PageProps&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./$types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; lang&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;ts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#73DACA&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageData &lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageProps &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;props&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Under the hood, &lt;code&gt;PageProps&lt;/code&gt; and &lt;code&gt;LayoutProps&lt;/code&gt; reuse &lt;code&gt;PageData&lt;/code&gt; and &lt;code&gt;LayoutData&lt;/code&gt; in their definition, nothing too special there.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageProps&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#73DACA&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; PageData&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#73DACA&quot;&gt; form&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; ActionData&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>svelte</term><scheme>https://hugosum.com/tag/svelte</scheme><label>Svelte</label></category><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><summary>I will show you how to migrate from Svelte 4 and SvelteKit 1 and achieve end-to-end type safety with Svelte 5 and SvelteKit 2.</summary><published>Mon, 27 Jan 2025 00:00:00 GMT</published><updated>Mon, 27 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/recreating-development-environment-with-nix-flake</id><title>Recreating development environment with Nix Flake</title><link>https://hugosum.com/blog/recreating-development-environment-with-nix-flake</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;In this post, I will show you how to define and recreate development environment of your projects anywhere using Nix Flake.&lt;/p&gt; &lt;h2 id=&quot;create-your-development-environment-with-nix-develop&quot;&gt;&lt;a href=&quot;#create-your-development-environment-with-nix-develop&quot;&gt;Create your development environment with &lt;code&gt;nix develop&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;You can define the development environment of your project in Nix Flake under &lt;code&gt;devShells&lt;/code&gt; with &lt;code&gt;pkgs.mkShell&lt;/code&gt;, and a shell based on that environment can be created with &lt;code&gt;nix develop .#&amp;lt;environment-name&gt;&lt;/code&gt;. For the packages you want to include in this environment, you can define them in &lt;code&gt;nativeBuildInputs&lt;/code&gt;, and they will be loaded through the &lt;code&gt;PATH&lt;/code&gt; in the shell automatically.&lt;/p&gt; &lt;p&gt;The following example is a flake that install &lt;code&gt;kustomize&lt;/code&gt; in &lt;code&gt;devShells.default&lt;/code&gt;. &lt;a href=&quot;https://github.com/hercules-ci/flake-parts&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;flake-parts&lt;/code&gt;&lt;/a&gt; is used to simplify configuration, so you can define &lt;code&gt;devShells.&amp;lt;name&gt;&lt;/code&gt; instead of &lt;code&gt;devShells.&amp;lt;system&gt;.&amp;lt;name&gt;&lt;/code&gt; for each system.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nixos/nixpkgs/nixos-24.11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:hercules-ci/flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;mkFlake&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; inherit&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      systems&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      perSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            inherit&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            config&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;allowUnfree&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            overlays&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          devShells&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;mkShell&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            nativeBuildInputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;              kustomize&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If you want to define environment variables in this environment or trigger some actions when entering it, for example start a database process in background, you can define those commands in &lt;code&gt;shellHook&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nixos/nixpkgs/nixos-24.11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:hercules-ci/flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;mkFlake&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; inherit&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      systems&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;x86_64-linux&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      perSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            inherit&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            config&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;allowUnfree&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            overlays&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          devShells&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;mkShell&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            nativeBuildInputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;              kustomize&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            ];&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            shellHook&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              set -a;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              export FOO=&quot;bar&quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              set +a;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            &apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;You might have also seen snippets of &lt;code&gt;pkgs.mkShell&lt;/code&gt; that defines what packages to use through &lt;code&gt;buildInputs&lt;/code&gt; or &lt;code&gt;packages&lt;/code&gt;. &lt;code&gt;buildInputs&lt;/code&gt; is interchangeable with &lt;code&gt;nativeBuildInputs&lt;/code&gt;, unless you are cross compiling, as packages defined in it are for the &lt;strong&gt;foreign platform&lt;/strong&gt; that your compilation is targeting, and packages defined in &lt;code&gt;nativeBuildInputs&lt;/code&gt; are for the &lt;strong&gt;native platform&lt;/strong&gt; where the compilation will happen. &lt;code&gt;packages&lt;/code&gt; is just an alias argument for &lt;code&gt;nativeBuildInputs&lt;/code&gt;, as it will &lt;a href=&quot;https://github.com/NixOS/nixpkgs/blob/0530d6bd0498e6f554cc9070a163ac9aec5819c8/pkgs/build-support/mkshell/default.nix#L41&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;be merged with the &lt;code&gt;nativeBuildInputs&lt;/code&gt;&lt;/a&gt; at the end.&lt;/p&gt; &lt;p&gt;Under the hood, &lt;code&gt;pkgs.mkShell&lt;/code&gt; creates a &lt;a href=&quot;https://github.com/NixOS/nixpkgs/blob/0530d6bd0498e6f554cc9070a163ac9aec5819c8/pkgs/build-support/mkshell/default.nix#L48&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;derivation that only has a &lt;code&gt;build&lt;/code&gt; phrase&lt;/a&gt;, which does not do anything on its own, and it is meant to be used only with the old &lt;code&gt;nix-shell&lt;/code&gt; command, that is wrapped by &lt;code&gt;nix develop&lt;/code&gt;.&lt;/p&gt;  &lt;h2 id=&quot;automate-environment-creation-with-direnv&quot;&gt;&lt;a href=&quot;#automate-environment-creation-with-direnv&quot;&gt;Automate environment creation with &lt;code&gt;direnv&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Instead of running &lt;code&gt;nix develop&lt;/code&gt; manually every time, what if there is a tool that can automate it for you, whenever you navigate into that project? &lt;a href=&quot;https://direnv.net/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;direnv&lt;/code&gt;&lt;/a&gt; is a tool that does exactly that. With its Nix Flake integration, &lt;a href=&quot;https://github.com/nix-community/nix-direnv&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nix-direnv&lt;/code&gt;&lt;/a&gt;, it would call &lt;code&gt;nix develop&lt;/code&gt; for you when you &lt;code&gt;cd&lt;/code&gt; into a project, and the &lt;code&gt;PATH&lt;/code&gt; and environment variables in your current shell will be updated temporarily, until you navigate away from that project. This is a small but important improvement for me, as I don’t have to use a bare-boned &lt;code&gt;bash&lt;/code&gt; shell and I can continue to enjoy the custom prompt and key bindings in my current shell profile.&lt;/p&gt; &lt;p&gt;There are a &lt;a href=&quot;https://github.com/nix-community/nix-direnv?tab=readme-ov-file#installation&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;few ways to install&lt;/a&gt; &lt;code&gt;nix-direnv&lt;/code&gt; in your system. Assuming you are using Home Manager and you are using &lt;code&gt;zsh&lt;/code&gt; as your shell, you would create a module as the following. Similar configuration exists for &lt;code&gt;bash&lt;/code&gt; and &lt;code&gt;fish&lt;/code&gt; as well.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;direnv.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; isDarwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;zsh&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;direnv&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;direnv&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enableZshIntegration&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;direnv&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nix-direnv&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Then in the project you want to enable &lt;code&gt;nix-direnv&lt;/code&gt; support, you need to create a file called &lt;code&gt;.envrc&lt;/code&gt; with &lt;code&gt;use flake&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;.envrc&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; flake&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Instead of the default &lt;code&gt;devShells&lt;/code&gt;, you can define and run a specific &lt;code&gt;devShells&lt;/code&gt;. In the following example, we instruct &lt;code&gt;direnv&lt;/code&gt; to run &lt;code&gt;devShells.&amp;lt;system&gt;.ci&lt;/code&gt; automatically for us.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;.envrc&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; flake&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; .#ci&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Finally, you will need to run &lt;code&gt;direnv allow&lt;/code&gt; once at the project level to allow &lt;code&gt;direnv&lt;/code&gt; to do its magic. The next time you navigate into this project, your development environment will be recreated automatically by &lt;code&gt;direnv&lt;/code&gt;.&lt;/p&gt; &lt;h2 id=&quot;reproduce-your-development-environment-anywhere-with-docker&quot;&gt;&lt;a href=&quot;#reproduce-your-development-environment-anywhere-with-docker&quot;&gt;Reproduce your development environment anywhere with Docker&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Since our development environment is defined in Nix Flake, we can reproduce our environment on any machine with Nix Flake support, including a Docker image. The Nix community provides a &lt;a href=&quot;https://github.com/nix-community/docker-nixpkgs/pkgs/container/docker-nixpkgs%2Fnix-flakes&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Docker image for running Nix Flake&lt;/a&gt;, and we can recreate our project environment and execute commands in it.&lt;/p&gt; &lt;p&gt;I found it very useful to bring my environment from Nix Flake into a CI/CD pipeline through Docker. Not only the version of packages I get are identical with what I have locally, but also I don’t need to define the installation process for each of them again. Everything is controlled in the Nix Flake.&lt;/p&gt; &lt;p&gt;Since we cannot interact with a shell started by &lt;code&gt;nix develop&lt;/code&gt; in a pipeline, we have to pass the command and arguments that we want to execute to &lt;code&gt;nix develop&lt;/code&gt; as &lt;code&gt;nix develop -c &amp;lt;command&gt; [...args]&lt;/code&gt;. The following example is a task for Tekton pipeline that executes &lt;code&gt;kustomize build --enable-helm ./final&lt;/code&gt; in an environment created by &lt;code&gt;nix develop&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#99b8c4&quot; d=&quot;m23.265 24.381l.9-.894c4.164.136 4.228-.01 4.411-.438l1.144-2.785l.085-.264l-.093-.231c-.049-.122-.2-.486-2.8-2.965V15.5c3-2.89 2.936-3.038 2.765-3.461l-1.139-2.814c-.171-.422-.236-.587-4.37-.474l-.9-.93a20 20 0 0 0-.141-4.106l-.116-.263l-2.974-1.3c-.438-.2-.592-.272-3.4 2.786l-1.262-.019c-2.891-3.086-3.028-3.03-3.461-2.855L9.149 3.182c-.433.175-.586.237-.418 4.437l-.893.89c-4.162-.136-4.226.012-4.407.438l-1.146 2.786l-.09.267l.094.232c.049.12.194.48 2.8 2.962v1.3c-3 2.89-2.935 3.038-2.763 3.462l1.138 2.817c.174.431.236.584 4.369.476l.9.935a20.2 20.2 0 0 0 .137 4.1l.116.265l2.993 1.308c.435.182.586.247 3.386-2.8l1.262.016c2.895 3.09 3.043 3.03 3.466 2.859l2.759-1.115c.436-.173.588-.234.413-4.436m-11.858-6.524a4.957 4.957 0 1 1 6.488 2.824a5.014 5.014 0 0 1-6.488-2.824&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;pipeline.yaml&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;---&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;apiVersion&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; tekton.dev/v1beta1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;kind&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; Task&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;metadata&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;  name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; generate-manifest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;spec&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;  steps&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt; image&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; docker.io/nixpkgs/nix-flakes:nixos-24.11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;    name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; generate-manifest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;    script&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;      nix develop -c kustomize build --enable-helm ./final;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><summary>In this post, I will show you how to define and recreate development environment of your projects anywhere using Nix Flake</summary><published>Thu, 23 Jan 2025 00:00:00 GMT</published><updated>Thu, 23 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/analyze-and-optimize-your-vite-bundle</id><title>Analyze and optimize your Vite bundle</title><link>https://hugosum.com/blog/analyze-and-optimize-your-vite-bundle</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;It is important to analyze your bundle generated by Vite from time to time, as often there will be some low-hanging opportunities to reduce its size. In this post I will show you how to analyze and optimize your Vite bundle by removing duplicate code and packages.&lt;/p&gt; &lt;h2 id=&quot;analyze-your-vite-bundle&quot;&gt;&lt;a href=&quot;#analyze-your-vite-bundle&quot;&gt;Analyze your Vite bundle&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;I have been using &lt;a href=&quot;https://www.npmjs.com/package/vite-bundle-visualizer&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;vite-bundle-visualizer&lt;/code&gt;&lt;/a&gt; in the past. It does what it says in the box and visualize my bundle, but I still have to spend time on examining charts and figure out what issues does my bundle contain.&lt;/p&gt; &lt;p&gt;I think &lt;a href=&quot;https://www.npmjs.com/package/rollup-plugin-bundle-stats&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;rollup-plugin-bundle-stats&lt;/code&gt;&lt;/a&gt; addressed my pain point here, and it is a superior option to analyze your Vite bundle. It gives me a clear pointer on duplicate code and packages, so I can address them easily. As Vite uses Rollup for bundling, we can use this plugin with Vite as well. You can install this package with whatever package manager you want.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;npm&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; i&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; rollup-plugin-bundle-stats&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; -D&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;After installing this package, you need to add this plugin to your Vite configuration. Even though all options for this plugin is optional, it cannot find the &lt;code&gt;baseline.json&lt;/code&gt; in my SvelteKit project out of the box, and I have to set the path manually at &lt;code&gt;baselineFilePath&lt;/code&gt;. I have also set &lt;code&gt;silent: true&lt;/code&gt; to reduce the log output from this plugin.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;vite.config.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;defineConfig&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;vite&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;bundleStats&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;rollup-plugin-bundle-stats&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;fileURLToPath&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;node:url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;dirname&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; join&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;node:path&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; currentDir&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; dirname&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;fileURLToPath&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;meta&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; defineConfig&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  plugins&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;    bundleStats&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;      baselineFilepath&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; join&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;currentDir&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;node_modules&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;.cache&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;bundle-stats&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;baseline.json&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;      silent&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Then you can run &lt;code&gt;vite build&lt;/code&gt; to build your project and generate the package analysis. You should be able to find a &lt;code&gt;bundle-stats.html&lt;/code&gt; in the output directory of &lt;code&gt;vite build&lt;/code&gt;.&lt;/p&gt; &lt;h2 id=&quot;remove-duplicate-packages-from-your-bundle&quot;&gt;&lt;a href=&quot;#remove-duplicate-packages-from-your-bundle&quot;&gt;Remove duplicate packages from your bundle&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To walk you through the process of removing duplicate packages from your bundle, I have created a &lt;a href=&quot;https://github.com/winston0410/analyze-vite-bundle-demo&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;minimal SvelteKit project with &lt;code&gt;@grafana/faro-rollup-plugin&lt;/code&gt;, &lt;code&gt;@grafana/faro-web-sdk&lt;/code&gt; and &lt;code&gt;@grafana/faro-web-tracing&lt;/code&gt;&lt;/a&gt; installed. These packages have some shared and duplicated dependencies, and it is perfect for demonstration.&lt;/p&gt; &lt;p&gt;Running &lt;code&gt;vite build&lt;/code&gt; for this project for the first time, and inspect &lt;code&gt;bundle-stats.html&lt;/code&gt;, we can see that there are 7 duplicate packages in this project. Click on the “duplicate packages” tab, we can see that the duplicate packages are &lt;code&gt;@opentelemetry/core&lt;/code&gt;, &lt;code&gt;@opentelemetry/semantic-conventions&lt;/code&gt; and &lt;code&gt;@opentelemetry/sdk-trace-web&lt;/code&gt;.&lt;/p&gt; &lt;iframe title=&quot;bundle-stats.html before removing duplicate packages&quot; class=&quot;uno-7vp2m7&quot; src=&quot;/embedded/bundle-stats-before.html&quot; width=&quot;100%&quot; height=&quot;320px&quot;&gt;&lt;/iframe&gt; &lt;p&gt;To unify the version of our packages and remove duplicate, we can define the desired version in &lt;code&gt;package.json&lt;/code&gt; in &lt;a href=&quot;https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;overrides&lt;/code&gt;&lt;/a&gt; (or &lt;a href=&quot;https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;resolutions&lt;/code&gt;&lt;/a&gt; if you are using &lt;code&gt;yarn&lt;/code&gt;). After updated &lt;code&gt;package.json&lt;/code&gt;, we then need to run &lt;code&gt;npm dedupe&lt;/code&gt; to update &lt;code&gt;package-lock.json&lt;/code&gt; and remove duplicate packages, and we can run &lt;code&gt;vite build&lt;/code&gt; again to verify the result. You might have to repeat this process multiple times, until you have removed all duplicate, as the new resolved packages might have duplicate dependencies with your existing packages.&lt;/p&gt; &lt;p&gt;A word of warning, overriding packages’ version with &lt;code&gt;overrides&lt;/code&gt; might break your project. It is better to write some tests beforehand to verify features of your project is still intact.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fbc02d&quot; d=&quot;M4.014 14.976a2.5 2.5 0 0 0 1.567-.518a2.38 2.38 0 0 0 .805-1.358a15.3 15.3 0 0 0 .214-2.944q.012-2.085.075-2.747a5.2 5.2 0 0 1 .418-1.686a3 3 0 0 1 .755-1.018A3.05 3.05 0 0 1 9 4.125A6.8 6.8 0 0 1 10.544 4h.7v1.96h-.387a2.34 2.34 0 0 0-1.723.468a3.4 3.4 0 0 0-.425 2.092a36 36 0 0 1-.137 4.133a4.7 4.7 0 0 1-.768 2.06A4.6 4.6 0 0 1 6.1 16a3.8 3.8 0 0 1 1.992 1.754a8.9 8.9 0 0 1 .618 3.865q0 2.435.05 2.9a1.76 1.76 0 0 0 .504 1.181a2.64 2.64 0 0 0 1.592.337h.387V28h-.7a5.7 5.7 0 0 1-1.773-.2a2.97 2.97 0 0 1-1.324-.93a3.35 3.35 0 0 1-.681-1.63a24 24 0 0 1-.165-3.234a16.5 16.5 0 0 0-.214-3.106a2.4 2.4 0 0 0-.805-1.361a2.5 2.5 0 0 0-1.567-.524Zm23.972 2.035a2.5 2.5 0 0 0-1.567.524a2.4 2.4 0 0 0-.805 1.361a16.5 16.5 0 0 0-.212 3.109a24 24 0 0 1-.169 3.234a3.35 3.35 0 0 1-.681 1.63a2.97 2.97 0 0 1-1.324.93a5.7 5.7 0 0 1-1.773.2h-.7V26.04h.387a2.64 2.64 0 0 0 1.592-.337a1.76 1.76 0 0 0 .506-1.186q.05-.462.05-2.9a8.9 8.9 0 0 1 .618-3.865A3.8 3.8 0 0 1 25.9 16a4.6 4.6 0 0 1-1.7-1.286a4.7 4.7 0 0 1-.768-2.06a36 36 0 0 1-.137-4.133a3.4 3.4 0 0 0-.425-2.092a2.34 2.34 0 0 0-1.723-.468h-.387V4h.7a6.8 6.8 0 0 1 1.54.125a3.05 3.05 0 0 1 1.149.581a3 3 0 0 1 .755 1.018a5.2 5.2 0 0 1 .418 1.686q.062.662.075 2.747a15.3 15.3 0 0 0 .212 2.947a2.38 2.38 0 0 0 .805 1.355a2.5 2.5 0 0 0 1.567.518Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;package.json&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  // ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &quot;&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;devDependencies&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@grafana/faro-rollup-plugin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^0.1.1&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@grafana/faro-web-sdk&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^1.12.2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@grafana/faro-web-tracing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^1.12.2&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &quot;&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;overrides&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@opentelemetry/resources&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1.27.0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@opentelemetry/core&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1.27.0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@opentelemetry/semantic-conventions&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1.27.0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;@opentelemetry/sdk-trace-web&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;1.27.0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;At the end, we could see that all duplicate packages are gone, and the bundle size decreased slightly as well. With a bigger project, you should see greater changes.&lt;/p&gt; &lt;iframe title=&quot;bundle-stats.html after removing duplicate packages&quot; class=&quot;uno-7vp2m7&quot; src=&quot;/embedded/bundle-stats-after.html&quot; width=&quot;100%&quot; height=&quot;320px&quot;&gt;&lt;/iframe&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>rollup</term><scheme>https://hugosum.com/tag/rollup</scheme><label>Rollup</label></category><category><term>vite</term><scheme>https://hugosum.com/tag/vite</scheme><label>Vite</label></category><summary>In this post I will show you how to analyze and optimize your Vite bundle by removing duplicate code and packages.</summary><published>Sat, 18 Jan 2025 00:00:00 GMT</published><updated>Sat, 18 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/reduce-input-lag-for-gaming-on-gnome</id><title>Reduce input latency for gaming with Gnome in NixOS</title><link>https://hugosum.com/blog/reduce-input-lag-for-gaming-on-gnome</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Recently I have started gaming in NixOS with Gnome, and everything is running smooth and slick, except a noticeable input latency, which is unbearable as I was playing shooter game.&lt;/p&gt; &lt;p&gt;After searching for a while, I realized that input latency can be reduced by enabling variable refresh rate (VRR). Gnome has added in &lt;a href=&quot;https://release.gnome.org/46/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;experimental support for VRR starting from version 46&lt;/a&gt;, and it is disabled by default.&lt;/p&gt; &lt;p&gt;To enable this experimental feature, you have to use &lt;code&gt;gsettings&lt;/code&gt; or &lt;code&gt;dconf&lt;/code&gt; to add &lt;code&gt;variable-refresh-rate&lt;/code&gt; as an item of the value of &lt;code&gt;/org/gnome/mutter/experimental-features&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you prefer gsettings&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;gsettings&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; set&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; org.gnome.mutter&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; experimental-features&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;[&apos;variable-refresh-rate&apos;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you prefer dconf&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;dconf&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; write&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; /org/gnome/mutter/experimental-features&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;[&apos;variable-refresh-rate&apos;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;To do this the Nix way, if you are using Home Manager and you want to enable this feature on a user basis, you set this value through &lt;code&gt;dconf.settings&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/mutter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      experimental-features&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;variable-refresh-rate&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>gnome</term><scheme>https://hugosum.com/tag/gnome</scheme><label>Gnome</label></category><category><term>home-manager</term><scheme>https://hugosum.com/tag/home-manager</scheme><label>Home Manager</label></category><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><summary>In this post I want to share how to reduce input latency when gaming with Gnome in NixOS.</summary><published>Fri, 17 Jan 2025 00:00:00 GMT</published><updated>Fri, 17 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/creating-content-security-policy-in-sveltekit</id><title>Creating Content Security Policy in SvelteKit</title><link>https://hugosum.com/blog/creating-content-security-policy-in-sveltekit</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;h2 id=&quot;what-is-content-security-policy-csp&quot;&gt;&lt;a href=&quot;#what-is-content-security-policy-csp&quot;&gt;What is Content Security Policy (CSP)?&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;In a nutshell, Content Security Policy (CSP) is a list of trusted origins which only their resources can be loaded on your website once defined. This is a security feature for preventing attacks such as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;cross-site scripting (XSS)&lt;/a&gt; and data injection.&lt;/p&gt; &lt;p&gt;CSP can be defined through HTTP response headers &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Content-Security-Policy&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;Content-Security-Policy-Report-Only&lt;/code&gt;&lt;/a&gt; or meta tags with &lt;code&gt;&amp;lt;meta http-equiv&gt;&lt;/code&gt;.&lt;/p&gt; &lt;h2 id=&quot;setting-up-content-security-policy-in-sveltekit&quot;&gt;&lt;a href=&quot;#setting-up-content-security-policy-in-sveltekit&quot;&gt;Setting up Content Security Policy in SvelteKit&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;SvelteKit provides CSP support out of the box. We just need to define the policy we want through &lt;code&gt;kit.csp&lt;/code&gt;, and SvelteKit will generate the corresponding hash or nonce for its inline style and scripts, and policies as &lt;code&gt;&amp;lt;meta http-equiv&gt;&lt;/code&gt; tag in HTML.&lt;/p&gt; &lt;p&gt;Initially I defined my CSP based on the &lt;a href=&quot;https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html#basic-non-strict-csp-policy&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;basic non-strict policy from OWASP&lt;/a&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;default-src&lt;/code&gt;&lt;/a&gt; directive would be used as a fallback for most unspecified directives, except a few exceptions such as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;frame-ancestors&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/form-action&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;form-action&lt;/code&gt;&lt;/a&gt; directive. The values of a directive are the allowed origins, and &lt;code&gt;self&lt;/code&gt; represents the same origin as your website.&lt;/p&gt; &lt;p&gt;By defining our policies in &lt;code&gt;kit.csp.reportOnly&lt;/code&gt; instead of &lt;code&gt;kit.csp.directives&lt;/code&gt;, browsers would not block non-compliant resources but only log violations or make a POST request to the endpoint defined in &lt;code&gt;report-uri&lt;/code&gt;. With that information, you can discover resources your website depending on, and gradually tighten your security policies without breaking anything, by moving your security policies from &lt;code&gt;kit.csp.reportOnly&lt;/code&gt; to &lt;code&gt;kit.csp.directives&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#F0DB4F&quot; d=&quot;M1.408 1.408h125.184v125.185H1.408z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#323330&quot; d=&quot;M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981c-3.832-1.761-8.104-3.022-9.377-5.926c-.452-1.69-.512-2.642-.226-3.665c.821-3.32 4.784-4.355 7.925-3.403c2.023.678 3.938 2.237 5.093 4.724c5.402-3.498 5.391-3.475 9.163-5.879c-1.381-2.141-2.118-3.129-3.022-4.045c-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235c-5.926 6.724-4.236 18.492 2.975 23.335c7.104 5.332 17.54 6.545 18.873 11.531c1.297 6.104-4.486 8.08-10.234 7.378c-4.236-.881-6.592-3.034-9.139-6.949c-4.688 2.713-4.688 2.713-9.508 5.485c1.143 2.499 2.344 3.63 4.26 5.795c9.068 9.198 31.76 8.746 35.83-5.176c.165-.478 1.261-3.666.38-8.581M69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149c-1.713 3.558-6.152 3.117-8.175 2.427c-2.059-1.012-3.106-2.451-4.319-4.485c-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901c4.462 2.678 10.459 3.499 16.731 2.059c4.082-1.189 7.604-3.652 9.448-7.401c2.666-4.915 2.094-10.864 2.07-17.444c.06-10.735.001-21.468.001-32.237&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;svelte.config.js&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    csp&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;      // NOTE without setting a truthy value for kit.csp.directives, SvelteKit would not do anything for CSP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      directives&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      reportOnly&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;default-src&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;frame-ancestors&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;form-action&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;report-uri&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;      &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I have created a &lt;a href=&quot;https://github.com/winston0410/sveltekit-csp&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;minimal SvelteKit project with these content security policies defined&lt;/a&gt;, so you can play around yourself.&lt;/p&gt; &lt;h2 id=&quot;dealing-with-csp-violations-in-sveltekit&quot;&gt;&lt;a href=&quot;#dealing-with-csp-violations-in-sveltekit&quot;&gt;Dealing with CSP violations in SvelteKit&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;The above configuration should work for most of the SvelteKit projects. From time to time you might encounter packages that violates your CSP. For example, on this website I use &lt;a href=&quot;https://grafana.com/oss/faro/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Grafana Faro&lt;/a&gt; for tracking performance my website. The SDK for this service, &lt;a href=&quot;https://www.npmjs.com/package/@grafana/faro-web-sdk?activeTab=dependencies&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;@grafana/faro-web-sdk&lt;/code&gt;&lt;/a&gt; used a package contains &lt;code&gt;eval()&lt;/code&gt; in its code, I then notice the following log in my console.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9AA5CE&quot;&gt;Content-Security-Policy: (Report-Only policy) The page’s settings would block a JavaScript eval (script-src) from being executed because it violates the following directive: “script-src &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&apos;self&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; &apos;nonce-ewcvSmSO/2WM8RPgzlYn3A==&apos;&lt;/span&gt;&lt;span style=&quot;color:#9AA5CE&quot;&gt; (Missing &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&apos;unsafe-eval&apos;&lt;/span&gt;&lt;span style=&quot;color:#9AA5CE&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;An option to address this is to add &lt;code&gt;unsafe-eval&lt;/code&gt; to &lt;code&gt;script-src&lt;/code&gt; directive as suggested, but this is a global setting for my website, not only for this package. We won’t get much benefit from CSP if we had used &lt;code&gt;unsafe-eval&lt;/code&gt; or &lt;code&gt;unsafe-inline&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;The other option is we move the policies to &lt;code&gt;kit.csp.reportOnly&lt;/code&gt; for reporting violations only, and we monitor those violations reports to verify our website is secure or not. You could host a server that receives and converts the POST payload sent by &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Reporting_API&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Reporting API from browsers&lt;/a&gt; to metrics understandable by tools such as Prometheus or OpenTelemetry, and then set up alerting rules to monitor content security policy’s violations. This approach requires more work in the back end, but it saves you from refactoring code or switch packages in your SvelteKit project.&lt;/p&gt; &lt;p&gt;From my research, I found &lt;a href=&quot;https://github.com/jacobbednarz/go-csp-collector/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;go-csp-collector&lt;/a&gt; for collecting the reports, and it seems to be a good starting point for building your monitoring system.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><summary>In this post I want to explain what is Content Security Policy (CSP) and how to implement it in SvelteKit, and how to deal with policy violations.</summary><published>Thu, 16 Jan 2025 00:00:00 GMT</published><updated>Thu, 16 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/how-to-get-100-performance-score-in-lighthouse-with-sveltekit</id><title>How to get 100 performance score in Lighthouse with SvelteKit</title><link>https://hugosum.com/blog/how-to-get-100-performance-score-in-lighthouse-with-sveltekit</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Lighthouse is a tool for auditing performance, accessibility and SEO of a web page. As I want to give my readers the best browsing experience, I am concerned with the Lighthouse score of my website.&lt;/p&gt; &lt;p&gt;In this post, I will show you a few techniques on optimizing your SvelteKit project for getting 100 performance score on Lighthouse.&lt;/p&gt; &lt;h2 id=&quot;minifying-html-response&quot;&gt;&lt;a href=&quot;#minifying-html-response&quot;&gt;Minifying HTML response&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Out of the box, only CSS and Javascript is minified by SvelteKit. HTML is not handled.&lt;/p&gt; &lt;p&gt;To minify HTML responses, no matter which adapter you are using, you can transform the HTML response in &lt;code&gt;hooks.server.js&lt;/code&gt; or &lt;code&gt;hooks.server.ts&lt;/code&gt; with an HTML minification library. The following is a snippet of using &lt;code&gt;html-minifier&lt;/code&gt; to minify the HTML response.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;src/hooks.server.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;minify&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;html-minifier&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; Handle&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; minifyOpts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  collapseBooleanAttributes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  collapseWhitespace&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  conservativeCollapse&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  decodeEntities&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  html5&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  ignoreCustomComments&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  minifyCSS&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  minifyJS&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeAttributeQuotes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeComments&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeOptionalTags&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeRedundantAttributes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeScriptTypeAttributes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  removeStyleLinkTypeAttributes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  sortAttributes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  sortClassName&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; handle&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; Handle&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; event&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; resolve&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; resolve&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;event&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;    transformPageChunk&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; done&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; minify&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; minifyOpts&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;enable-pre-compression&quot;&gt;&lt;a href=&quot;#enable-pre-compression&quot;&gt;Enable pre-compression&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;After minifying your assets, you should also compress them with &lt;code&gt;gzip&lt;/code&gt; or &lt;code&gt;brotli&lt;/code&gt;, reducing the size of files to be transmitted. Some adapters, such as &lt;a href=&quot;https://www.npmjs.com/package/@sveltejs/adapter-node&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;@sveltejs/adapter-node&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://www.npmjs.com/package/@sveltejs/adapter-static&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;@sveltejs/adapter-static&lt;/code&gt;&lt;/a&gt; support pre-compression, and you can pre-compress your assets in the build time. Otherwise, you will have to compress your assets on the fly.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#F0DB4F&quot; d=&quot;M1.408 1.408h125.184v125.185H1.408z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#323330&quot; d=&quot;M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981c-3.832-1.761-8.104-3.022-9.377-5.926c-.452-1.69-.512-2.642-.226-3.665c.821-3.32 4.784-4.355 7.925-3.403c2.023.678 3.938 2.237 5.093 4.724c5.402-3.498 5.391-3.475 9.163-5.879c-1.381-2.141-2.118-3.129-3.022-4.045c-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235c-5.926 6.724-4.236 18.492 2.975 23.335c7.104 5.332 17.54 6.545 18.873 11.531c1.297 6.104-4.486 8.08-10.234 7.378c-4.236-.881-6.592-3.034-9.139-6.949c-4.688 2.713-4.688 2.713-9.508 5.485c1.143 2.499 2.344 3.63 4.26 5.795c9.068 9.198 31.76 8.746 35.83-5.176c.165-.478 1.261-3.666.38-8.581M69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149c-1.713 3.558-6.152 3.117-8.175 2.427c-2.059-1.012-3.106-2.451-4.319-4.485c-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901c4.462 2.678 10.459 3.499 16.731 2.059c4.082-1.189 7.604-3.652 9.448-7.401c2.666-4.915 2.094-10.864 2.07-17.444c.06-10.735.001-21.468.001-32.237&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;svelte.config.js&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/adapter-static&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;/** &lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;@type&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;import(&apos;@sveltejs/kit&apos;).Config&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;&amp;#125; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    adapter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      precompress&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;After compressing your assets, you might need to configure your load balancer for serving them. My guide on &lt;a href=&quot;/blog/dockerize-sveltekit-with-adaptor-static-and-nginx#serving-precompressed-assets&quot;&gt;serving compressed files with &lt;code&gt;nginx&lt;/code&gt;&lt;/a&gt; might be useful for you.&lt;/p&gt; &lt;h2 id=&quot;cache-immutable-assets-with-cache-control-http-response-header&quot;&gt;&lt;a href=&quot;#cache-immutable-assets-with-cache-control-http-response-header&quot;&gt;Cache immutable assets with &lt;code&gt;Cache-Control&lt;/code&gt; HTTP response header&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If you have ever examined the build output of SvelteKit, you may notice that &lt;code&gt;/_app/immutable&lt;/code&gt; contains all your CSS and Javascript of a build (except service worker script, &lt;code&gt;sw.js&lt;/code&gt;), and every file in it has a hash in their file name, which is generated based on the content of the file. These hashes are used for &lt;strong&gt;cache-busting&lt;/strong&gt;, and files with such hash should be cached for as long as possible.&lt;/p&gt; &lt;p&gt;&lt;code&gt;Cache-Control&lt;/code&gt; HTTP response header indicates how long a resource should be cached. You should at least cache files in &lt;code&gt;/_app/immutable&lt;/code&gt; for a year.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[!--&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;Cache-Control&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; max-age=31536000&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Do not add such strong caching rule to a file without hash, unless you know what you are doing. Setting &lt;code&gt;Cache-Control: no-cache&lt;/code&gt; to those files is a good default, which the browser will still cache the file, but always revalidate, making sure the latest version is served.&lt;/p&gt; &lt;p&gt;Depending on what you prefer, you can set this header at your load balancer level or file server level. The configuration depends on what you use. If you are using &lt;code&gt;nginx&lt;/code&gt;, you can add this header inside a &lt;code&gt;location&lt;/code&gt; block.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    location&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; /_app/immutable &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        add_header &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;Cache-Control &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;max-age=31536000&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;optimize-images&quot;&gt;&lt;a href=&quot;#optimize-images&quot;&gt;Optimize images&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;This is the most important optimization to have, as an unoptimized image can drag down the performance of your website significantly. In principle, optimizing images on a webpage means &lt;strong&gt;serving the right format and the right size&lt;/strong&gt;. You should use format that can be compressed smaller such as &lt;code&gt;webp&lt;/code&gt; or &lt;code&gt;avif&lt;/code&gt;, and you should serve a smaller image, if your user is browsing your website with his phone. In a nutshell, you have to generate images in multiple formats and dimension to achieve this.&lt;/p&gt; &lt;h3 id=&quot;optimize-images-at-build-time&quot;&gt;&lt;a href=&quot;#optimize-images-at-build-time&quot;&gt;Optimize images at build time&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;In the past I have to set up tools such as &lt;code&gt;sharp&lt;/code&gt; and create an image markup component to load the generated images and the original image as fallback, using &lt;code&gt;&amp;lt;picture&gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;source&gt;&lt;/code&gt;. Fortunately, the new experimental plugin &lt;a href=&quot;https://www.npmjs.com/package/@sveltejs/enhanced-img&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;@sveltejs/enhanced-img&lt;/a&gt; do all that for us.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#ff3e00&quot; d=&quot;M110.43 16.936C98.553-.076 75.09-5.118 58.13 5.696l-29.792 19a34.2 34.2 0 0 0-15.48 22.897a25.478 30.64 0 0 0-.572 6.396a36.15 36.15 0 0 0 4.163 16.73A34.4 34.4 0 0 0 11.34 83.5a25.348 30.483 0 0 0 .345 14.412a36.5 36.5 0 0 0 5.9 13.152c11.878 17.01 35.394 22.053 52.3 11.24l29.762-19.001a34.13 34.13 0 0 0 15.438-22.918a35.5 35.5 0 0 0 .572-6.386a36.2 36.2 0 0 0-4.112-16.71a34.4 34.4 0 0 0 5.112-12.77c.369-2.11.557-4.245.562-6.386a36.4 36.4 0 0 0-6.787-21.178z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M55.219 112.662a28.463 34.23 0 0 1-5.954.76a23.64 23.64 0 0 1-19.435-10.187a21.9 21.9 0 0 1-4.08-12.74a15.658 18.83 0 0 1 .333-3.833a15.425 18.55 0 0 1 .72-2.782l.561-1.708l1.52 1.156a38.7 38.7 0 0 0 11.658 5.834l1.104.333l-.104 1.104v.573a6.63 6.63 0 0 0 1.228 3.854a7.1 7.1 0 0 0 2.538 2.288a8.262 9.936 0 0 0 3.312.837a8.251 9.923 0 0 0 1.79-.229a7.272 8.745 0 0 0 1.833-.802l29.76-19.094a6.26 6.26 0 0 0 2.904-5.302a6.62 6.62 0 0 0-1.26-3.844a7.14 7.14 0 0 0-2.553-2.252a8.313 9.997 0 0 0-3.307-.81a8.246 9.917 0 0 0-1.79.23a6.938 8.344 0 0 0-1.822.801l-11.346 7.25a24.376 29.314 0 0 1-6.048 2.656a23.64 23.64 0 0 1-25.39-9.416a21.94 21.94 0 0 1-4.08-12.74c.002-1.285.114-2.567.333-3.833a20.65 20.65 0 0 1 9.286-13.781l29.792-18.99a21.9 21.9 0 0 1 6.048-2.667a24 24 0 0 1 5.954-.75A23.68 23.68 0 0 1 98.22 24.745a21.94 21.94 0 0 1 4.029 12.75a15.748 18.939 0 0 1-.334 3.844a15.407 18.529 0 0 1-.718 2.781l-.562 1.708l-1.52-1.114a38.4 38.4 0 0 0-11.658-5.834l-1.104-.343l.104-1.105v-.572a6.7 6.7 0 0 0-1.228-3.865a7.1 7.1 0 0 0-2.55-2.25a8.309 9.992 0 0 0-3.3-.813a8.221 9.887 0 0 0-1.77.271a6.819 8.2 0 0 0-1.831.802l-29.793 18.99a5.88 7.071 0 0 0-1.836 1.79a4.75 5.713 0 0 0-.963 2.377a5.037 6.057 0 0 0-.136 1.104a6.62 6.62 0 0 0 1.228 3.844a7.1 7.1 0 0 0 2.549 2.25a8.299 9.98 0 0 0 3.301.812a8.247 9.918 0 0 0 1.79-.23a6.943 8.35 0 0 0 1.833-.801l11.367-7.292a24.218 29.125 0 0 1 6.048-2.656a28.526 34.305 0 0 1 5.954-.76A23.66 23.66 0 0 1 96.566 60.61a21.94 21.94 0 0 1 3.737 16.614a20.6 20.6 0 0 1-9.286 13.781l-29.74 18.99a24.308 29.233 0 0 1-6.057 2.667z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; FooImage&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;./foo.jpg?enhanced&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; // import the source image but generated the enhanced version as well&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;/&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;&amp;#x3C;!-- this component is using &amp;#x3C;picture&gt; and &amp;#x3C;source&gt; as well, just nicely packaged --&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt;&amp;#x3C;&lt;/span&gt;&lt;span style=&quot;color:#F7768E&quot;&gt;enhanced:img&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; src&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;FooImage&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; alt&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;some alt text&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#BA3C97&quot;&gt; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h3 id=&quot;optimize-images-at-run-time&quot;&gt;&lt;a href=&quot;#optimize-images-at-run-time&quot;&gt;Optimize images at run time&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;If your images are stored in a S3 bucket or somewhere remote, and you load them dynamically, you can only optimize them in runtime. You can use an image transformation proxy, such as &lt;a href=&quot;https://imgproxy.net/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;imgproxy&lt;/a&gt; to generate an optimized image on the fly.&lt;/p&gt; &lt;p&gt;As an alternative, you can also run scripts that optimize images continuously with cron jobs.&lt;/p&gt; &lt;h2 id=&quot;enable-pre-rendering-if-possible&quot;&gt;&lt;a href=&quot;#enable-pre-rendering-if-possible&quot;&gt;Enable pre-rendering if possible&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;By pre-rendering your pages, you create an HTML file with all the variables in your Svelte markup substituted in the build time. Users of your application will then get a hydrated (basically it means completed) HTML file immediately and reduce &lt;a href=&quot;https://web.dev/articles/fcp&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;First Contentful Print&lt;/a&gt;. You can set &lt;code&gt;const prerender = true&lt;/code&gt; in your &lt;code&gt;+layout.ts&lt;/code&gt; or &lt;code&gt;+page.ts&lt;/code&gt; to enable pre-rendering. Setting it at &lt;code&gt;+layout.ts&lt;/code&gt; will enable pre-rendering for all pages using that layout.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+layout.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; prerender&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;However, pre-rendering might not be useful to your application, if your users cannot benefit from stale data. Say your application shows real time stocks’ price, pre-rendering and shipping the prices at the build time to users initially is meaningless.&lt;/p&gt; &lt;h2 id=&quot;disable-client-side-rendering-csr&quot;&gt;&lt;a href=&quot;#disable-client-side-rendering-csr&quot;&gt;Disable client side rendering (CSR)&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If your page can be pre-rendered or server side rendered, and you do not need interactivity on your page, you can simply disable client side rendering and not ship Javascript to your users. This would obviously reduce the payload you send to your users, but it might only be feasible for static pages, such as a blog post.&lt;/p&gt; &lt;p&gt;To disable CSR, you can set &lt;code&gt;const csr = false&lt;/code&gt; in a &lt;code&gt;+layout.ts&lt;/code&gt; or &lt;code&gt;+page.ts&lt;/code&gt;, and it will disable CSR for a set of pages using that layout or an individual page.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;+layout.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; csr&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;// enable at least ssr or pre-rendering, otherwise a blank page will be shipped&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; ssr&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; prerender&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;optimize-font-rendering&quot;&gt;&lt;a href=&quot;#optimize-font-rendering&quot;&gt;Optimize font rendering&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If no font specified through &lt;code&gt;font-family&lt;/code&gt; has been loaded, browsers would wait for it and would not render text for a period of time. To make browsers fallback to system font, until at least one specified font is available, you should set &lt;code&gt;font-display: swap&lt;/code&gt; in your &lt;code&gt;@font-face&lt;/code&gt; rule in CSS.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#1572B6&quot; d=&quot;M18.814 114.123L8.76 1.352h110.48l-10.064 112.754l-45.243 12.543z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#33A9DC&quot; d=&quot;m64.001 117.062l36.559-10.136l8.601-96.354h-45.16z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M64.001 51.429h18.302l1.264-14.163H64.001V23.435h34.682l-.332 3.711l-3.4 38.114h-30.95z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#EBEBEB&quot; d=&quot;m64.083 87.349l-.061.018l-15.403-4.159l-.985-11.031H33.752l1.937 21.717l28.331 7.863l.063-.018z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;m81.127 64.675l-1.666 18.522l-15.426 4.164v14.39l28.354-7.858l.208-2.337l2.406-26.881z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#EBEBEB&quot; d=&quot;M64.048 23.435v13.831H30.64l-.277-3.108l-.63-7.012l-.331-3.711zm-.047 27.996v13.831H48.792l-.277-3.108l-.631-7.012l-.33-3.711z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;font-face&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;  font-family&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; Roboto&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;  font-display&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; swap&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Also you should only use font with &lt;code&gt;woff2&lt;/code&gt; format, as it can achieve better compression comparing with other formats, and it is supported by &lt;a href=&quot;https://caniuse.com/?search=woff2&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;almost all browsers&lt;/a&gt; in 2025.&lt;/p&gt; &lt;p&gt;If you don’t want to deal with all these manually, I would recommend using font packages from &lt;a href=&quot;https://fontsource.org/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Fontsource&lt;/a&gt;. Out of the box they set &lt;code&gt;font-display: swap&lt;/code&gt; and use only &lt;code&gt;woff2&lt;/code&gt; font files.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>svelte</term><scheme>https://hugosum.com/tag/svelte</scheme><label>Svelte</label></category><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><category><term>lighthouse</term><scheme>https://hugosum.com/tag/lighthouse</scheme><label>Lighthouse</label></category><summary>In this post, I will show you a few techniques on optimizing your SvelteKit project for getting 100 performance score on Lighthouse.</summary><published>Mon, 13 Jan 2025 00:00:00 GMT</published><updated>Mon, 13 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/syncronizing-inputs-across-flakes</id><title>Synchronizing inputs across Nix flakes</title><link>https://hugosum.com/blog/syncronizing-inputs-across-flakes</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;I have a few projects using &lt;code&gt;nix-direnv&lt;/code&gt; to load development environments automatically, and each of them is using a slightly different version of &lt;code&gt;nixpkgs&lt;/code&gt;, depending on when I created them. As my laptop with 256 GB storage run out of space again, and I do not depend on any unstable software with my projects, I want to synchronize their inputs to avoid duplications and reduce storage usage.&lt;/p&gt; &lt;h2 id=&quot;synchronizing-inputs-with-nix-registry&quot;&gt;&lt;a href=&quot;#synchronizing-inputs-with-nix-registry&quot;&gt;Synchronizing inputs with &lt;code&gt;nix registry&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;As I understand it, &lt;code&gt;nix registry&lt;/code&gt; is just an alias to an actual input. By using an alias, you can then force multiple flakes to use the exact same version of an input.&lt;/p&gt; &lt;p&gt;You can define your own &lt;code&gt;nix registry&lt;/code&gt; specific to your machine with &lt;a href=&quot;https://search.nixos.org/options?show=nix.registry&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=registry&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nix.registry&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;To create a registry that is called &lt;code&gt;foo&lt;/code&gt;, and points to &lt;code&gt;nixos-23.05&lt;/code&gt; branch in &lt;code&gt;NixOS/nixpkgs&lt;/code&gt; repository on GitHub, you can update your NixOS configuration as the following.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nix&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;registry&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        foo&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;to&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            owner&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;NixOS&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            ref&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixos-23.05&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            repo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;            type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And then you can use this &lt;code&gt;foo&lt;/code&gt; as input in Nix flake. You do not need to define this variable in &lt;code&gt;inputs&lt;/code&gt;, as &lt;strong&gt;missing inputs will be resolved by the registry automatically&lt;/strong&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Using &lt;a href=&quot;https://search.nixos.org/options?show=nix.registry&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=registry&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nix.registry&lt;/code&gt;&lt;/a&gt; can only create &lt;code&gt;nix registry&lt;/code&gt; on your local machine. If you want to create a registry definition that can be shared among multiple machines, you can create a JSON file according to the format accepted by &lt;code&gt;nix registry&lt;/code&gt; and host it somewhere, and point to that JSON file in the &lt;code&gt;nixConfig.flake-registry&lt;/code&gt; in your &lt;code&gt;flake.nix&lt;/code&gt;. A good start will be forking &lt;a href=&quot;https://github.com/NixOS/flake-registry&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;the global flake registry&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-highlighted&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; foo&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  nixConfig&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    flake-registry&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;https://example.com/myrepository.json&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line highlighted&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;In my opinion you should always have &lt;code&gt;nixConfig.flake-registry&lt;/code&gt; defined if you are using &lt;code&gt;nix registry&lt;/code&gt;. Without defining &lt;code&gt;nixConfig.flake-registry&lt;/code&gt;, &lt;code&gt;nix registry&lt;/code&gt; will become a &lt;strong&gt;global mutable state&lt;/strong&gt;. If you cannot control the &lt;code&gt;nix registry&lt;/code&gt; definition in your flake consumers’ machine, you cannot guarantee your flake would build there. What if &lt;code&gt;foo&lt;/code&gt; points to &lt;code&gt;nixos-23.05&lt;/code&gt; on your machine, but &lt;code&gt;foo&lt;/code&gt; points to &lt;code&gt;nixos-14.05&lt;/code&gt; on their machine? What if you have two projects using the same registry name in their flake, but that name should resolve to two entirely different inputs?&lt;/p&gt; &lt;h2 id=&quot;synchronizing-inputs-with-proxy-flake&quot;&gt;&lt;a href=&quot;#synchronizing-inputs-with-proxy-flake&quot;&gt;Synchronizing inputs with proxy flake&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Another option to synchronize inputs is to create a proxy flake. It will be used as an input by your downstream flakes and its inputs will be followed, exposing them to downstream flakes. This approach obviously works with multiple machines.&lt;/p&gt; &lt;p&gt;For example, I have a flake that has the following inputs as proxy.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  description&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;proxy flake for controlling input for all my flakes&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nixos/nixpkgs/nixos-24.11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:hercules-ci/flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nixpkgs-lib&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixos-hardware&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:NixOS/nixos-hardware/master&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nur&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nix-community/NUR/master&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nur&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And then I can use its inputs indirectly in my projects’ flake.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;projects/flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    proxy-flake&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:winston0410/proxy-flake?main&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;proxy-flake/nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    flake-parts&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;proxy-flake/flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; flake-parts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Personally I prefer using proxy flake over &lt;code&gt;nix registry&lt;/code&gt;, as it completely remove the possible pitfall of a global mutable state.&lt;/p&gt; &lt;h2 id=&quot;upgrading-inputs&quot;&gt;&lt;a href=&quot;#upgrading-inputs&quot;&gt;Upgrading inputs&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To update inputs, after changing their target commit or branch in your registry definition or proxy flake, you still have to run &lt;code&gt;nix flake update&lt;/code&gt; manually to update downstream flakes. Even though it seems to be a hassle, inputs of your projects would not update automatically without you knowing. But of course you can write a script to automate it.&lt;/p&gt; &lt;p&gt;No matter which approach you have chosen, you can still find &lt;code&gt;sha256&lt;/code&gt; hash in &lt;code&gt;flake.lock&lt;/code&gt; to confirm which commit or branch does it resolve to.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><summary>In this post, I will show you how to synchronize version of inputs across Nix flake with `nix registry` and proxy flakes, and talk about their limitations.</summary><published>Sat, 11 Jan 2025 00:00:00 GMT</published><updated>Sat, 11 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/convert-git-repository-into-a-tarball-for-sharing</id><title>Convert git repository into a tarball for sharing</title><link>https://hugosum.com/blog/convert-git-repository-into-a-tarball-for-sharing</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;A new hire joined our company, but the engineer who manages role and permission for the company is still on holiday. Obviously he didn’t get access to our remote git repository, so I had to convert our repository into a tarball and send it to him.&lt;/p&gt; &lt;p&gt;In this post, I will share how can you convert git repository into a tarball that respects &lt;code&gt;.gitignore&lt;/code&gt; for easy sharing.&lt;/p&gt; &lt;h2 id=&quot;creating-tarball-from-remote-repository&quot;&gt;&lt;a href=&quot;#creating-tarball-from-remote-repository&quot;&gt;Creating tarball from remote repository&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;After searching for a while, I came across this &lt;a href=&quot;https://stackoverflow.com/a/13751126&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Stackoverflow answer&lt;/a&gt; and learnt about &lt;code&gt;git archive&lt;/code&gt;. This command creates an archive of files from a commit, therefore &lt;code&gt;.gitignore&lt;/code&gt; is respected and only commited files will be included in the archive. Possible &lt;a href=&quot;https://git-scm.com/docs/git-archive#Documentation/git-archive.txt---formatltfmtgt&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;output format supported are &lt;code&gt;tar&lt;/code&gt;, &lt;code&gt;zip&lt;/code&gt;, &lt;code&gt;tar.gz&lt;/code&gt; and &lt;code&gt;tgz&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Since &lt;code&gt;git archive&lt;/code&gt; is commit-based, you can reference your remote git repository to create an archive.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; archive&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --format=tar&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; -o&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; ~/myarchive.tar&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --remote=https://mygitrepository/myproject.git&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; master&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # it accepts branch, commit or tag&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Be mindful that this command would only work if the target git server supports it. Also if you want to use &lt;code&gt;http&lt;/code&gt; instead of &lt;code&gt;git&lt;/code&gt; protocol for your remote git repository, you have to use &lt;a href=&quot;https://github.com/git/git/commit/bc7ee2e5e16f0d1e710ef8fab3db59ab11f2bbe7#diff-3a3ca29331351d0f90a7b6734731bbf47fe1076646b84a2a4e4c64e46921839a&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;git 2.44.0 or later&lt;/a&gt;.&lt;/p&gt; &lt;h2 id=&quot;creating-tarball-from-local-repository&quot;&gt;&lt;a href=&quot;#creating-tarball-from-local-repository&quot;&gt;Creating tarball from local repository&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If archiving directly from remote git repository is not an option for you, you can still clone the repository first, and then create an archive locally.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; archive&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --format=tar&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; -o&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; ~/myarchive.tar&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>git</term><scheme>https://hugosum.com/tag/git</scheme><label>Git</label></category><summary>In this post, I will share how can you convert git repository into a tarball that respects `.gitignore` for easy sharing.</summary><published>Fri, 10 Jan 2025 00:00:00 GMT</published><updated>Fri, 10 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/creating-sitemap-for-your-sveltekit-project-with-minimal-effort</id><title>Creating sitemap for your SvelteKit project with minimal effort</title><link>https://hugosum.com/blog/creating-sitemap-for-your-sveltekit-project-with-minimal-effort</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;Sitemap is crucial for the SEO success of a website. Even though SvelteKit is designed with SEO in mind, the decision was to &lt;a href=&quot;https://github.com/sveltejs/kit/issues/1142#issuecomment-1040976359&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;keep sitemap generation in the userland&lt;/a&gt;. I have been using SvelteKit since version pre 1.0, and I have created sitemaps for SvelteKit projects using different adapters. In this post I want to share my experience on building sitemap in SvelteKit and introduce &lt;a href=&quot;https://github.com/jasongitmail/super-sitemap&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;super-sitemap&lt;/code&gt;&lt;/a&gt; to you, which provides the ideal interface and experience for building sitemap in my opinion.&lt;/p&gt; &lt;h2 id=&quot;common-ways-of-creating-sitemap-for-sveltekit-projects&quot;&gt;&lt;a href=&quot;#common-ways-of-creating-sitemap-for-sveltekit-projects&quot;&gt;Common ways of creating sitemap for SvelteKit projects&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Building sitemap usually involve two steps, metadata retrieval and transformation. The process of metadata retrieval is largely shaped by how data is stored, and it is specific to a project. Projects that store metadata as local files usually use &lt;a href=&quot;https://vite.dev/guide/features#glob-import&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;import.meta.glob&lt;/code&gt; function&lt;/a&gt; for bulk import; projects that store metadata remotely, such as in a CMS, usually collect its data with HTTP requests.&lt;/p&gt; &lt;p&gt;After metadata are collected, it should then be transformed into structures that you would expect to see in a sitemap. It could be transformed directly as &lt;code&gt;&amp;lt;url&gt;&lt;/code&gt; nodes and embedded in a sitemap as string, or as objects that will be consumed by &lt;a href=&quot;https://www.npmjs.com/package/sitemap&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;sitemap generating libraries&lt;/a&gt;. No matter how you do it, this step is relatively generic.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;src/routes/sitemap.xml/+server.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;RequestHandler&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;loadPosts&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$lib/content&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; GET&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; RequestHandler&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  // this function could load from local files with import.meta.glob() or fetching data from remote, depending on how you store your data&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; posts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; loadPosts&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; Response&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#96;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;urlset&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns=&quot;https://www.sitemaps.org/schemas/sitemap/0.9&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns:xhtml=&quot;https://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns:mobile=&quot;https://www.google.com/schemas/sitemap-mobile/1.0&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns:news=&quot;https://www.google.com/schemas/sitemap-news/0.9&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns:image=&quot;https://www.google.com/schemas/sitemap-image/1.1&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;  xmlns:video=&quot;https://www.google.com/schemas/sitemap-video/1.1&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;$&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;posts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; updatedAt&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#96;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;url&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              &amp;#x3C;loc&gt;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;$&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;origin&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/blog/&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;$&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;/loc&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              &amp;#x3C;lastmod&gt;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;$&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;updatedAt&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;/lastmod&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;              &amp;#x3C;/url&gt;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#96;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#x3C;/urlset&gt;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#96;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;trim&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;      headers&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Content-Type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;application/xml&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;      &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  )&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;This approach is imperative, and the pitfall for it is you have to &lt;strong&gt;duplicate your routing configuration in code and maintain them&lt;/strong&gt;, as metadata do not have information on what routes your SvelteKit project has. Say the &lt;code&gt;id&lt;/code&gt; of your posts are all slugified strings, such as &lt;code&gt;my-post-title&lt;/code&gt;, and in your SvelteKit project you have a route &lt;code&gt;/blog/[slug]&lt;/code&gt;. You have to transform your data and prepend &lt;code&gt;/blog&lt;/code&gt; when you build your sitemap. A few months later, your project manager decided to add i18n support in your website, and you changed the route to &lt;code&gt;/[lang]/blog/[slug]&lt;/code&gt;. I bet you a pound to penny someone will forget to update the sitemap.&lt;/p&gt; &lt;h2 id=&quot;creating-sitemap-for-sveltekit-projects-with-super-sitemap&quot;&gt;&lt;a href=&quot;#creating-sitemap-for-sveltekit-projects-with-super-sitemap&quot;&gt;Creating sitemap for SvelteKit projects with &lt;code&gt;super-sitemap&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;The cleanest and the easiest way to create a sitemap in SvelteKit right now is probably with the &lt;a href=&quot;https://github.com/jasongitmail/super-sitemap&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;super-sitemap&lt;/code&gt;&lt;/a&gt;. Instead of using &lt;a href=&quot;https://vite.dev/guide/features#glob-import&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;import.meta.glob&lt;/code&gt; function&lt;/a&gt; to import all the data files, &lt;code&gt;super-sitemap&lt;/code&gt; only imports &lt;a href=&quot;https://github.com/jasongitmail/super-sitemap/blob/ca6a9363a4af62e467afb70d5fb1e0b3b4fa70f5/src/lib/sitemap.ts#L326&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;route definition files such as &lt;code&gt;+page.svelte&lt;/code&gt;, &lt;code&gt;+page.md&lt;/code&gt; and &lt;code&gt;+page.svx&lt;/code&gt;&lt;/a&gt; and tracks all routes you have in your project. You have to exclude or provide metadata for all route parameters for every route, otherwise it will throw error.&lt;/p&gt; &lt;p&gt;Building sitemap with &lt;code&gt;super-sitemap&lt;/code&gt; is more declarative, as it expects you to provide values for route parameters found in your routes only, and path building is managed by it. You do not need to duplicate routing configurations in code.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M22.67 47h99.67v73.67H22.67z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#007acc&quot; d=&quot;M1.5 63.91v62.5h125v-125H1.5zm100.73-5a15.56 15.56 0 0 1 7.82 4.5a20.6 20.6 0 0 1 3 4c0 .16-5.4 3.81-8.69 5.85c-.12.08-.6-.44-1.13-1.23a7.09 7.09 0 0 0-5.87-3.53c-3.79-.26-6.23 1.73-6.21 5a4.6 4.6 0 0 0 .54 2.34c.83 1.73 2.38 2.76 7.24 4.86c8.95 3.85 12.78 6.39 15.16 10c2.66 4 3.25 10.46 1.45 15.24c-2 5.2-6.9 8.73-13.83 9.9a38.3 38.3 0 0 1-9.52-.1a23 23 0 0 1-12.72-6.63c-1.15-1.27-3.39-4.58-3.25-4.82a9 9 0 0 1 1.15-.73L82 101l3.59-2.08l.75 1.11a16.8 16.8 0 0 0 4.74 4.54c4 2.1 9.46 1.81 12.16-.62a5.43 5.43 0 0 0 .69-6.92c-1-1.39-3-2.56-8.59-5c-6.45-2.78-9.23-4.5-11.77-7.24a16.5 16.5 0 0 1-3.43-6.25a25 25 0 0 1-.22-8c1.33-6.23 6-10.58 12.82-11.87a31.7 31.7 0 0 1 9.49.26zm-29.34 5.24v5.12H56.66v46.23H45.15V69.26H28.88v-5a49 49 0 0 1 .12-5.17C29.08 59 39 59 51 59h21.83z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;src/routes/sitemap.xml/+server.ts&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; as&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; sitemap&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;super-sitemap&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;RequestHandler&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123; &lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt;loadPages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; loadPosts&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;$lib/content&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; const&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; GET&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; RequestHandler&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; =&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  // you can pull metadata from wherever you like. It could be from &amp;#96;import.meta.glob&amp;#96; or from a CMS.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; posts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; loadPosts&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    pinned&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    description&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; sitemap&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;response&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    origin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;origin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    excludeRoutePatterns&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;      // you can exclude routes from the generated sitemap.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^/author.*&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^/tag.*&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;^/archive.*&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    ]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    paramValues&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;      // and you provide your metadata to super-sitemap, using route with route parameter as key, so it can substitute those routes for you in the sitemap output.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/blog/[slug]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; posts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7;font-style:italic&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;          values&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;          lastmod&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; x&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;updatedAt&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;        &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;      &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;With &lt;code&gt;super-sitemap&lt;/code&gt; covering route tracking and sitemap generation, you can focus on retrieving metadata for your routes. This separation of concerns makes the project easier to refactor and maintain down the road.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>svelte</term><scheme>https://hugosum.com/tag/svelte</scheme><label>Svelte</label></category><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><summary>In this post I want to share my experience on building sitemap in SvelteKit and introduce library that provides the best developer experience in my opinion to you.</summary><published>Thu, 09 Jan 2025 00:00:00 GMT</published><updated>Thu, 09 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/simplify-your-csharp-code-with-using-statement</id><title>Simplify your C# code with `using` statement</title><link>https://hugosum.com/blog/simplify-your-csharp-code-with-using-statement</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;As someone who started coding with Javascript and now mainly working with C#, my transition was smooth as these two languages are relatively similar syntax wise. As I read more and more C# code written by my colleagues, I realised how concise my code can be using the &lt;code&gt;using&lt;/code&gt; statement.&lt;/p&gt; &lt;p&gt;In this post I will share what is &lt;code&gt;using&lt;/code&gt; statement, when can you use it and its limitation.&lt;/p&gt; &lt;h2 id=&quot;what-is-a-using-statement-and-when-can-you-use-it&quot;&gt;&lt;a href=&quot;#what-is-a-using-statement-and-when-can-you-use-it&quot;&gt;What is a &lt;code&gt;using&lt;/code&gt; statement and when can you use it&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;The &lt;code&gt;using&lt;/code&gt; statement is a feature introduced &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/variables#94418-using-statements&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;since C# 8.0&lt;/a&gt;, and it can only be used with &lt;strong&gt;&lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/using-objects&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;objects that implemented &lt;code&gt;System.IDisposable&lt;/code&gt; or &lt;code&gt;System.IAsyncDisposable&lt;/code&gt;&lt;/a&gt;&lt;/strong&gt;. It is a syntactical sugar that will be transformed to a &lt;code&gt;try...finally&lt;/code&gt; statement during compile time, and &lt;code&gt;StreamReader.Dispose&lt;/code&gt; method will be automatically called in the &lt;code&gt;finally&lt;/code&gt; block.&lt;/p&gt; &lt;p&gt;Considering an example of creating a connection with a SQL database and executing &lt;code&gt;SELECT GETDATE()&lt;/code&gt;, using the &lt;code&gt;try...finally&lt;/code&gt; statement.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#4e994a&quot; d=&quot;M29 10.232a2.4 2.4 0 0 0-.318-1.244a2.45 2.45 0 0 0-.936-.879q-5.194-2.868-10.393-5.733a2.64 2.64 0 0 0-2.763.024c-1.378.779-8.275 4.565-10.331 5.706A2.29 2.29 0 0 0 3 10.231V21.77a2.4 2.4 0 0 0 .3 1.22a2.43 2.43 0 0 0 .954.9c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.44 2.44 0 0 0 .955-.9a2.4 2.4 0 0 0 .3-1.22V10.232&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#358230&quot; d=&quot;M28.549 23.171a2 2 0 0 0 .147-.182a2.4 2.4 0 0 0 .3-1.22V10.232a2.4 2.4 0 0 0-.318-1.244c-.036-.059-.089-.105-.13-.16L16 16Z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#1a7515&quot; d=&quot;M28.549 23.171L16 16L3.451 23.171a2.4 2.4 0 0 0 .809.72c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.4 2.4 0 0 0 .808-.719&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M19.6 18.02a4.121 4.121 0 1 1-.027-4.087l3.615-2.073A8.309 8.309 0 0 0 7.7 16a8.2 8.2 0 0 0 1.1 4.117a8.319 8.319 0 0 0 14.411-.017z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M27.67 15.271v-1.238h-1.007v-1.006h-1.239v1.006h-1.508v-1.006h-1.239v1.006h-1.008v1.238h1.006v1.513h-1.006v1.237h1.006v1.006h1.239v-1.006h1.509v1.006h1.239v-1.006h1.006v-1.237h-1v-1.513Zm-2.246 1.513h-1.508v-1.513h1.508Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; null&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;try&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;    conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Server=whatever;Database=whatever;User Id=whatever;Password=whatever;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    await&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;OpenAsync&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;    SqlCommand&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; command&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlCommand&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;SELECT GETDATE()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    object&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; command&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;ExecuteScalar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;finally&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;conn&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; !=&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; null&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        await&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;?.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;CloseAsync&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;();&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; // close connection so we don&apos;t occupy all of them in the pool&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If we rewrite that with the &lt;code&gt;using&lt;/code&gt; statement, the &lt;code&gt;finally&lt;/code&gt; block is now hidden from us. Also we don’t have to declare a variable outside the scope of &lt;code&gt;try...finally&lt;/code&gt; block, and reassign the variable. Our code is now clean and concise.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#4e994a&quot; d=&quot;M29 10.232a2.4 2.4 0 0 0-.318-1.244a2.45 2.45 0 0 0-.936-.879q-5.194-2.868-10.393-5.733a2.64 2.64 0 0 0-2.763.024c-1.378.779-8.275 4.565-10.331 5.706A2.29 2.29 0 0 0 3 10.231V21.77a2.4 2.4 0 0 0 .3 1.22a2.43 2.43 0 0 0 .954.9c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.44 2.44 0 0 0 .955-.9a2.4 2.4 0 0 0 .3-1.22V10.232&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#358230&quot; d=&quot;M28.549 23.171a2 2 0 0 0 .147-.182a2.4 2.4 0 0 0 .3-1.22V10.232a2.4 2.4 0 0 0-.318-1.244c-.036-.059-.089-.105-.13-.16L16 16Z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#1a7515&quot; d=&quot;M28.549 23.171L16 16L3.451 23.171a2.4 2.4 0 0 0 .809.72c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.4 2.4 0 0 0 .808-.719&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M19.6 18.02a4.121 4.121 0 1 1-.027-4.087l3.615-2.073A8.309 8.309 0 0 0 7.7 16a8.2 8.2 0 0 0 1.1 4.117a8.319 8.319 0 0 0 14.411-.017z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M27.67 15.271v-1.238h-1.007v-1.006h-1.239v1.006h-1.508v-1.006h-1.239v1.006h-1.008v1.238h1.006v1.513h-1.006v1.237h1.006v1.006h1.239v-1.006h1.509v1.006h1.239v-1.006h1.006v-1.237h-1v-1.513Zm-2.246 1.513h-1.508v-1.513h1.508Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Server=whatever;Database=whatever;User Id=whatever;Password=whatever;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;))&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    await&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;OpenAsync&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;    SqlCommand&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; command&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlCommand&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;SELECT GETDATE()&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    object&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; result&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; command&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;ExecuteScalar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;handling-exception-with-the-using-statement&quot;&gt;&lt;a href=&quot;#handling-exception-with-the-using-statement&quot;&gt;Handling exception with the &lt;code&gt;using&lt;/code&gt; statement&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;You might ask where is the &lt;code&gt;catch&lt;/code&gt;? Since &lt;code&gt;using&lt;/code&gt; statement is only a syntactical sugar for &lt;code&gt;try...finally&lt;/code&gt;, it &lt;strong&gt;does not catch exception for you&lt;/strong&gt;. To catch exception, you will have to put &lt;code&gt;using&lt;/code&gt; statement inside &lt;code&gt;try...catch&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#4e994a&quot; d=&quot;M29 10.232a2.4 2.4 0 0 0-.318-1.244a2.45 2.45 0 0 0-.936-.879q-5.194-2.868-10.393-5.733a2.64 2.64 0 0 0-2.763.024c-1.378.779-8.275 4.565-10.331 5.706A2.29 2.29 0 0 0 3 10.231V21.77a2.4 2.4 0 0 0 .3 1.22a2.43 2.43 0 0 0 .954.9c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.44 2.44 0 0 0 .955-.9a2.4 2.4 0 0 0 .3-1.22V10.232&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#358230&quot; d=&quot;M28.549 23.171a2 2 0 0 0 .147-.182a2.4 2.4 0 0 0 .3-1.22V10.232a2.4 2.4 0 0 0-.318-1.244c-.036-.059-.089-.105-.13-.16L16 16Z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#1a7515&quot; d=&quot;M28.549 23.171L16 16L3.451 23.171a2.4 2.4 0 0 0 .809.72c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.4 2.4 0 0 0 .808-.719&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M19.6 18.02a4.121 4.121 0 1 1-.027-4.087l3.615-2.073A8.309 8.309 0 0 0 7.7 16a8.2 8.2 0 0 0 1.1 4.117a8.319 8.319 0 0 0 14.411-.017z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M27.67 15.271v-1.238h-1.007v-1.006h-1.239v1.006h-1.508v-1.006h-1.239v1.006h-1.008v1.238h1.006v1.513h-1.006v1.237h1.006v1.006h1.239v-1.006h1.509v1.006h1.239v-1.006h1.006v-1.237h-1v-1.513Zm-2.246 1.513h-1.508v-1.513h1.508Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;try&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    using&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;connString&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;      // interact with the connection, omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Exception&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; exc&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    // handle exception&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I have also seen people putting &lt;code&gt;try...catch&lt;/code&gt; inside &lt;code&gt;using&lt;/code&gt; too, but I would not recommend this(&lt;em&gt;unless you want to lay mines for your team&lt;/em&gt;). Since the &lt;code&gt;try...catch&lt;/code&gt; is now inside the scope of &lt;code&gt;using&lt;/code&gt;, exceptions of &lt;code&gt;SqlConnection conn = new SqlConnection(connString)&lt;/code&gt; are not caught. You have to make sure that line would not throw exception if you write it this way.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 32 32&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#4e994a&quot; d=&quot;M29 10.232a2.4 2.4 0 0 0-.318-1.244a2.45 2.45 0 0 0-.936-.879q-5.194-2.868-10.393-5.733a2.64 2.64 0 0 0-2.763.024c-1.378.779-8.275 4.565-10.331 5.706A2.29 2.29 0 0 0 3 10.231V21.77a2.4 2.4 0 0 0 .3 1.22a2.43 2.43 0 0 0 .954.9c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.44 2.44 0 0 0 .955-.9a2.4 2.4 0 0 0 .3-1.22V10.232&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#358230&quot; d=&quot;M28.549 23.171a2 2 0 0 0 .147-.182a2.4 2.4 0 0 0 .3-1.22V10.232a2.4 2.4 0 0 0-.318-1.244c-.036-.059-.089-.105-.13-.16L16 16Z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#1a7515&quot; d=&quot;M28.549 23.171L16 16L3.451 23.171a2.4 2.4 0 0 0 .809.72c2.056 1.141 8.954 4.927 10.332 5.706a2.64 2.64 0 0 0 2.763.026q5.19-2.871 10.386-5.733a2.4 2.4 0 0 0 .808-.719&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M19.6 18.02a4.121 4.121 0 1 1-.027-4.087l3.615-2.073A8.309 8.309 0 0 0 7.7 16a8.2 8.2 0 0 0 1.1 4.117a8.319 8.319 0 0 0 14.411-.017z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#fff&quot; d=&quot;M27.67 15.271v-1.238h-1.007v-1.006h-1.239v1.006h-1.508v-1.006h-1.239v1.006h-1.008v1.238h1.006v1.513h-1.006v1.237h1.006v1.006h1.239v-1.006h1.509v1.006h1.239v-1.006h1.006v-1.237h-1v-1.513Zm-2.246 1.513h-1.508v-1.513h1.508Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;using&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; conn&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; SqlConnection&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;connString&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    try&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;        // interact with the connection, omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    catch&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;Exception&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; exc&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;        // handle exception&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>c</term><scheme>https://hugosum.com/tag/c</scheme><label>C#</label></category><summary>In this post I will share what is the `using` statement in C#, when can you use it and its limitation.</summary><published>Wed, 08 Jan 2025 00:00:00 GMT</published><updated>Wed, 08 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/customizing-gnome-with-nix-and-home-manager</id><title>Customizing Gnome with Nix and Home Manager</title><link>https://hugosum.com/blog/customizing-gnome-with-nix-and-home-manager</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;In this post, I will share my experience and some snippets on customizing Gnome using Nix and Home Manager.&lt;/p&gt; &lt;h2 id=&quot;remove-utilities-installed-with-gnome&quot;&gt;&lt;a href=&quot;#remove-utilities-installed-with-gnome&quot;&gt;Remove utilities installed with Gnome&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If you want to start with a minimal system, you can remove all the utilities installed alongside Gnome by default.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  services&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;gnome&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;games&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  services&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;gnome&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;core-utilities&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  environment&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;gnome&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;excludePackages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    (with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; gnome-tour&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; gnome-shell-extensions&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ]);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;gnome-terminal&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # make sure you have another terminal program ready before you set this to false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And you can install specific utilities you want through &lt;code&gt;home.packages&lt;/code&gt;, so you can keep your system as lean as possible.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  # for example, we want to have file manager and secret manager back&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  home&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;packages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    nautilus&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    seahorse&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;customizing-gnome-settings-with-dconf&quot;&gt;&lt;a href=&quot;#customizing-gnome-settings-with-dconf&quot;&gt;Customizing Gnome settings with &lt;code&gt;dconf&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;&lt;code&gt;dconf&lt;/code&gt; is the low level key-based configuration system used by Gnome, and we can interact with it with Home Manager and create a reproducible configuration of Gnome. To define &lt;code&gt;dconf&lt;/code&gt; settings with Home Manager, you can use &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-dconf.settings&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;dconf.settings&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Personally I found that &lt;a href=&quot;https://apps.gnome.org/DconfEditor/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;dconf-editor&lt;/code&gt;&lt;/a&gt; very useful for exploring settings and finding keys in &lt;code&gt;dconf&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/settings-daemon/plugins/power&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      power-button-action&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;interactive&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-ac-timeout&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-ac-type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nothing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-battery-type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nothing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/datetime&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; automatic-timezone&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;customizing-fonts-settings-in-gnome&quot;&gt;&lt;a href=&quot;#customizing-fonts-settings-in-gnome&quot;&gt;Customizing fonts settings in Gnome&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To set system font families, you can set the value of keys &lt;code&gt;org/gnome/desktop/interface/monospace-font-name&lt;/code&gt; and &lt;code&gt;org/gnome/desktop/interface/document-font-name&lt;/code&gt; in &lt;code&gt;dconf&lt;/code&gt; through &lt;code&gt;dconf.settings&lt;/code&gt;. Make sure you have installed those font packages through &lt;code&gt;home.packages&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  home&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;packages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    (&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;nerdfonts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;override&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; fonts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;0xProto&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # avoid installing everything from nerdfonts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    Inter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    noto-fonts-cjk-sans&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;    noto-fonts-cjk-serif&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/interface&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      monospace-font-name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;0xProto Nerd Font Mono&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      document-font-name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Inter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h3 id=&quot;customizing-default-font-for-applications&quot;&gt;&lt;a href=&quot;#customizing-default-font-for-applications&quot;&gt;Customizing default font for applications&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;As Gnome respects configuration of &lt;code&gt;fontconfig&lt;/code&gt;, you can use &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-fonts.fontconfig.enable&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;fonts.fontconfig&lt;/code&gt;&lt;/a&gt; for defining default font that will be used by applications(e.g. Firefox). You can define multiple fonts as default at &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-fonts.fontconfig.defaultFonts.monospace&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;fonts.fontconfig.defaultFonts.monospace&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-fonts.fontconfig.defaultFonts.sansSerif&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;fonts.fontconfig.defaultFonts.sansSerif&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-fonts.fontconfig.defaultFonts.serif&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;fonts.fontconfig.defaultFonts.serif&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-fonts.fontconfig.defaultFonts.emoji&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;fonts.fontconfig.defaultFonts.emoji&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Some applications respect &lt;code&gt;gtk&lt;/code&gt; configuration instead of &lt;code&gt;fontconfig&lt;/code&gt;, to set that we can define the font we want to use in &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-gtk.font&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;gtk.font&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  fonts&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;fontconfig&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    defaultFonts&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      monospace&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;0xProto Nerd Font Mono&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Noto Sans Mono CJK HK&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      serif&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Noto Serif CJK HK&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sansSerif&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Inter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Noto Sans CJK HK&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  gtk&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    font&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Inter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      package&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;inter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h3 id=&quot;enable-font-hinting-and-font-antialiasing&quot;&gt;&lt;a href=&quot;#enable-font-hinting-and-font-antialiasing&quot;&gt;Enable font-hinting and font-antialiasing&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;If you have a good monitor, you might notice that by default the rendering of font in Gnome is blurry and not as crisp as other systems. To enable RGBA font antialiasing and full &lt;a href=&quot;https://en.wikipedia.org/wiki/Font_hinting&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;font hinting&lt;/a&gt;, you can set &lt;code&gt;org/gnome/desktop/interface/font-hinting = &quot;full&quot;&lt;/code&gt; and &lt;code&gt;org/gnome/desktop/interface/font-antialiasing = &quot;rgba&quot;&lt;/code&gt; through &lt;code&gt;dconf.settings&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/interface&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      font-hinting&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;full&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      font-antialiasing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;rgba&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h3 id=&quot;increase-system-font-size&quot;&gt;&lt;a href=&quot;#increase-system-font-size&quot;&gt;Increase system font size&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;You can set the desired system font size alongside the name of font at &lt;code&gt;org/gnome/desktop/interface/font-name&lt;/code&gt;. The name of font should match &lt;code&gt;org/gnome/desktop/interface/document-font-name&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/interface&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      font-name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Inter 11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;removing-suspend-button-from-your-quick-setting-menu&quot;&gt;&lt;a href=&quot;#removing-suspend-button-from-your-quick-setting-menu&quot;&gt;Removing suspend button from your quick setting menu&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Since my CPU does not come with an integrated GPU, I cannot put my Nvidia GPU into offload mode during suspend. After waking it up, sometimes text on my screen with be broken. If I set &lt;code&gt;NVreg_PreserveVideoMemoryAllocations=1&lt;/code&gt; kernel parameter to &lt;a href=&quot;https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Preserve_video_memory_after_suspend&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;preserve video memory after suspend&lt;/a&gt;, I can’t even enter suspend.&lt;/p&gt; &lt;p&gt;Therefore, I decided to disable suspend completely. After searching up documentation for a few hours, I finally figured out that can only be disabled through &lt;code&gt;systemd&lt;/code&gt; configuration. No Gnome extension needed.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  systemd&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;targets&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;sleep&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  systemd&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;targets&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;suspend&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  systemd&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;targets&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;hibernate&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  systemd&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;targets&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;hybrid-sleep&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;disabling-auto-suspend&quot;&gt;&lt;a href=&quot;#disabling-auto-suspend&quot;&gt;Disabling auto suspend&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;By default, Gnome will automatically put the computer into suspend after a while. To disable that behavior, you can set &lt;code&gt;org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout = 0&lt;/code&gt; in &lt;code&gt;dconf&lt;/code&gt; through &lt;code&gt;dconf.settings&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;If you want to selectively enable auto suspend based on your power supply, &lt;code&gt;org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type&lt;/code&gt; and &lt;code&gt;org/gnome/settings-daemon/plugins/power/sleep-inactive-battery-type&lt;/code&gt; might be useful to you.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/settings-daemon/plugins/power&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      power-button-action&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;interactive&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-ac-timeout&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-ac-type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nothing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      sleep-inactive-battery-type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nothing&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;customizing-mouse-speed-and-profile&quot;&gt;&lt;a href=&quot;#customizing-mouse-speed-and-profile&quot;&gt;Customizing mouse speed and profile&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If you want to game on Gnome, mouse acceleration is definitely something you want to disable. To tweak mouse speed and profile, you can set &lt;code&gt;org/gnome/desktop/peripherals/mouse/accel-profile&lt;/code&gt; and &lt;code&gt;org/gnome/desktop/peripherals/mouse/speed&lt;/code&gt; in &lt;code&gt;dconf&lt;/code&gt; through &lt;code&gt;dconf.settings&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/peripherals/mouse&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      accel-profile&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;flat&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      speed&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;customizing-wallpapers&quot;&gt;&lt;a href=&quot;#customizing-wallpapers&quot;&gt;Customizing wallpapers&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;If you want to set your own wallpapers and change them based on light and dark mode, you can set &lt;code&gt;org/gnome/desktop/background/picture-uri&lt;/code&gt; and &lt;code&gt;org/gnome/desktop/background/picture-uri-dark&lt;/code&gt; in &lt;code&gt;dconf&lt;/code&gt; through &lt;code&gt;dconf.settings&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;gnome.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  dconf&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;org/gnome/desktop/background&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      picture-uri&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;file:///home/foobar/whereever-you-store-your-wallpapers/example.jpg&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      picture-uri-dark&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;file:///home/foobar/whereever-you-store-your-wallpapers/example-dark.jpg&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;reduce-input-latency-for-gaming&quot;&gt;&lt;a href=&quot;#reduce-input-latency-for-gaming&quot;&gt;Reduce input latency for gaming&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;You can &lt;a href=&quot;/blog/reduce-input-lag-for-gaming-on-gnome&quot;&gt;enable variable refresh rate (VRR) through &lt;code&gt;dconf.settings&lt;/code&gt;&lt;/a&gt; to reduce input latency. This experimental feature is only available since Gnome version 46.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><category><term>home-manager</term><scheme>https://hugosum.com/tag/home-manager</scheme><label>Home Manager</label></category><category><term>gnome</term><scheme>https://hugosum.com/tag/gnome</scheme><label>Gnome</label></category><summary>In this post, I will share my experience and some snippets on customizing Gnome using Nix and Home Manager.</summary><published>Mon, 06 Jan 2025 00:00:00 GMT</published><updated>Fri, 17 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/customizing-firefox-with-nix-and-home-manager</id><title>Customizing Firefox with Nix and Home Manager</title><link>https://hugosum.com/blog/customizing-firefox-with-nix-and-home-manager</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;In this post I will share my experience on customizing Firefox using Nix and Home Manager, so you can easily create reproducible and declarative configuration to manage your Firefox.&lt;/p&gt; &lt;h2 id=&quot;installing-firefox-with-home-manager&quot;&gt;&lt;a href=&quot;#installing-firefox-with-home-manager&quot;&gt;Installing Firefox with Home Manager&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Installing Firefox with Home Manager is easy on Linux, just set &lt;code&gt;programs.firefox.enable = true&lt;/code&gt; and you are good to go.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;home-manager/firefox.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;firefox&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;However, if you are using Home Manager on MacOS, you will find out that the &lt;code&gt;firefox&lt;/code&gt; package is &lt;a href=&quot;https://github.com/NixOS/nixpkgs/issues/71689&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;broken on darwin&lt;/a&gt;. Luckily, there is a &lt;a href=&quot;https://github.com/bandithedoge/nixpkgs-firefox-darwin&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nixpkgs-firefox-darwin&lt;/code&gt;&lt;/a&gt; overlay that provides a &lt;code&gt;firefox&lt;/code&gt; derivation that works on darwin. Browsers derived from &lt;code&gt;firefox&lt;/code&gt;, such as &lt;code&gt;librewolf&lt;/code&gt; and &lt;code&gt;floorp&lt;/code&gt; are also supported by this overlay.&lt;/p&gt; &lt;p&gt;To use this overlay, add this flake as an input to your flake, and pass the &lt;code&gt;nixpkgs-firefox-darwin.overlay&lt;/code&gt; to &lt;code&gt;overlays&lt;/code&gt; in the import statement of &lt;code&gt;nixpkgs&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nixos/nixpkgs/release-24.11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    home-manager&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nix-community/home-manager/release-24.11&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    home-manager&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:bandithedoge/nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; home-manager&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      inherit&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      darwinArmSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;aarch64-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      darwinArmPkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; darwinArmSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        overlays&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;          nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;overlay&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # add the overlay from the input&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      homeConfigurations&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; home-manager&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;homeManagerConfiguration&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; darwinArmPkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          modules&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; ./home-manager/firefox.nix&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;configuring-firefox-with-home-manager&quot;&gt;&lt;a href=&quot;#configuring-firefox-with-home-manager&quot;&gt;Configuring Firefox with Home Manager&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To configure options avaliable to Firefox in &lt;code&gt;about:config&lt;/code&gt; editor with Home Manager, you can create a profile with &lt;code&gt;programs.firefox.profiles.&amp;lt;name&gt;&lt;/code&gt; and define options specific to this profile at &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.profiles._name_.settings&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;programs.firefox.profiles.&amp;lt;name&gt;.settings&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;home-manager/firefox.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;firefox&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    profiles&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      admin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        id&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;admin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        isDefault&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        settings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;extensions.pocket.enabled&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;browser.toolbarbuttons.introduced.pocket-button&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I have tried to find an exhaustive list for all options in &lt;code&gt;about:config&lt;/code&gt;, but based on &lt;a href=&quot;https://support.mozilla.org/bm/questions/1358615&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;this conversation&lt;/a&gt; that seems to be non-existent.&lt;/p&gt; &lt;h2 id=&quot;installing-firefox-extensions-with-home-manager&quot;&gt;&lt;a href=&quot;#installing-firefox-extensions-with-home-manager&quot;&gt;Installing Firefox extensions with Home Manager&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Firefox extensions are not packaged in the official &lt;a href=&quot;https://github.com/NixOS/nixpkgs/&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nixpkgs&lt;/code&gt; repository&lt;/a&gt; but in the &lt;a href=&quot;https://github.com/nix-community/NUR&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nur&lt;/code&gt; repository&lt;/a&gt;. To use this repository, you have to include it as an input for a flake, and apply an overlay in the import statement of &lt;code&gt;nixpkgs&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;flake.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nur&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;github:nix-community/NUR/master&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    nur&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;follows&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; self&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; home-manager&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nur&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    let&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      inherit&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; outputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      darwinArmSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;aarch64-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      darwinArmPkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; import&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; nixpkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; darwinArmSystem&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        overlays&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;          nixpkgs-firefox-darwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;overlay&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;          nur&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;overlays&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # add the overlay from the input&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    in&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;      # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;After applying the overlay, we can then include Firefox extensions as packages at &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.profiles._name_.extensions&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;programs.firefox.profiles.&amp;lt;name&gt;.extensions&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;home-manager/firefox.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;firefox&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    profiles&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      admin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        id&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;admin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        isDefault&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        extensions&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; with&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;; &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;[&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;          # installing bitwarden and ublock-origin through nur&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;          nur&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;repos&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;rycee&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;firefox-addons&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;bitwarden&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;          nur&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;repos&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;rycee&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;firefox-addons&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;ublock-origin&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;When I was configuring my own flake, after doing the above, I thought I have done everything I need to set up extensions in Firefox. However, I found out that &lt;code&gt;programs.firefox.profiles.&amp;lt;name&gt;.extensions&lt;/code&gt; would &lt;strong&gt;only install but not enable&lt;/strong&gt; the extensions for you.&lt;/p&gt; &lt;h2 id=&quot;enable-firefox-extensions-with-policiesjson&quot;&gt;&lt;a href=&quot;#enable-firefox-extensions-with-policiesjson&quot;&gt;Enable Firefox extensions with &lt;code&gt;policies.json&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Firefox allows users to customize its functionality with &lt;a href=&quot;https://support.mozilla.org/en-US/kb/customizing-firefox-using-policiesjson&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;policies.json&lt;/code&gt;&lt;/a&gt;. Skimming through the available options, I notice that we can &lt;a href=&quot;https://mozilla.github.io/policy-templates/#extensions&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;force an extension to be enabled with &lt;code&gt;Extensions.Locked&lt;/code&gt;&lt;/a&gt;. This unobvious option is exactly what we need.&lt;/p&gt; &lt;p&gt;&lt;code&gt;Extensions.Locked&lt;/code&gt; is an array that accepts the ID of a Firefox extension. You can find out the ID of your extensions in &lt;a href=&quot;about:debugging#/runtime/this-firefox&quot;&gt;&lt;code&gt;about:debugging#/runtime/this-firefox&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Another useful option is &lt;code&gt;ExtensionSettings&lt;/code&gt;, which allow you to customize where to show the extension, for example pinning it to the navbar. There are a lot more you can do with &lt;code&gt;policies.json&lt;/code&gt;, I highly recommend you go through &lt;a href=&quot;https://mozilla.github.io/policy-templates&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;the documentation&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The corresponding Home Manager option to manage &lt;code&gt;policies.json&lt;/code&gt; is &lt;a href=&quot;https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.policies&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;programs.firefox.policies&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;home-manager/firefox.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;firefox&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    enable&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    policies&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      Extensions&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        Locked&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;          # enable both extensions&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;uBlock0@raymondhill.net&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;446900e4-71c2-419f-a6a7-df9c091e268b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # Extension ID for bitwarden&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      ExtensionSettings&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;        # pin both extensions in the navbar&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;uBlock0@raymondhill.net&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; default_area&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;navbar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;446900e4-71c2-419f-a6a7-df9c091e268b&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; default_area&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;navbar&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;defining-custom-search-engines-and-its-shortcut-alias&quot;&gt;&lt;a href=&quot;#defining-custom-search-engines-and-its-shortcut-alias&quot;&gt;Defining custom search engines and its shortcut alias&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To define custom search engines and its shortcut alias in Firefox with Home Manager, you can define them at &lt;code&gt;programs.firefox.profiles.&amp;lt;name&gt;.search.engines&lt;/code&gt;. The following is my definition that allows me to search packages in &lt;code&gt;https://search.nixos.org/packages&lt;/code&gt; after typing a shortcut alias of &lt;code&gt;@nix&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;home-manager/firefox.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; inputs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; system&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; isDarwin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  programs&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;firefox&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    profiles&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      admin&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        search&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;          engines&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;Nix Packages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;              urls&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                template&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;https://search.nixos.org/packages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                params&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                  &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                    name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;type&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                    value&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;packages&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                  &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                  &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                    name&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;query&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;                    value&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&amp;#123;searchTerms&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                  &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;              &amp;#125;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;              icon&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;                &quot;&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;$&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt;nixos-icons&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;/share/icons/hicolor/scalable/apps/nix-snowflake.svg&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;              definedAliases&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@nix&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;            &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;          &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;        &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;      &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;    &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><category><term>home-manager</term><scheme>https://hugosum.com/tag/home-manager</scheme><label>Home Manager</label></category><category><term>firefox</term><scheme>https://hugosum.com/tag/firefox</scheme><label>Firefox</label></category><summary>In this post I will share my experience on customizing Firefox using Nix and Home Manager, so you can manage your Firefox&apos;s settings, extensions and policies with a reproducible and declarative configuration.</summary><published>Sun, 05 Jan 2025 00:00:00 GMT</published><updated>Sun, 05 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/dockerize-sveltekit-with-adaptor-static-and-nginx</id><title>Dockerize SvelteKit with adapter-static and Nginx</title><link>https://hugosum.com/blog/dockerize-sveltekit-with-adaptor-static-and-nginx</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;I have encountered a few unobvious pitfalls when I create the &lt;code&gt;Dockerfile&lt;/code&gt; for this blog, which is a SvelteKit project built with &lt;a href=&quot;https://www.npmjs.com/package/@sveltejs/adapter-static&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;@sveltejs/adapter-static&lt;/code&gt;&lt;/a&gt;. For the sake of contributing back to the community, I would like to share those pitfalls and some tips with you on building a Docker image that follows best practises.&lt;/p&gt; &lt;h2 id=&quot;build-sveltekit-in-docker&quot;&gt;&lt;a href=&quot;#build-sveltekit-in-docker&quot;&gt;Build SvelteKit in Docker&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To reduce the size of the Docker image as much as possible, only the output of building SvelteKit should be included in the image. With a multi-stage build, only the final layer will be included in the image, and the rest will be discarded. By doing so, we can discard all dependencies of the building process(e.g. &lt;code&gt;node_modules&lt;/code&gt;), keeping the image slim.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3c1.2-.4 2.6-1 3.8-1.7c-1.6-2.1-2.4-4.7-2.6-7.3c-.3-3.5.4-8.1 2.8-10.8l1.2-1.4l1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4c4.3-1.3 9.3-1 13.1 1.2l1.5.9l-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8c-9.8 24.3-31 35.8-56.8 35.8c-13.3 0-25.5-5-32.5-16.8l-.1-.2l-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6V50.8h11.3V39.6h22.5V28.3h13.5z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00AADA&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7H18.6c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5 1.1-8.3 1.3h-.6c-1.3.1-2.7.1-4.2.1c-1.6 0-3.1 0-4.9-.1c6 6.8 15.4 10.8 27.2 10.8c25 0 46.2-11.1 55.5-35.9c6.7.7 13.1-1 16-6.7c-4.5-2.7-10.5-1.8-13.9-.1&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#28B8EB&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1c15.8-6.1 30.6-17.7 40.9-30.9c-.2.1-.4.1-.5.2&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#028BB8&quot; d=&quot;M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1c-1.6 0-3.2 0-4.9-.1c6 6.8 15.5 10.8 27.3 10.8c21.4 0 40-8.1 50.8-26H18.7z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#019BC6&quot; d=&quot;M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.6 1.4c8.5 4.4 20.8 4.3 34.9-1.1c8.5-3.3 16.8-8.2 24.2-14.1z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M28.4 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3-12h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M39.6 52.7h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 41.5h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3.1 10.4H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 41.5H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 30.2H72V40h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.5 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7s-1.2 2.7-2.7 2.7s-2.7-1.2-2.7-2.7s1.2-2.7 2.7-2.7&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 79.1c.2 0 .5 0 .7.1c-.2.1-.4.4-.4.7c0 .4.4.8.8.8c.3 0 .6-.2.7-.4c.1.2.1.5.1.7c0 1.1-.9 1.9-1.9 1.9c-1.1 0-1.9-.9-1.9-1.9s.8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2c-5 5.7-16.9 4-20 1.2c-3.4 4.9-23 3-24.3-.8c-4.2 5-17.3 5-21.5 0c-1.4 3.8-21 5.7-24.3.8c-3 2.8-15 4.5-20-1.2c1.1 3.5-4.9 4.5-7.6 5.2&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#BFDBE0&quot; d=&quot;M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2c-2.5.7-5.5 1.2-8.9 1.4c-1.3.1-2.7.1-4.1.1c-1.7 0-3.4 0-5.2-.1c6 6 13.6 10.7 27.5 10.8z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; d=&quot;M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3c-2.5.7-5.5 1.2-8.9 1.4c2.3 1.2 5.7 2.4 11.4 2.9&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;Dockerfile&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; node:22.12.0-slim &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; base&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;WORKDIR&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; /usr/src/app&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; base &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; install&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; mkdir -p /temp/dev&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; package.json package-lock.json /temp/dev/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; cd /temp/dev &amp;#x26;&amp;#x26; npm install --frozen-lockfile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; mkdir -p /temp/prod&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; package.json package-lock.json /temp/prod/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; cd /temp/prod &amp;#x26;&amp;#x26; npm install --frozen-lockfile --production&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; base &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; prerelease&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; --from=install /temp/dev/node_modules node_modules&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; . .&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;ENV&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; NODE_ENV=production&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;RUN&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; npm run build&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;However, this Docker image would not run and response to request yet. With &lt;code&gt;@sveltejs/adapter-static&lt;/code&gt;, the output of SvelteKit is only a set of static files, and we need to run a file server to serve them. I am going to pick &lt;code&gt;nginx&lt;/code&gt;, a popular and performant file server to serve these files.&lt;/p&gt; &lt;p&gt;As I run my Docker images in Kubernetes, I am relatively sensitive with what privileges I need to give my containers. Most people out there would probably use &lt;a href=&quot;https://hub.docker.com/_/nginx&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nginx&lt;/code&gt;&lt;/a&gt; in their Docker image, but this image &lt;strong&gt;would run &lt;code&gt;nginx&lt;/code&gt; as root&lt;/strong&gt;, and by default listen to port &lt;code&gt;80&lt;/code&gt;, which is a &lt;strong&gt;priviledged port&lt;/strong&gt;. Running a file server shouldn’t require &lt;code&gt;root&lt;/code&gt; permission at all. A better option is to use &lt;a href=&quot;https://hub.docker.com/r/nginxinc/nginx-unprivileged&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nginxinc/nginx-unprivileged&lt;/code&gt;&lt;/a&gt;, which would run &lt;code&gt;nginx&lt;/code&gt; as non-root and listen to port &lt;code&gt;8080&lt;/code&gt; by default.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3c1.2-.4 2.6-1 3.8-1.7c-1.6-2.1-2.4-4.7-2.6-7.3c-.3-3.5.4-8.1 2.8-10.8l1.2-1.4l1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4c4.3-1.3 9.3-1 13.1 1.2l1.5.9l-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8c-9.8 24.3-31 35.8-56.8 35.8c-13.3 0-25.5-5-32.5-16.8l-.1-.2l-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6V50.8h11.3V39.6h22.5V28.3h13.5z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00AADA&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7H18.6c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5 1.1-8.3 1.3h-.6c-1.3.1-2.7.1-4.2.1c-1.6 0-3.1 0-4.9-.1c6 6.8 15.4 10.8 27.2 10.8c25 0 46.2-11.1 55.5-35.9c6.7.7 13.1-1 16-6.7c-4.5-2.7-10.5-1.8-13.9-.1&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#28B8EB&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1c15.8-6.1 30.6-17.7 40.9-30.9c-.2.1-.4.1-.5.2&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#028BB8&quot; d=&quot;M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1c-1.6 0-3.2 0-4.9-.1c6 6.8 15.5 10.8 27.3 10.8c21.4 0 40-8.1 50.8-26H18.7z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#019BC6&quot; d=&quot;M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.6 1.4c8.5 4.4 20.8 4.3 34.9-1.1c8.5-3.3 16.8-8.2 24.2-14.1z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M28.4 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3-12h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M39.6 52.7h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 41.5h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3.1 10.4H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 41.5H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 30.2H72V40h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.5 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7s-1.2 2.7-2.7 2.7s-2.7-1.2-2.7-2.7s1.2-2.7 2.7-2.7&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 79.1c.2 0 .5 0 .7.1c-.2.1-.4.4-.4.7c0 .4.4.8.8.8c.3 0 .6-.2.7-.4c.1.2.1.5.1.7c0 1.1-.9 1.9-1.9 1.9c-1.1 0-1.9-.9-1.9-1.9s.8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2c-5 5.7-16.9 4-20 1.2c-3.4 4.9-23 3-24.3-.8c-4.2 5-17.3 5-21.5 0c-1.4 3.8-21 5.7-24.3.8c-3 2.8-15 4.5-20-1.2c1.1 3.5-4.9 4.5-7.6 5.2&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#BFDBE0&quot; d=&quot;M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2c-2.5.7-5.5 1.2-8.9 1.4c-1.3.1-2.7.1-4.1.1c-1.7 0-3.4 0-5.2-.1c6 6 13.6 10.7 27.5 10.8z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; d=&quot;M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3c-2.5.7-5.5 1.2-8.9 1.4c2.3 1.2 5.7 2.4 11.4 2.9&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;Dockerfile&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; nginxinc/nginx-unprivileged:1.26.2-alpine &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; release&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; --from=prerelease --chown=nginx:nginx /usr/src/app/build /usr/share/nginx/html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;EXPOSE&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; 8080&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;CMD&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;nginx&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;-g&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;daemon off;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Now if you build and run your Docker image, you should be able to serve your SvelteKit’s output.&lt;/p&gt; &lt;h2 id=&quot;handling-directories-without-indexhtml&quot;&gt;&lt;a href=&quot;#handling-directories-without-indexhtml&quot;&gt;Handling directories without &lt;code&gt;index.html&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Unless you have set &lt;code&gt;trailingSlash = &apos;always&apos;&lt;/code&gt; in your SvelteKit project, you will notice that there is only one &lt;code&gt;index.html&lt;/code&gt; in your build output. Pages with a nested path, say &lt;code&gt;/post/my-post-title&lt;/code&gt;, would be generated as &lt;code&gt;build/post/my-post-title.html&lt;/code&gt; instead of &lt;code&gt;build/post/my-post-title/index.html&lt;/code&gt;. &lt;code&gt;nginx&lt;/code&gt; will refuse serving these routes with its default configuration. To fix that, we have to provide our own configuration of &lt;code&gt;nginx&lt;/code&gt;, through the &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;First of all, create an &lt;code&gt;nginx.conf&lt;/code&gt; at the same level as your &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    listen &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;8080&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    listen &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;[::]:8080&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    root &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/usr/share/nginx/html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    server_name &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;_&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    location&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; / &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        try_files &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # handle the output of SvelteKit correctly, by using a fallback pattern.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    include &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/etc/nginx/mime.types&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # handle mime.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;And then copy it and overwrite the default configuration file of &lt;code&gt;nginx&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.8 50.8h11.3v11.5h5.7c2.6 0 5.3-.5 7.8-1.3c1.2-.4 2.6-1 3.8-1.7c-1.6-2.1-2.4-4.7-2.6-7.3c-.3-3.5.4-8.1 2.8-10.8l1.2-1.4l1.4 1.1c3.6 2.9 6.5 6.8 7.1 11.4c4.3-1.3 9.3-1 13.1 1.2l1.5.9l-.8 1.6c-3.2 6.2-9.9 8.2-16.4 7.8c-9.8 24.3-31 35.8-56.8 35.8c-13.3 0-25.5-5-32.5-16.8l-.1-.2l-1-2.1c-2.4-5.2-3.1-10.9-2.6-16.6l.2-1.7h9.6V50.8h11.3V39.6h22.5V28.3h13.5z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00AADA&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7H18.6c-.6 6.2.5 11.9 3 16.8l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5 1.1-8.3 1.3h-.6c-1.3.1-2.7.1-4.2.1c-1.6 0-3.1 0-4.9-.1c6 6.8 15.4 10.8 27.2 10.8c25 0 46.2-11.1 55.5-35.9c6.7.7 13.1-1 16-6.7c-4.5-2.7-10.5-1.8-13.9-.1&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#28B8EB&quot; d=&quot;M110.4 55.1c.8-5.9-3.6-10.5-6.4-12.7c-3.1 3.6-3.6 13.2 1.3 17.2c-2.8 2.4-8.5 4.7-14.5 4.7h-68c-.3 9.5 3.2 16.7 9.5 21c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4l-.1-.1c8.5 4.4 20.8 4.3 35-1.1c15.8-6.1 30.6-17.7 40.9-30.9c-.2.1-.4.1-.5.2&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#028BB8&quot; d=&quot;M18.7 71.8c.4 3.3 1.4 6.4 2.9 9.3l.8 1.5c.5.9 1.1 1.7 1.7 2.6c3 .2 5.7.3 8.2.2c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.5 1.4h-.4c-1.3.1-2.7.1-4.1.1c-1.6 0-3.2 0-4.9-.1c6 6.8 15.5 10.8 27.3 10.8c21.4 0 40-8.1 50.8-26H18.7z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#019BC6&quot; d=&quot;M23.5 71.8c1.3 5.8 4.3 10.4 8.8 13.5c4.9-.1 8.9-.7 12-1.7c.5-.2.9.1 1.1.5c.2.5-.1.9-.5 1.1c-.4.1-.8.3-1.3.4c-2.4.7-5.2 1.2-8.6 1.4c8.5 4.4 20.8 4.3 34.9-1.1c8.5-3.3 16.8-8.2 24.2-14.1z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M28.4 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3-12h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M39.6 52.7h9.8v9.8h-9.8zm.9.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.9 41.5h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm3.1 10.4H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 41.5H72v9.8h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#23C2EE&quot; fill-rule=&quot;evenodd&quot; d=&quot;M62.2 30.2H72V40h-9.8zm.8.8h.8v8.1H63zm1.5 0h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#00ACD3&quot; fill-rule=&quot;evenodd&quot; d=&quot;M73.5 52.7h9.8v9.8h-9.8zm.8.8h.8v8.1h-.8zm1.4 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8zm1.5 0h.8v8.1h-.8z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 78.3c1.5 0 2.7 1.2 2.7 2.7s-1.2 2.7-2.7 2.7s-2.7-1.2-2.7-2.7s1.2-2.7 2.7-2.7&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3A4D54&quot; fill-rule=&quot;evenodd&quot; d=&quot;M48.8 79.1c.2 0 .5 0 .7.1c-.2.1-.4.4-.4.7c0 .4.4.8.8.8c.3 0 .6-.2.7-.4c.1.2.1.5.1.7c0 1.1-.9 1.9-1.9 1.9c-1.1 0-1.9-.9-1.9-1.9s.8-1.9 1.9-1.9M1.1 72.8h125.4c-2.7-.7-8.6-1.6-7.7-5.2c-5 5.7-16.9 4-20 1.2c-3.4 4.9-23 3-24.3-.8c-4.2 5-17.3 5-21.5 0c-1.4 3.8-21 5.7-24.3.8c-3 2.8-15 4.5-20-1.2c1.1 3.5-4.9 4.5-7.6 5.2&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#BFDBE0&quot; d=&quot;M56 97.8c-6.7-3.2-10.3-7.5-12.4-12.2c-2.5.7-5.5 1.2-8.9 1.4c-1.3.1-2.7.1-4.1.1c-1.7 0-3.4 0-5.2-.1c6 6 13.6 10.7 27.5 10.8z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#D4EEF1&quot; d=&quot;M46.1 89.9c-.9-1.3-1.8-2.8-2.5-4.3c-2.5.7-5.5 1.2-8.9 1.4c2.3 1.2 5.7 2.4 11.4 2.9&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;Dockerfile&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; nginxinc/nginx-unprivileged:1.26.2-alpine &lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; release&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; --from=prerelease --chown=nginx:nginx /usr/src/app/build /usr/share/nginx/html&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;COPY&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; nginx.conf /etc/nginx/conf.d/default.conf # [!code ++]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;EXPOSE&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; 8080&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt;CMD&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;nginx&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;-g&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;&quot;daemon off;&quot;&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;handling-404-error&quot;&gt;&lt;a href=&quot;#handling-404-error&quot;&gt;Handling 404 error&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;Since we are using &lt;code&gt;@sveltejs/adapter-static&lt;/code&gt;, all the HTTP errors are handled during prerendering, with the exception of 404. A simple way to handle this is to update &lt;code&gt;nginx.conf&lt;/code&gt; and use the internal error page of &lt;code&gt;nginx&lt;/code&gt;.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    location&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; / &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        try_files &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.html &lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;uri&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;/ &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;=404&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # if we cannot find a match, route to 404.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;

&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    error_page &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;404&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; /404.html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # if 404, route the request to 404.html.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;

&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # return the default error page of nginx.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    location&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt; /404.html &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;        internal&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Even though SvelteKit would render &lt;code&gt;+error.svelte&lt;/code&gt; for 404 during development(i.e. &lt;code&gt;vite dev&lt;/code&gt;), it does not generate that page for you automatically in build time. To generate that, you have to specify the fallback in the adapter’s arguments.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#F0DB4F&quot; d=&quot;M1.408 1.408h125.184v125.185H1.408z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#323330&quot; d=&quot;M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981c-3.832-1.761-8.104-3.022-9.377-5.926c-.452-1.69-.512-2.642-.226-3.665c.821-3.32 4.784-4.355 7.925-3.403c2.023.678 3.938 2.237 5.093 4.724c5.402-3.498 5.391-3.475 9.163-5.879c-1.381-2.141-2.118-3.129-3.022-4.045c-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235c-5.926 6.724-4.236 18.492 2.975 23.335c7.104 5.332 17.54 6.545 18.873 11.531c1.297 6.104-4.486 8.08-10.234 7.378c-4.236-.881-6.592-3.034-9.139-6.949c-4.688 2.713-4.688 2.713-9.508 5.485c1.143 2.499 2.344 3.63 4.26 5.795c9.068 9.198 31.76 8.746 35.83-5.176c.165-.478 1.261-3.666.38-8.581M69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149c-1.713 3.558-6.152 3.117-8.175 2.427c-2.059-1.012-3.106-2.451-4.319-4.485c-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901c4.462 2.678 10.459 3.499 16.731 2.059c4.082-1.189 7.604-3.652 9.448-7.401c2.666-4.915 2.094-10.864 2.07-17.444c.06-10.735.001-21.468.001-32.237&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;svelte.config.js&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/adapter-static&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;/** &lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;@type&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;import(&apos;@sveltejs/kit&apos;).Config&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;&amp;#125; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  // omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    adapter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      fallback&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;404.html&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; // this filename can be whatever you want&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;Then when you run &lt;code&gt;vite build&lt;/code&gt;, you should be able to find a &lt;code&gt;404.html&lt;/code&gt; in your build directory. To make &lt;code&gt;nginx&lt;/code&gt; route to this page whenever a 404 is encountered, you simply need to remove the route to the &lt;code&gt;internal&lt;/code&gt; error page.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    location&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#B4F9F8&quot;&gt; /404.html &lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;      internal&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff remove&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;    &amp;#125;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;serving-precompressed-assets&quot;&gt;&lt;a href=&quot;#serving-precompressed-assets&quot;&gt;Serving precompressed assets&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;To improve performance of your site, you should served your assets with compression, such as with &lt;code&gt;gzip&lt;/code&gt; or &lt;code&gt;brotli&lt;/code&gt;. &lt;code&gt;@sveltejs/adapter-static&lt;/code&gt; supports precompressing, creating compressed assets for you in the build time.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#F0DB4F&quot; d=&quot;M1.408 1.408h125.184v125.185H1.408z&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#323330&quot; d=&quot;M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981c-3.832-1.761-8.104-3.022-9.377-5.926c-.452-1.69-.512-2.642-.226-3.665c.821-3.32 4.784-4.355 7.925-3.403c2.023.678 3.938 2.237 5.093 4.724c5.402-3.498 5.391-3.475 9.163-5.879c-1.381-2.141-2.118-3.129-3.022-4.045c-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235c-5.926 6.724-4.236 18.492 2.975 23.335c7.104 5.332 17.54 6.545 18.873 11.531c1.297 6.104-4.486 8.08-10.234 7.378c-4.236-.881-6.592-3.034-9.139-6.949c-4.688 2.713-4.688 2.713-9.508 5.485c1.143 2.499 2.344 3.63 4.26 5.795c9.068 9.198 31.76 8.746 35.83-5.176c.165-.478 1.261-3.666.38-8.581M69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149c-1.713 3.558-6.152 3.117-8.175 2.427c-2.059-1.012-3.106-2.451-4.319-4.485c-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901c4.462 2.678 10.459 3.499 16.731 2.059c4.082-1.189 7.604-3.652 9.448-7.401c2.666-4.915 2.094-10.864 2.07-17.444c.06-10.735.001-21.468.001-32.237&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;svelte.config.js&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;color:#0DB9D7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; from&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &apos;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;@sveltejs/adapter-static&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&apos;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;/** &lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;@type&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; &amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#646E9C;font-style:italic&quot;&gt;import(&apos;@sveltejs/kit&apos;).Config&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;&amp;#125; */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9D7CD8;font-style:italic&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;  // omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;  kit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#73DACA&quot;&gt;    adapter&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#7AA2F7&quot;&gt; adapter&lt;/span&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;(&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#41A6B5&quot;&gt;      precompress&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;    &amp;#125;)&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;  &amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9ABDF5&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#7DCFFF&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;After precompressing your assets, you have to make &lt;code&gt;nginx&lt;/code&gt; serve these assets. Setting &lt;a href=&quot;https://nginx.org/en/docs/http/ngx_http_gzip_static_module.html&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;gzip_static&lt;/code&gt;&lt;/a&gt; will allow &lt;code&gt;nginx&lt;/code&gt; to serve &lt;code&gt;gzip&lt;/code&gt; files.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#090&quot; d=&quot;M24.5 50.5c-1.5 0-2.5 1.2-2.5 2.7v14.1l-15.9-16c-.8-.8-2.2-1-3.2-.6S1 52.1 1 53.2v20.7c0 1.5 1.5 2.7 3 2.7s3-1.2 3-2.7V59.8l16.1 16c.5.5 1.2.8 1.9.8c.3 0 .4-.1.7-.2c1-.4 1.3-1.4 1.3-2.5V53.3c0-1.5-1-2.8-2.5-2.8m19.7 11.8c-1.4 0-2.7 1.4-2.7 2.8s1.3 2.8 2.7 2.8l6.6.4l-1.5 3.7h-8.5l-4.2-7.9l4.3-8.1H50l2.1 4h5.5L54 52.1l-.8-1.1H37.6l-.7 1.2L31 62.5l-.7 1.3l.7 1.3l5.8 10.3l.8 1.6h15.1l.7-1.7l4.3-9l1.9-4.3h-4.4zM65 50.5c-1.4 0-3 1.3-3 2.7V60h6v-6.7c0-1.5-1.6-2.8-3-2.8m30.4.3c-1-.4-2.4-.2-3.1.6L76 67.4V53.3c0-1.5-1-2.7-2.5-2.7S71 51.8 71 53.3V74c0 1.1.7 2.1 1.7 2.5c.3.1.7.2 1 .2c.7 0 1.6-.3 2.1-.8l16.2-16V74c0 1.5 1 2.7 2.5 2.7S97 75.5 97 74V53.3c0-1.1-.6-2.1-1.6-2.5m21.8 12.8l8.4-8.4c1.1-1.1 1.1-2.8 0-3.8c-1.1-1.1-2.8-1.1-3.8 0l-8.4 8.4l-8.4-8.4c-1.1-1.1-2.8-1.1-3.8 0c-1.1 1.1-1.1 2.8 0 3.8l8.4 8.4l-8.4 8.4c-1.1 1.1-1.1 2.8 0 3.8c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8l8.4-8.4l8.4 8.4c.5.5 1.2.8 1.9.8s1.4-.3 1.9-.8c1.1-1.1 1.1-2.8 0-3.8zM62 73.9c0 1.4 1.5 2.7 3 2.7c1.4 0 3-1.3 3-2.7V62h-6z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;nginx.conf&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night has-diff&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;server&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;    # omitted for brevity&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line diff add&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    gzip_static &lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If you want to use &lt;code&gt;brotli&lt;/code&gt; instead for better compression, you will need to instsall &lt;a href=&quot;https://github.com/google/ngx_brotli&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;ngx_brotli&lt;/code&gt;&lt;/a&gt; module and set &lt;a href=&quot;https://github.com/google/ngx_brotli?tab=readme-ov-file#brotli_static&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;brotli_static&lt;/code&gt;&lt;/a&gt;. I didn’t go that far, but I found &lt;a href=&quot;https://github.com/KiweeEu/nginx-brotli&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;a Docker image&lt;/a&gt; with this module installed.&lt;/p&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>docker</term><scheme>https://hugosum.com/tag/docker</scheme><label>Docker</label></category><category><term>sveltekit</term><scheme>https://hugosum.com/tag/sveltekit</scheme><label>SvelteKit</label></category><category><term>svelte</term><scheme>https://hugosum.com/tag/svelte</scheme><label>Svelte</label></category><category><term>nginx</term><scheme>https://hugosum.com/tag/nginx</scheme><label>Nginx</label></category><summary>Learn essential tips and potential pitfalls for building a Docker image with best practise to deploy your SvelteKit project with @sveltejs/adapter-static and nginx.</summary><published>Fri, 03 Jan 2025 00:00:00 GMT</published><updated>Sun, 12 Jan 2025 00:00:00 GMT</updated></entry><entry><id>https://hugosum.com/blog/how-to-avoid-too-many-old-nixos-generations</id><title>How to remove old NixOS generations in your system and bootloader</title><link>https://hugosum.com/blog/how-to-avoid-too-many-old-nixos-generations</link><content>&lt;!--[--&gt;&lt;!----&gt;&lt;p&gt;I remembered running around 60 times of &lt;code&gt;nixos-rebuild switch&lt;/code&gt; to make all my hardware and Wi-Fi works in NixOS, in the beginning of my dual booting NixOS and Windows adventure. The next time when I boot, I saw all those old and imperfect generations and I had to press the Down button for 3 seconds until I reach the Windows 11 boot options… Those generations have polluted my bootloader menu and took over my disk space, which is a pain in the back side.&lt;/p&gt; &lt;p&gt;In this Nix tips, I am going to show you a few tricks to remove and avoid keeping old NixOS generations in your system and bootloader menu.&lt;/p&gt; &lt;h2 id=&quot;limit-the-number-of-generations-kept-by-nixos&quot;&gt;&lt;a href=&quot;#limit-the-number-of-generations-kept-by-nixos&quot;&gt;Limit the number of generations kept by NixOS&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;There is a NixOS configuration called &lt;a href=&quot;https://search.nixos.org/options?show=boot.loader.systemd-boot.configurationLimit&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=boot.loader.systemd-boot.configurationLimit&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;boot.loader.systemd-boot.configurationLimit&lt;/code&gt;&lt;/a&gt; for limiting the maximum number of generations to keep in your system. When the generations you have exceeded the limit, the oldest one will be removed from your boot menu and marked for garbage collection.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    boot&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;loader&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;systemd-boot&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;configurationLimit&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; 10&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # only 10 generations are kept&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;h2 id=&quot;use-nixos-rebuild-test-and-nixos-rebuild-dry-activate-for-testing-your-configuration&quot;&gt;&lt;a href=&quot;#use-nixos-rebuild-test-and-nixos-rebuild-dry-activate-for-testing-your-configuration&quot;&gt;Use &lt;code&gt;nixos-rebuild test&lt;/code&gt; and &lt;code&gt;nixos-rebuild dry-activate&lt;/code&gt; for testing your configuration&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;&lt;code&gt;nixos-rebuild switch&lt;/code&gt; should be the first command you came across when you start your NixOS, but you should not abuse this command for just experimenting configuration. By itself, this command would build, activate and store a generation in the bootloader menu. Using this for testing, you will easily pollute your bootloader menu.&lt;/p&gt; &lt;p&gt;Unlike &lt;code&gt;nixos-rebuild switch&lt;/code&gt;, &lt;code&gt;nixos-rebuild test&lt;/code&gt; would only build and activate a new generation based on your current configuration, and it would not add this generation to the bootloader menu. This is really useful if you just want to try out a new configuration.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are not using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; test&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; test&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --flake&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; .#replaceMeWithYourSystemName&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --use-remote-sudo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If you just want to verify if your current configuration would build without error, you can use &lt;code&gt;nixos-rebuild dry-activate&lt;/code&gt;. This command would only build your configuration, but it would not activate or store it in the bootloader menu. On top of that, it would show what changes would be made comparing with the current one, if this generation is activated.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are not using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; dry-activate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; dry-activate&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --flake&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; .#replaceMeWithYourSystemName&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --use-remote-sudo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;I highly recommend you to check out the &lt;a href=&quot;https://nixos.wiki/wiki/Nixos-rebuild&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;doc of &lt;code&gt;nixos-rebuild&lt;/code&gt;&lt;/a&gt;, and discover other available arguments.&lt;/p&gt; &lt;h2 id=&quot;periodically-clean-up-old-generations&quot;&gt;&lt;a href=&quot;#periodically-clean-up-old-generations&quot;&gt;Periodically clean up old generations&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;NixOS provides an option called &lt;a href=&quot;https://search.nixos.org/options?show=nix.gc.automatic&amp;amp;from=0&amp;amp;size=50&amp;amp;sort=relevance&amp;amp;type=packages&amp;amp;query=nix.gc&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;code&gt;nix.gc&lt;/code&gt;&lt;/a&gt;, allowing you to set up a &lt;code&gt;systemd&lt;/code&gt; service to automatically garbage collect old generations for you.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 128 128&quot; width=&quot;1.2em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#7EBAE4&quot; fill-rule=&quot;evenodd&quot; d=&quot;M50.732 43.771L20.525 96.428l-7.052-12.033l8.14-14.103l-16.167-.042L2 64.237l3.519-6.15l23.013.073l8.27-14.352zm2.318 42.094l60.409.003l-6.827 12.164l-16.205-.045l8.047 14.115l-3.45 6.01l-7.05.008l-11.445-20.097l-16.483-.034zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148l8.12-14.072l6.897.002l3.532 6.143l-11.57 20.024l8.213 14.386z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#5277C3&quot; fill-rule=&quot;evenodd&quot; d=&quot;m39.831 65.463l30.202 52.66l-13.88.131l-8.063-14.148l-8.12 14.072l-6.897-.002l-3.532-6.143l11.57-20.024l-8.213-14.386zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045l-8.047-14.115l3.45-6.01l7.051-.01l11.444 20.097l16.484.034zm2.357 42.216l30.207-52.658l7.052 12.034l-8.141 14.102l16.168.043L126 64.006l-3.519 6.15l-23.013-.073l-8.27 14.352z&quot; clip-rule=&quot;evenodd&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[--&gt;&lt;span class=&quot;pre-container__header__title&quot;&gt;configuration.nix&lt;/span&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; pkgs&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; lib&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; ... &amp;#125;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;  nix&lt;/span&gt;&lt;span style=&quot;color:#A9B1D6&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;gc&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &amp;#123;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    automatic&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#FF9E64&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    dates&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;*-*-* 21:00:00&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt; # conduct a GC operation every night at 2100&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#BB9AF7&quot;&gt;    options&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt; &quot;&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt;--delete-older-than 7d&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;  &amp;#125;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#89DDFF&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt; &lt;p&gt;If you can’t wait and want to get rid of all generations right away, except the latest one, you can use &lt;code&gt;nix-collect-garbage&lt;/code&gt; and &lt;code&gt;nixos-rebuild boot&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;Remember you &lt;strong&gt;have to run &lt;code&gt;nix-collect-garbage&lt;/code&gt; with &lt;code&gt;sudo&lt;/code&gt; or as &lt;code&gt;root&lt;/code&gt;&lt;/strong&gt;, otherwise the old generations would not be removed, yet the command would still exit without error.&lt;/p&gt; &lt;div style=&quot;background-color: #1a1b26;&quot; class=&quot;pre-container&quot;&gt;&lt;div class=&quot;pre-container__header&quot;&gt;&lt;!--[--&gt;&lt;span class=&quot;pre-container__header__icon&quot;&gt;&lt;svg viewBox=&quot;0 0 224 256&quot; width=&quot;1.06em&quot; height=&quot;1.2em&quot;&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M207.953 52.162L127.317 4.287a30.37 30.37 0 0 0-31.114 0L15.55 52.162A32.17 32.17 0 0 0 0 79.869v95.734a32.17 32.17 0 0 0 15.55 27.691l80.636 47.859a30.39 30.39 0 0 0 31.115 0l80.636-47.859a32.17 32.17 0 0 0 15.566-27.707V79.869a32.17 32.17 0 0 0-15.55-27.707&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#2F3A3E&quot; d=&quot;m208.412 52.277l-80.814-47.98a30.44 30.44 0 0 0-31.184 0l-80.83 47.98A32.24 32.24 0 0 0 0 80.045v95.945a32.24 32.24 0 0 0 15.584 27.752l80.814 47.964a30.46 30.46 0 0 0 31.183 0l80.814-47.964a32.24 32.24 0 0 0 15.6-27.769V80.045a32.24 32.24 0 0 0-15.583-27.768M99.23 246.803l-80.814-47.964A26.6 26.6 0 0 1 5.6 175.989V80.046a26.59 26.59 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.43 26.43 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a25 25 0 0 1-4.24.405a25.03 25.03 0 0 1-12.768-3.512&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#3AB14A&quot; d=&quot;m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.62 1.62 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55&quot;&gt;&lt;/path&gt;&lt;path fill=&quot;#FFF&quot; d=&quot;M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.9 12.9 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.65 2.65 0 0 1-.694 1.227a1.6 1.6 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.24 10.24 0 0 0-7.444 1.194a9.35 9.35 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.52 2.52 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292q.174-.166.388-.275a.8.8 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.17 11.17 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.03 25.03 0 0 1 9.462-19.15l-.29-7.04a2.5 2.5 0 0 1 1.178-2.13z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;&lt;!----&gt;&lt;/span&gt;&lt;!--]--&gt; &lt;!--[!--&gt;&lt;!--]--&gt;&lt;/div&gt; &lt;!----&gt;&lt;pre class=&quot;shiki tokyo-night&quot; style=&quot;background-color:#1a1b26;color:#a9b1d6&quot; tabindex=&quot;0&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; nix-collect-garbage&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; -d&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are not using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; boot&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#51597D;font-style:italic&quot;&gt;# if you are using Nix Flake to manage your NixOS configuration&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#C0CAF5&quot;&gt;nixos-rebuild&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; boot&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --flake&lt;/span&gt;&lt;span style=&quot;color:#9ECE6A&quot;&gt; .#replaceMeWithYourSystemName&lt;/span&gt;&lt;span style=&quot;color:#E0AF68&quot;&gt; --use-remote-sudo&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;!----&gt;&lt;!----&gt;&lt;/div&gt;&lt;!----&gt;&lt;!----&gt;&lt;!--]--&gt;</content><author><name>Hugo Sum</name></author><category><term>nix</term><scheme>https://hugosum.com/tag/nix</scheme><label>Nix</label></category><category><term>nixos</term><scheme>https://hugosum.com/tag/nixos</scheme><label>NixOS</label></category><summary>In this Nix tips, I am going to show you a few tricks to remove and avoid keeping old NixOS generations in your system and bootloader menu.</summary><published>Wed, 01 Jan 2025 00:00:00 GMT</published><updated>Wed, 01 Jan 2025 00:00:00 GMT</updated></entry></feed>