<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Snamellit - guix</title>
      <link>https://www.snamellit.com</link>
      <description></description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://www.snamellit.com/tags/guix/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Fri, 20 Mar 2026 11:01:00 +0100</lastBuildDate>
      <item>
          <title>Install GUIX on Macbook 12</title>
          <pubDate>Fri, 20 Mar 2026 11:01:00 +0100</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/20260320t110150-install-guix-on-macbook-12-guix-linux-sysadmin/</link>
          <guid>https://www.snamellit.com/posts/20260320t110150-install-guix-on-macbook-12-guix-linux-sysadmin/</guid>
          <description xml:base="https://www.snamellit.com/posts/20260320t110150-install-guix-on-macbook-12-guix-linux-sysadmin/">&lt;h2 id=&quot;motivation&quot;&gt;Motivation&lt;&#x2F;h2&gt;
&lt;p&gt;I have an old Intel macbook 12 of begin 2016, one of the so-called
&quot;Retina Macbooks&quot;. It is an ideal couch device but far too slow to run
modern OS-X, provided you wanted to run that to begin with.&lt;&#x2F;p&gt;
&lt;p&gt;I wanted to revive this machine to avoid lugging the BIG laptop,
especially for the friday SystemCrafters stream in my comfy chair in
the living.&lt;&#x2F;p&gt;
&lt;p&gt;I saw some experience reports with Ubuntu, which worked, but then I
never used it because Ubuntu is, well it is Ok, there is nothing wrong
with it... Gnome works fine, KDE worked fine, it is just all different
from my usual Arch&#x2F;Guix machines for little added benefit.&lt;&#x2F;p&gt;
&lt;p&gt;Because I was curious about immutable distros and leveraging
containers like toolbox&#x2F;flatpak I installed Fedora Silverblue. Again
it is fine, Gnome is really luxurious on this machine. It all works
well, but again different. Distributing the software between immutable
host (which you have to reboot to make packages appear  after
install), flatpaks and toolbox containers works fine again, but
inevitably causes friction when crossing the domains,
e.g. Emacs. Nothing insurmountable. Also I am not impresssed by
toolbox, it is simple, but it does nothing that distrobox does not
seem to do better, while being less tied to the OS. I am not a fan of
the dev container workflow, and Fedora Silverblue didn&#x27;t sell it to
me. Again in large deployments the balance might be different.&lt;&#x2F;p&gt;
&lt;p&gt;AFAICT Guix offers (almost) the same immutability features and
drawbacks but less pronounced. i.e. you do not have to reboot to make
host software available in most cases. The diffferent profiles allow
much more granular control with several half-way points to find the
right balance of reproducability and creature comfort. Of course this
is also means more opportunity to let it run out of control and create
a confusing mess. In any case I can leverage the GUIX configuration of
my servers and big laptop and ensure a consistent experience if I can
get it on the lil&#x27; macbook and liberate it to fight another day.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;installation-process&quot;&gt;Installation Process&lt;&#x2F;h2&gt;
&lt;p&gt;Installing Ubuntu and Silverblue learned me that there is nothing
specially difficult for the intel mac. It kinda just works with some
small caveats.&lt;&#x2F;p&gt;
&lt;p&gt;A quick hardware check shows a BCM4350 wireless network adapter which
is not on the open hardware list AFAIK, and since the laptop needs to
do laptop duty and has only a single USB-C port WiFi is the only way
to get something in and out of it. Intel graphics should not be a
problem. An intel soundchip. Some Apple NVMe controller (foreshadowing)&lt;&#x2F;p&gt;
&lt;p&gt;So we probably need the nonguix version to support the firmware blobs.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;creating-installation-media&quot;&gt;Creating Installation Media&lt;&#x2F;h3&gt;
&lt;p&gt;Check out on your local friendly Guix enabled device, a foreign
install is fine, checkout the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;SystemCrafters&#x2F;guix-installer&#x2F;releases&#x2F;tag&#x2F;v202503220148&quot;&gt;SystemCrafters Guix Installer Repo&lt;&#x2F;a&gt;. In
the root of the project is a script &lt;code&gt;build.iso&lt;&#x2F;code&gt;. Run it and have a
walk outside or something. It takes a while. If you have no Guix
enabled machine yet, you can download the last released version, which
is over a year old, so the first &lt;code&gt;guix pull&lt;&#x2F;code&gt; on the macbook will be
epic... .&lt;&#x2F;p&gt;
&lt;p&gt;You&#x27;ll end up with a file &lt;code&gt;guix-installer-202603162333.iso&lt;&#x2F;code&gt; with of
course a probably newer timestamp is spacetime is behaving
consistently in your locati
This can be written to a thumb drive. Ensure you check with &lt;code&gt;dmesg -w&lt;&#x2F;code&gt;
which device the USB stick uses. On insertion you&#x27;ll see&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ sudo dmesg -w
&lt;&#x2F;span&gt;&lt;span&gt;... lots of lines skipped
&lt;&#x2F;span&gt;&lt;span&gt;[308042.889695] usb 1-4.3.2: new high-speed USB device number 12 using xhci_hcd
&lt;&#x2F;span&gt;&lt;span&gt;[308043.000238] usb 1-4.3.2: New USB device found, idVendor=0781, idProduct=5572, bcdDevice= 1.00
&lt;&#x2F;span&gt;&lt;span&gt;[308043.000242] usb 1-4.3.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
&lt;&#x2F;span&gt;&lt;span&gt;[308043.000244] usb 1-4.3.2: Product: Cruzer Switch
&lt;&#x2F;span&gt;&lt;span&gt;[308043.000246] usb 1-4.3.2: Manufacturer: SanDisk
&lt;&#x2F;span&gt;&lt;span&gt;[308043.000247] usb 1-4.3.2: SerialNumber: 4C530001061011107340
&lt;&#x2F;span&gt;&lt;span&gt;[308043.038906] usb-storage 1-4.3.2:1.0: USB Mass Storage device detected
&lt;&#x2F;span&gt;&lt;span&gt;[308043.039031] scsi host2: usb-storage 1-4.3.2:1.0
&lt;&#x2F;span&gt;&lt;span&gt;[308043.039112] usbcore: registered new interface driver usb-storage
&lt;&#x2F;span&gt;&lt;span&gt;[308043.042575] usbcore: registered new interface driver uas
&lt;&#x2F;span&gt;&lt;span&gt;[308044.049756] scsi 2:0:0:0: Direct-Access     SanDisk  Cruzer Switch    1.00 PQ: 0 ANSI: 6
&lt;&#x2F;span&gt;&lt;span&gt;[308044.055625] sd 2:0:0:0: [sda] 62521344 512-byte logical blocks: (32.0 GB&#x2F;29.8 GiB)
&lt;&#x2F;span&gt;&lt;span&gt;[308044.056787] sd 2:0:0:0: [sda] Write Protect is off
&lt;&#x2F;span&gt;&lt;span&gt;[308044.056790] sd 2:0:0:0: [sda] Mode Sense: 43 00 00 00
&lt;&#x2F;span&gt;&lt;span&gt;[308044.057159] sd 2:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn&amp;#39;t support DPO or FUA
&lt;&#x2F;span&gt;&lt;span&gt;[308044.093399]  sda: sda1 sda2
&lt;&#x2F;span&gt;&lt;span&gt;[308044.093545] sd 2:0:0:0: [sda] Attached SCSI removable disk
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &#x27;[sda]&#x27; on the last lines shows that the USB is now available as
&lt;code&gt;&#x2F;dev&#x2F;sda&lt;&#x2F;code&gt;. Be careful as using your current harddisk by accident will
cause an unscheduled backup&#x2F;restore excercise. To be safe make sure
you use the data which appeared on screen when inserting the
drive. Pull it out and insert it again to be sure.&lt;&#x2F;p&gt;
&lt;p&gt;Also don&#x27;t mount&#x2F;open it if your smart desktop assistent comes asking
helpfully. It only makes things slower and more complicated.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ sudo dd if=guix-installer-202603162333.iso of=&#x2F;dev&#x2F;sda bs=1M
&lt;&#x2F;span&gt;&lt;span&gt;$ sync
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;bs=1M&lt;&#x2F;code&gt; is to speed things up otherwise it takes forever. Value is
not critical but this is easy to type and _reasonable_™.&lt;&#x2F;p&gt;
&lt;p&gt;This will probably take a &lt;span class=&quot;underline&quot;&gt;refill coffee&lt;&#x2F;span&gt; amount of time to
complete. The `sync` should ensure the buffers are written before
unplugging the device.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;installation-process&quot;&gt;Installation Process&lt;&#x2F;h3&gt;
&lt;p&gt;One of the biggest challenges to start the installation process is to
build a Jenga tower of USB dongles to ensure you can power the macbook
and insert the USB stick. This device only has a single USB-C port, it
dislikes thunderbolt docks or even many USB-C docks. I used a
Steamdeck dock. In practice I assume most of the cheap USB extender
dongles will do it, however I had to experiment before it worked.&lt;&#x2F;p&gt;
&lt;p&gt;You can probably install the OS on whatever capacity is remaining
after all this time, but I would not rely on it and I would not want
to do the crypto setup of the disks with the battery draining like a
&lt;a href=&quot;https:&#x2F;&#x2F;youtu.be&#x2F;DoQwKe0lggw&quot;&gt;James Bond Villain Death Trap&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;I installed it a few times. First without disk encryption. Worked
fine. You follow the prompts.&lt;&#x2F;p&gt;
&lt;p&gt;Then with disk encryption. Worked fine.&lt;&#x2F;p&gt;
&lt;p&gt;I choose separate volumes for &lt;code&gt;root&lt;&#x2F;code&gt; and &lt;code&gt;home&lt;&#x2F;code&gt; formatted in ext4. When encrypting the
volumes using LUKS we now get an interesting issue. During boot up we
are asked 4 times to unlock the drives. Also once we selected the
image to boot in Grub the kernel will ask to unlock the disks, but the
internal laptop keyboard does not work. This can be solved by adding a
USB keyboard to your Jenga Tower and unlock the drives. This get tired
really quickly. For installation it is not a blocker so we plod on.&lt;&#x2F;p&gt;
&lt;p&gt;Also at some point the graphical installer decide that black is the
new orange and show nothing else than that. However the manual
installer is well documented.&lt;&#x2F;p&gt;
&lt;p&gt;Also the installation process for GUIXSD is far less important than
for other distros as you can completely control the OS using `guix
system reconfigure`. So if you can boot in a terminal and get on your
network you&#x27;re golden.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;crypto-setup&quot;&gt;Crypto Setup&lt;&#x2F;h3&gt;
&lt;p&gt;I am going to forget the keyboard issue for now and deal with the
passwords. Because if that is fixed the keyboard does not matter
anymore as once the kernel is fully started it works again.&lt;&#x2F;p&gt;
&lt;p&gt;If you followed along the installer will already have created the
partitioning and LUKS encryption of the volumes. We can use a keyfile
to unlock the partitions but we have to make sure the keyfile is not
exposed on an unencrypted volume. Some people suggest a keyfile on a
USB stick but this is not very practical on this device (think Jenga
tower).&lt;&#x2F;p&gt;
&lt;p&gt;There is no way to pass secrets from Grub to the booting
kernel. However we have access to files in the initial ramdisk. The
GUIX bootloader configuration has the &lt;code&gt;extra-initrd&lt;&#x2F;code&gt; option which was
originally added for this very purpose and adding the keyfile is
explained there.&lt;&#x2F;p&gt;
&lt;p&gt;So the plan is:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;add a key from a keyfile to a slot in the LUKS partitions&lt;&#x2F;li&gt;
&lt;li&gt;wrap the keyfile in a cpio image to merge to the initial ramdisk&lt;&#x2F;li&gt;
&lt;li&gt;configure the mapped devices to use this keyfile&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4 id=&quot;add-keyfile-to-initrd&quot;&gt;add keyfile to initrd&lt;&#x2F;h4&gt;
&lt;p&gt;I created a random file&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ dd if=&#x2F;dev&#x2F;urandom of=&#x2F;keyfile.bin bs=1 count=512
&lt;&#x2F;span&gt;&lt;span&gt;$ chmod 0400 &#x2F;keyfile.bin
&lt;&#x2F;span&gt;&lt;span&gt;$ echo &#x2F;key-file.bin | cpio -oH newc &amp;gt;&#x2F;key-file.cpio
&lt;&#x2F;span&gt;&lt;span&gt;$ chmod 0000 &#x2F;keyfile.cpio
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;add the keyfile as a key to the LUKS partitions.&lt;&#x2F;p&gt;
&lt;p&gt;Update &lt;code&gt;&#x2F;etc&#x2F;config.scm&lt;&#x2F;code&gt; to add the &lt;code&gt;extra-initrd&lt;&#x2F;code&gt; option to make the file
accessible during early boot.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(bootloader (bootloader-configuration
&lt;&#x2F;span&gt;&lt;span&gt;               (bootloader grub-efi-bootloader)
&lt;&#x2F;span&gt;&lt;span&gt;               (targets &amp;#39;(&amp;quot;&#x2F;boot&#x2F;efi&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;               (keyboard-layout keyboard-layout)
&lt;&#x2F;span&gt;&lt;span&gt;	              (extra-initrd &amp;quot;&#x2F;key-file.cpio&amp;quot;)))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;tell-kernel-to-use-the-keyfile&quot;&gt;Tell kernel to use the keyfile&lt;&#x2F;h4&gt;
&lt;p&gt;To configure the kernel to use the keyfile instead of asking for a
password, we have to add the &lt;code&gt;#:key-file &quot;&#x2F;key-file.bin&quot;&lt;&#x2F;code&gt; to the luks mapping&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(mapped-devices
&lt;&#x2F;span&gt;&lt;span&gt; (list (mapped-device
&lt;&#x2F;span&gt;&lt;span&gt;        (source (uuid &amp;quot;47642581-ea45-4c53-84c8-d1baf81c70de&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;        (target &amp;quot;my-root&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;        (type luks-device-mapping)
&lt;&#x2F;span&gt;&lt;span&gt;	        (arguments &amp;#39;(#:key-file &amp;quot;&#x2F;key-file.bin&amp;quot;)))
&lt;&#x2F;span&gt;&lt;span&gt;       (mapped-device
&lt;&#x2F;span&gt;&lt;span&gt;        (source (uuid &amp;quot;f2d3ee87-7cc7-4a95-8f4c-1f6c0fa750ee&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;        (target &amp;quot;my-home&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;        (type luks-device-mapping)
&lt;&#x2F;span&gt;&lt;span&gt;	        (arguments &amp;#39;(#:key-file &amp;quot;&#x2F;key-file.bin&amp;quot;)))))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h4 id=&quot;apply-it&quot;&gt;Apply it&lt;&#x2F;h4&gt;
&lt;p&gt;run a &lt;code&gt;guix system reconfigure&lt;&#x2F;code&gt; and reboot and now you will only have to
enter 2x the password. A 50% improvement  ( or 500%, 600% according to
some world leader).&lt;&#x2F;p&gt;
&lt;p&gt;Now why does grub insist in decrypting the &lt;code&gt;&#x2F;home&lt;&#x2F;code&gt; partition?&lt;&#x2F;p&gt;
&lt;p&gt;A quick look in &lt;code&gt;&#x2F;boot&#x2F;grub&#x2F;grub.cfg&lt;&#x2F;code&gt; shows:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;➜ cat &#x2F;boot&#x2F;grub&#x2F;grub.cfg | head
&lt;&#x2F;span&gt;&lt;span&gt;# This file was generated from your Guix configuration.  Any changes
&lt;&#x2F;span&gt;&lt;span&gt;# will be lost upon reconfiguration.
&lt;&#x2F;span&gt;&lt;span&gt;insmod luks
&lt;&#x2F;span&gt;&lt;span&gt;insmod luks2
&lt;&#x2F;span&gt;&lt;span&gt;cryptomount -u 47642581ea454c5384c8d1baf81c70de
&lt;&#x2F;span&gt;&lt;span&gt;cryptomount -u f2d3ee877cc74a958f4c1f6c0fa750ee
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;# Set &amp;#39;root&amp;#39; to the partition that contains &#x2F;gnu&#x2F;store.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Ok, that explains it. But why?&lt;&#x2F;p&gt;
&lt;p&gt;The manual does not give me any hints. Looking in the source code of
the guix bootloader generator shows that it makes a list of all mapped
devices which have a valid UUID and add it to grub. It throws a
warning when a mapped device uses the regular linux devicename instead
of the UUID as grub cannot find the devices with the linux name. This
makes sense and we can abuse it to get rid of the 2nd password prompt:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(mapped-devices
&lt;&#x2F;span&gt;&lt;span&gt; (list (mapped-device
&lt;&#x2F;span&gt;&lt;span&gt;        (source (uuid &amp;quot;47642581-ea45-4c53-84c8-d1baf81c70de&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;        (target &amp;quot;my-root&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;        (type luks-device-mapping)
&lt;&#x2F;span&gt;&lt;span&gt;	  (arguments &amp;#39;(#:key-file &amp;quot;&#x2F;key-file.bin&amp;quot;)))
&lt;&#x2F;span&gt;&lt;span&gt;       (mapped-device
&lt;&#x2F;span&gt;&lt;span&gt;        ;;(source (uuid &amp;quot;f2d3ee87-7cc7-4a95-8f4c-1f6c0fa750ee&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;	  (source &amp;quot;&#x2F;dev&#x2F;nvme0n1p3&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;        (target &amp;quot;my-home&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;        (type luks-device-mapping)
&lt;&#x2F;span&gt;&lt;span&gt;	  (arguments &amp;#39;(#:key-file &amp;quot;&#x2F;key-file.bin&amp;quot;)))))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If we replace the UUID with the regular device name, it will no longer
be exported to &lt;code&gt;grub.cfg&lt;&#x2F;code&gt; and the kernel kan still find the device for
mapping it.&lt;&#x2F;p&gt;
&lt;p&gt;A quick reconfigure and reboot later confirms this. I can now remove
the keyboard from the Jenga tower, but that would be cheating.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;fixing-the-keyboard&quot;&gt;Fixing the keyboard&lt;&#x2F;h3&gt;
&lt;p&gt;Some searching in the Guix mailing list showed that &quot;hid_apple&quot; was
removed from the standard initrd somewhere in &#x27;24 because of issues
with RISCV.&lt;&#x2F;p&gt;
&lt;p&gt;That is where the &lt;code&gt;initrd-modules&lt;&#x2F;code&gt; option is for:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(operating-system
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  (initrd-modules (cons &amp;quot;hid_apple&amp;quot; %base-initrd-modules))
&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This fixes the issue. I forgot how I tested it, but it does.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;post-installation&quot;&gt;Post Installation&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;system-does-not-allow-to-login-after-sleep&quot;&gt;System does not allow to login after sleep&lt;&#x2F;h3&gt;
&lt;p&gt;Actually the problem is that the disk is still sleeping (remember the
foreshadowing when seeing the Apple NVMe device). This is not GUIX
specific as I already had to fix it in Ubuntu and Fedora. There you
add&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;echo 0 &amp;gt;&#x2F;sys&#x2F;bus&#x2F;pci&#x2F;devices&#x2F;0000\:01\:00.0&#x2F;d3cold_allowed
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;in the &lt;code&gt;crontab&lt;&#x2F;code&gt; on the &lt;code&gt;@reboot&lt;&#x2F;code&gt; event.&lt;&#x2F;p&gt;
&lt;p&gt;This syntax is not supported by the herd scheduled jobs and I did not
find an alternative and got no suggestions on the #guix IRC
channel. So I decided to make a small shepherd service for this.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;(define disk-sleep-shepherd-service
&lt;&#x2F;span&gt;&lt;span&gt;  (shepherd-service
&lt;&#x2F;span&gt;&lt;span&gt;   (provision &amp;#39;(disk-sleep))
&lt;&#x2F;span&gt;&lt;span&gt;   (documentation &amp;quot;Disallow disk to go to d3cold state to prevent crash on wake up.&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;   (one-shot? #t)
&lt;&#x2F;span&gt;&lt;span&gt;   (start #~(lambda _
&lt;&#x2F;span&gt;&lt;span&gt;	       (call-with-output-file &amp;quot;&#x2F;sys&#x2F;bus&#x2F;pci&#x2F;devices&#x2F;0000:01:00.0&#x2F;d3cold_allowed&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;		 (lambda (port) (display &amp;quot;0&amp;quot; port)))
&lt;&#x2F;span&gt;&lt;span&gt;	       #t))))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The only part I struggled with is that the &lt;code&gt;start&lt;&#x2F;code&gt; field takes a
function with a variable number of arguments. The &lt;code&gt;&#x2F;var&#x2F;log&#x2F;messages&lt;&#x2F;code&gt;
registered the error but was not very helpful. Herd did not show the
service at all until it was fixed. Comparing to other implementation
gave the needed clues.&lt;&#x2F;p&gt;
&lt;p&gt;To add this to the system:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(operating-system
&lt;&#x2F;span&gt;&lt;span&gt; ...
&lt;&#x2F;span&gt;&lt;span&gt; (services
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  (simple-service &amp;#39;disk-sleep-service shepherd-root-service-type
&lt;&#x2F;span&gt;&lt;span&gt;	  (list disk-sleep-shepherd-service))
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  ))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;sound-no-sound-from-speakers-dot&quot;&gt;Sound : no sound from speakers.&lt;&#x2F;h3&gt;
&lt;p&gt;There is no sound coming from the speakers.&lt;&#x2F;p&gt;
&lt;p&gt;There is sound coming from the headphone jack. Good enough for use in
the living.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll call this a feature, not a bug.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;things-i-would-do-differently&quot;&gt;Things I would do differently&lt;&#x2F;h2&gt;
&lt;p&gt;Basically use btrfs to have a single encrypted LUKS volume to deal with and
split the volumes in btrfs. That would also give the other goodness of
btrfs and should be well supported by grub.&lt;&#x2F;p&gt;
&lt;p&gt;But for now I&#x27;ll enjoy my new couch laptop.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Screenshot in Sway with GUIX</title>
          <pubDate>Sat, 25 Oct 2025 14:19:00 +0200</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/20251025t141904-screenshot-in-sway-with-guix-guix-linux/</link>
          <guid>https://www.snamellit.com/posts/20251025t141904-screenshot-in-sway-with-guix-guix-linux/</guid>
          <description xml:base="https://www.snamellit.com/posts/20251025t141904-screenshot-in-sway-with-guix-guix-linux/">&lt;h2 id=&quot;screenshots-in-sway-with-guix-home-manager&quot;&gt;Screenshots in Sway with Guix Home Manager&lt;&#x2F;h2&gt;
&lt;p&gt;A &lt;a href=&quot;https:&#x2F;&#x2F;kaibreucker.dev&#x2F;en&#x2F;content&#x2F;foss&#x2F;sway&#x2F;screenshots&#x2F;&quot;&gt;blog post&lt;&#x2F;a&gt; documented an elegant way to configure screenshots in
wayland using &lt;strong&gt;grim&lt;&#x2F;strong&gt; and &lt;strong&gt;grimshot&lt;&#x2F;strong&gt;. After moving my sway config to use
the &lt;strong&gt;GUIX&lt;&#x2F;strong&gt; &lt;code&gt;sway-service&lt;&#x2F;code&gt; to generate the config file Iost my configured
screenshot bindings.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;output-files&quot;&gt;Output Files&lt;&#x2F;h3&gt;
&lt;p&gt;The screenshots will be placed  in the &lt;code&gt;Pictures&#x2F;screenshots&lt;&#x2F;code&gt; folder
with the timestamp as filename.  To avoid duplication and ensure
consistency we&#x27;ll add  a variable to generate the filename&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(sway-configuration
&lt;&#x2F;span&gt;&lt;span&gt;  (variables (append %sway-default-variables
&lt;&#x2F;span&gt;&lt;span&gt;		     `((menu .  ,#~(string-append
&lt;&#x2F;span&gt;&lt;span&gt;                                    #$fuzzel
&lt;&#x2F;span&gt;&lt;span&gt;                                    &amp;quot;&#x2F;bin&#x2F;fuzzel&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;                                    &amp;quot; -w 50 -x 8 -y 8 -r 3 -b 232635ff -t A6Accdff -s A6Accdff -S 232635ff -C c792eacc -m c792eacc -f \&amp;quot;JetBrains Mono:weight=light:size=10\&amp;quot; --icon-theme=\&amp;quot;Papirus-Dark\&amp;quot; --no-exit-on-keyboard-focus-loss&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;		       (term . ,(file-append alacritty &amp;quot;&#x2F;bin&#x2F;alacritty&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;		       (screenshot_out . &amp;quot;$(xdg-user-dir PICTURES)&#x2F;screenshots&#x2F;$(date +\&amp;quot;%Y%m%d-%H%M%S\&amp;quot;).png&amp;quot;))
&lt;&#x2F;span&gt;&lt;span&gt;		     ))
&lt;&#x2F;span&gt;&lt;span&gt;  ...)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;key-bindings&quot;&gt;Key Bindings&lt;&#x2F;h3&gt;
&lt;p&gt;I often use various screenshots pasted in chat windows or Jira tickets
so the clipboard is an important destination.
Alternatively saving them to move them to a target folder for
inclusion whereverr they needed is an important secondary use-case.&lt;&#x2F;p&gt;
&lt;p&gt;We can now use the variable made previously and add the following keybindings:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;scheme&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-scheme &quot;&gt;&lt;code class=&quot;language-scheme&quot; data-lang=&quot;scheme&quot;&gt;&lt;span&gt;(sway-configuration
&lt;&#x2F;span&gt;&lt;span&gt;	    ...
&lt;&#x2F;span&gt;&lt;span&gt;	    (keybindings (append
&lt;&#x2F;span&gt;&lt;span&gt;			  `(...
&lt;&#x2F;span&gt;&lt;span&gt;			    ;; Special key to take a screenshot with grim
&lt;&#x2F;span&gt;&lt;span&gt;			    ($mod+Shift+p . &amp;quot;exec grimshot copy anything&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;			    ($mod+Shift+s . &amp;quot;exec grimshot save screen $screenshot_out&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;			    ($mod+Shift+w . &amp;quot;exec grimshot save window $screenshot_out&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;			    ($mod+Shift+a . &amp;quot;exec grimshot save area $screenshot_out&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;			    ...
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;			    )
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;deploying-the-configuration&quot;&gt;Deploying the configuration&lt;&#x2F;h2&gt;
&lt;p&gt;To activate the configuration&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;$ make home
&lt;&#x2F;span&gt;&lt;span&gt;echo Loading modules from ~&#x2F;.config&#x2F;dotfiles&#x2F;guix&#x2F;src
&lt;&#x2F;span&gt;&lt;span&gt;Loading modules from &#x2F;home&#x2F;pti&#x2F;.config&#x2F;dotfiles&#x2F;guix&#x2F;src
&lt;&#x2F;span&gt;&lt;span&gt;guix home reconfigure -L ~&#x2F;.config&#x2F;dotfiles&#x2F;guix&#x2F;channel -c 32 ~&#x2F;.config&#x2F;dotfiles&#x2F;guix&#x2F;home-config-`hostname | cut -d. -f1`.scm
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;which quickly (for some value of quick) updates the home
configuration, writing a new &lt;strong&gt;~&#x2F;.config&#x2F;sway&#x2F;config&lt;&#x2F;strong&gt; file.&lt;&#x2F;p&gt;
&lt;p&gt;When the prompt returns a quick reload of the sway config with
&lt;code&gt;$mod+Shift+c&lt;&#x2F;code&gt; and testing if the modifications are active.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;testing-it-out&quot;&gt;Testing it Out&lt;&#x2F;h2&gt;
&lt;p&gt;I opened libre office writer to paste copied screenshots and made a
mess to show the &lt;code&gt;copy anything&lt;&#x2F;code&gt; works as expected. It does, it
highlights what it understands depending on your mouse location, a
window if hovering over a window, a rectangle if you start selecting
and all the screen if you move the mouse outside all windows (i.e. the
boundary on a tiling wm). It is a bit fiddly so sometimes I select the
wrong thing, but since it only clobbers the clipboard and I can
quickly try again, this seems reasonable.&lt;&#x2F;p&gt;
&lt;p&gt;Similarly using the 3 other bindings to save different type of
screenshots.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;shell&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-shell &quot;&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span&gt;  $ ls ~&#x2F;Pictures&#x2F;screenshots&#x2F;
&lt;&#x2F;span&gt;&lt;span&gt;20251025-141106.png  20251025-145006.png  20251025-145019.png
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Cool, that made a mess in the folder and &lt;strong&gt;displaying&lt;&#x2F;strong&gt; them show that it
are actually screenshots. Cool.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Samba Adventures with Guix</title>
          <pubDate>Sat, 17 Aug 2024 00:00:00 +0200</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/20240817-samba-adventures-in-guix/</link>
          <guid>https://www.snamellit.com/posts/20240817-samba-adventures-in-guix/</guid>
          <description xml:base="https://www.snamellit.com/posts/20240817-samba-adventures-in-guix/">&lt;p&gt;Samba or CIFS file sharing is a finicky area at best, but widely used,
especially since it was heavily pushed by Microsoft in the Windows
ecosystem, This makes it widely used in corporate and NAS environments
and even for Linux file sharing.&lt;&#x2F;p&gt;
&lt;p&gt;In this post I will look at some ways to use CIFS file sharing as a
client. Personally I find hardly any uses for Samba file serving
nowadays from my compute environments, with &lt;strong&gt;git&lt;&#x2F;strong&gt;, &lt;strong&gt;ssh&lt;&#x2F;strong&gt;, &lt;strong&gt;http(s)&lt;&#x2F;strong&gt;,
databases, MQTT, file synchronization services ... it hardly ever happens that
I face a situation where I think : &quot;Hey, I wish I could serve my files
from my PC&#x2F;VPS&#x2F;VM&#x2F;... with Samba&quot;. It is such a generic non-specific
service I usually find a more opinionated data sharing
service. Actually I find the same for NFS.&lt;&#x2F;p&gt;
&lt;p&gt;That being said, it is still ubiquitous to get enterprise data and to
connect to NAS or remote hard disks.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;cifs-server-simulator&quot;&gt;CIFS Server Simulator&lt;&#x2F;h2&gt;
&lt;p&gt;In practice setting up and connecting to a CIFS server is a
frustrating experience due to a bewildering array of different
protocols, security systems, credentials, ... .&lt;&#x2F;p&gt;
&lt;p&gt;To test out accessing a Samba server without having to deal with too
many moving pieces at the same time I like to use a known fixed local
basic samba server. This enables me to get working client - server
configurations which I find easier to tweak to real life servers than
starting from scratch.&lt;&#x2F;p&gt;
&lt;p&gt;Docker hub provides preconfigured images for Samba servers which are
easy to use :&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; docker run --name test-smb -p 4139:139 --rm -p 4445:445 -v `&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;pwd&lt;&#x2F;span&gt;&lt;span&gt;`&#x2F;samples&#x2F;:&#x2F;mnt&#x2F;export --rm -d dperson&#x2F;samba -p -u &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;joe;schmoe&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; -s &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;export;&#x2F;mnt&#x2F;export&#x2F;;yes;no;no;joe;;;Test Share&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This will start a samba server and listen on ports 4139 and 4445 so it
does not clash if a server is running on the machine we&#x27;re using and
we do not need special privileges other than being in the &lt;code&gt;docker&lt;&#x2F;code&gt; group
to run &lt;strong&gt;docker&lt;&#x2F;strong&gt; as a regular user. The &lt;code&gt;-s ...&lt;&#x2F;code&gt; option configures a share
name &lt;strong&gt;export&lt;&#x2F;strong&gt; which is browsable, not readonly, not accessible by guest
users and  can only be accessed with the &lt;strong&gt;joe&lt;&#x2F;strong&gt; user account. This is to
make the experience a bit more in line with usual real world
configuration which are seldom as open as the default settings for
shares. For more details, see &lt;a href=&quot;https:&#x2F;&#x2F;hub.docker.com&#x2F;r&#x2F;dperson&#x2F;samba&quot;&gt;the github repo for the image&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Because this is not a fun command line to type I like to put them in a
&lt;strong&gt;Makefile&lt;&#x2F;strong&gt; in a folder with some support files&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; cd ...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; mkdir test-smb
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; cd test-smb
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; mkdir samples
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; echo &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;Hello, Samba&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt;samples&#x2F;hello.txt
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and then add the Makefile&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;makefile&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-makefile &quot;&gt;&lt;code class=&quot;language-makefile&quot; data-lang=&quot;makefile&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;servers-start&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span&gt; run --name test-smb -p 4139:139 --rm -p 4445:445 -v `&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;pwd&lt;&#x2F;span&gt;&lt;span&gt;`&#x2F;samples&#x2F;:&#x2F;mnt&#x2F;export --rm -d dperson&#x2F;samba -p -u &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;joe;schmoe&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; -s &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;export;&#x2F;mnt&#x2F;export&#x2F;;yes;no;no;joe;;;Test Share&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;servers-stop&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span&gt; stop test-smb
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h3 id=&quot;guix-notes-for-docker&quot;&gt;Guix Notes for Docker&lt;&#x2F;h3&gt;
&lt;p&gt;Docker  (and podman too) need some OS support to talk to the kernel to
create the namespaces to make the containers work. Even though podman
does not need a daemon to run, it still needs some &lt;strong&gt;setuid&lt;&#x2F;strong&gt; helpers. I
tend to mostly use &lt;strong&gt;docker&lt;&#x2F;strong&gt; because of habit and everyone else uses it
and tends to be better supported and documented for my use cases. In
any case I did not have any luck getting either to work in a local
&lt;code&gt;guix shell&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;To enable &lt;strong&gt;docker&lt;&#x2F;strong&gt; on Guix-SD I have the following in my system configuration.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  (use&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;modules cups desktop docker networking ssh xorg)
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;(operating&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  (users
&lt;&#x2F;span&gt;&lt;span&gt;   (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;cons&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;*
&lt;&#x2F;span&gt;&lt;span&gt;    (user&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;account
&lt;&#x2F;span&gt;&lt;span&gt;     ...
&lt;&#x2F;span&gt;&lt;span&gt;     (supplementary&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;groups
&lt;&#x2F;span&gt;&lt;span&gt;      &amp;#39;( ... &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;docker&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)))  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; enable access to docker daemon
&lt;&#x2F;span&gt;&lt;span&gt;    %base&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;user&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;accounts))
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;(packages
&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;   ...
&lt;&#x2F;span&gt;&lt;span&gt;   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; add docker command line tools
&lt;&#x2F;span&gt;&lt;span&gt;   docker
&lt;&#x2F;span&gt;&lt;span&gt;   ...
&lt;&#x2F;span&gt;&lt;span&gt;   ))))
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;(services
&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;   ...
&lt;&#x2F;span&gt;&lt;span&gt;   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; enable docker
&lt;&#x2F;span&gt;&lt;span&gt;   (service docker&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;When using Guix on a host os, the native &lt;strong&gt;docker&lt;&#x2F;strong&gt; package should work
fine.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;connecting-using-smbclient&quot;&gt;Connecting using smbclient&lt;&#x2F;h2&gt;
&lt;p&gt;Before mounting drives we need to ascertain our credentials are
accepted by the Samba server. It makes no sense proceeding trying to
mount shares if we cannot get past authentication and the overhead of
configuring those shares and the Guix configuration rebuilding really
impacts iteration speed when trying things out.&lt;&#x2F;p&gt;
&lt;p&gt;The most straightforward way to connect to a CIFS server is with the
&lt;strong&gt;smbclient&lt;&#x2F;strong&gt; tool which is part of the &lt;strong&gt;samba&lt;&#x2F;strong&gt; package:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; guix shell samba
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;test-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; smbclient -L &#x2F;&#x2F;localhost -p 4445 -U joe
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;Password&lt;&#x2F;span&gt;&lt;span&gt; for &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;WORKGROUP&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\j&lt;&#x2F;span&gt;&lt;span&gt;oe&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;Sharename&lt;&#x2F;span&gt;&lt;span&gt;       Type      Comment
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;---------&lt;&#x2F;span&gt;&lt;span&gt;       ----      -------
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;export          &lt;&#x2F;span&gt;&lt;span&gt;Disk      Test Share
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;IPC$&lt;&#x2F;span&gt;&lt;span&gt;            IPC       IPC Service (Samba Server)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;SMB1&lt;&#x2F;span&gt;&lt;span&gt; disabled&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt; --&lt;&#x2F;span&gt;&lt;span&gt; no workgroup available
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;test-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[!]&lt;&#x2F;span&gt;&lt;span&gt; via 🐃  took 4s
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; smbclient &#x2F;&#x2F;localhost&#x2F;export -p 4445 -U joe
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;Password&lt;&#x2F;span&gt;&lt;span&gt; for &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;WORKGROUP&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\j&lt;&#x2F;span&gt;&lt;span&gt;oe&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;Try &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;help&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; to get a list of possible commands.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;smb: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; ls
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;                                   D        0  Sat Aug 17 03:49:32 2024
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;..&lt;&#x2F;span&gt;&lt;span&gt;                                  D        0  Sat Aug 17 05:22:38 2024
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;hello.txt&lt;&#x2F;span&gt;&lt;span&gt;                           N       13  Sat Aug 17 03:50:27 2024
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;1912951596&lt;&#x2F;span&gt;&lt;span&gt; blocks of size 1024. 998957000 blocks available
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;smb: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;guix shell samba&lt;&#x2F;code&gt; creates a profile with the &lt;strong&gt;samba&lt;&#x2F;strong&gt; package
installed which places `smbclient` on the path.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;smbclient -L &#x2F;&#x2F;servername&lt;&#x2F;code&gt; lists the services offered by the server, in
our case &lt;strong&gt;localhost&lt;&#x2F;strong&gt; to connect to our docker instance. The &lt;code&gt;-p 4445&lt;&#x2F;code&gt;
option selects the custom port we specified on our docker
container. By default &lt;strong&gt;smbclient&lt;&#x2F;strong&gt; will use your login as uid, so we need
to override it to the user we created when starting the docker
container with &lt;code&gt;-U joe&lt;&#x2F;code&gt; .&lt;&#x2F;p&gt;
&lt;p&gt;The password is configured as &lt;code&gt;schmoe&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;We see the &lt;code&gt;export&lt;&#x2F;code&gt; folder is shared so we connect to it using
`smbclient &#x2F;&#x2F;localhost&#x2F;export -p 4445 -U joe` and can list the
contents. And of course we can upload, download and all the other
terminal goodness offered by &lt;strong&gt;smbclient&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;In practice it can be very fiddly to get the right username, password,
Workgroup or Domain, port number, SMB protocol, etc dialed in. The
obtuse messages often do not really help. The other methods make
interpreting errors even harder, with the exception of programmatic
access which is sometime surprisingly helpful in getting a connection
going.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;save-the-credentials&quot;&gt;Save the credentials&lt;&#x2F;h3&gt;
&lt;p&gt;The samba tools have a convention to save the credentials in a
&lt;strong&gt;authentication file&lt;&#x2F;strong&gt; which is supported by most tools AFAICT.&lt;&#x2F;p&gt;
&lt;p&gt;To use this create a file &lt;code&gt;.smbcredentials&lt;&#x2F;code&gt; in your home folder. Well,
it can be anything but I like that place as I typically only have my
NAS to connect to using samba and it is for my home folder, backup
folder, my Music and Movies folder and the like, i.e. stuff related to
my user account, so I find it in its place in my home folder.&lt;&#x2F;p&gt;
&lt;p&gt;In it place the &lt;code&gt;username&lt;&#x2F;code&gt;, &lt;code&gt;password&lt;&#x2F;code&gt; and &lt;code&gt;domain&lt;&#x2F;code&gt; which worked with
smbclient so they no longer need to be provided :&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;username=joe
&lt;&#x2F;span&gt;&lt;span&gt;password=schmoe
&lt;&#x2F;span&gt;&lt;span&gt;domain=WORKGROUP
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then we can use it:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; smbclient &#x2F;&#x2F;localhost&#x2F;export -p 4445 -A &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;.smbcredentials
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;Try &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;help&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; to get a list of possible commands.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;smb: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt; ls
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;                                   D        0  Sat Aug 17 03:49:32 2024
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;..&lt;&#x2F;span&gt;&lt;span&gt;                                  D        0  Sat Aug 17 12:02:13 2024
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;hello.txt&lt;&#x2F;span&gt;&lt;span&gt;                           N       13  Sat Aug 17 03:50:27 2024
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;                &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;1912951596&lt;&#x2F;span&gt;&lt;span&gt; blocks of size 1024. 998918312 blocks available
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;smb: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This save a lot of typing and we can use this file in the next stages
and avoid spreading the credentials all over the disk. I am going to
gloss over encrypting this info any further because I do not keep
nuclear (or any other for that matter) secrets on my nas.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;mounting-shares-with-mount-dot-cifs&quot;&gt;Mounting Shares with &lt;code&gt;mount.cifs&lt;&#x2F;code&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Let&#x27;s create a mount point in our test folder&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span&gt; mkdir mnt
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and then mount the share with &lt;code&gt;mount.cifs&lt;&#x2F;code&gt;.  This is part of the &lt;code&gt;cifs-utils&lt;&#x2F;code&gt; package.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;ttest-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[?]&lt;&#x2F;span&gt;&lt;span&gt; via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; guix shell cifs-utils
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;The&lt;&#x2F;span&gt;&lt;span&gt; following derivation will be built:
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;&#x2F;gnu&#x2F;store&#x2F;2x7mmyrsnsf21aing02ass82899gm2yh-profile.drv
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;building&lt;&#x2F;span&gt;&lt;span&gt; CA certificate bundle...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;listing&lt;&#x2F;span&gt;&lt;span&gt; Emacs sub-directories...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;building&lt;&#x2F;span&gt;&lt;span&gt; fonts directory...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;building&lt;&#x2F;span&gt;&lt;span&gt; directory of Info manuals...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;building&lt;&#x2F;span&gt;&lt;span&gt; profile with 1 package...
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;est-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;❮&lt;&#x2F;span&gt;&lt;span&gt; sudo mount.cifs &#x2F;&#x2F;localhost&#x2F;export mnt -o credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials,port=4445
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;test-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[?]&lt;&#x2F;span&gt;&lt;span&gt; via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; ls mnt
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;hello.txt
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;test-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[?]&lt;&#x2F;span&gt;&lt;span&gt; via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This mounts the share to the folder &lt;code&gt;mnt&lt;&#x2F;code&gt;. The &lt;code&gt;-o&lt;&#x2F;code&gt; option is used to
point to the credentials file and the port number of our docker NAS
simulator.&lt;&#x2F;p&gt;
&lt;p&gt;Checking with the regular &lt;code&gt;mount&lt;&#x2F;code&gt; command to see if it agrees we mounted
the share:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;❯&lt;&#x2F;span&gt;&lt;span&gt; sudo mount -t cifs
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;&#x2F;&#x2F;localhost&#x2F;export&lt;&#x2F;span&gt;&lt;span&gt; on &#x2F;home&#x2F;pti&#x2F;src&#x2F;test-smb&#x2F;mnt type cifs (rw,relatime,vers=3.1.1,cache=strict,username=joe,domain=WORKGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=0000:0000:0000:0000:0000:0000:0000:0001,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1)
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;test-smb&lt;&#x2F;span&gt;&lt;span&gt; on  main &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;[?]&lt;&#x2F;span&gt;&lt;span&gt; via 🐃
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;➜&lt;&#x2F;span&gt;&lt;span&gt; sudo mount &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span&gt; cifs
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;&#x2F;etc&#x2F;auto.cifs&lt;&#x2F;span&gt;&lt;span&gt; on &#x2F;nas type autofs (rw,relatime,fd=6,pgrp=1732,timeout=600,minproto=5,maxproto=5,indirect,pipe_ino=27049)
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;&#x2F;&#x2F;localhost&#x2F;export&lt;&#x2F;span&gt;&lt;span&gt; on &#x2F;home&#x2F;pti&#x2F;src&#x2F;test-smb&#x2F;mnt type cifs (rw,relatime,vers=3.1.1,cache=strict,username=joe,domain=WORKGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=0000:0000:0000:0000:0000:0000:0000:0001,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1,closetimeo=1)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Calling &lt;code&gt;mount&lt;&#x2F;code&gt; without arguments lists all mounted filesystems, however
nowadays the output is so overwhelming that I prefer to use &lt;code&gt;grep&lt;&#x2F;code&gt; to
narrow down the output to the filesystem type I am interested in. The
same thing can be achieved by specifying the filesystem type with the
&lt;code&gt;-t&lt;&#x2F;code&gt; option.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;configuring-the-mounts-in-the-operating-system-dot&quot;&gt;Configuring the mounts in the operating system.&lt;&#x2F;h2&gt;
&lt;p&gt;The &lt;code&gt;mount.cifs&lt;&#x2F;code&gt; command is fine for testing and ad-hoc use but in
practice I mostly (read 99+% of the time) want the same shares of the
NAS mounted in the same place on my system. This is where the &lt;code&gt;fstab&lt;&#x2F;code&gt;
file comes in. This file is read by the mount command at boot time and
mounts the configured filesystems.&lt;&#x2F;p&gt;
&lt;p&gt;I do not recommend mounting CIFS shares at boot time, but configuring
the shares in &lt;code&gt;fstab&lt;&#x2F;code&gt; is a good way to be able to mount them when needed
with a quick &lt;code&gt;mount -a&lt;&#x2F;code&gt; command.&lt;&#x2F;p&gt;
&lt;p&gt;On my Tuxedo system I have in the &lt;code&gt;&#x2F;etc&#x2F;fstab&lt;&#x2F;code&gt; file&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;&#x2F;nas.snamellit.com&#x2F;home &#x2F;home&#x2F;pti&#x2F;nas   cifs   rw,uid=1000,gid=100,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials   0   0
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;&#x2F;nas.snamellit.com&#x2F;public &#x2F;mnt&#x2F;public   cifs   rw,uid=1000,gid=100,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials   0   0
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;&#x2F;nas.snamellit.com&#x2F;multimedia &#x2F;mnt&#x2F;multimedia   cifs   rw,uid=1000,gid=100,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials   0   0
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The first column is the reference to the share as we&#x27;ve seen
above. Then the mount point. The 3rd column indicates it is a &lt;code&gt;cifs&lt;&#x2F;code&gt;
share, Then the options we&#x27;ve seen with smbmount. Here I have to play
with the &lt;code&gt;uid&lt;&#x2F;code&gt; and &lt;code&gt;gid&lt;&#x2F;code&gt; to align my local user and group with the
configuration on the nas. The last 2 columns are whether to include
the mounts when dumping the filesystem and doing a filesystem check
which will probably always be 0 as the CIFS server is responsible for
that.&lt;&#x2F;p&gt;
&lt;p&gt;In theory this will mount the shares at boot time, and it probably
does, however in my experience it seems they are unmounted on suspend
and not remounted after resume. Or there is some timeout. I never
investigated I must admit. I just do a quick &lt;code&gt;mount -a&lt;&#x2F;code&gt; before I need
them and this works wonders.&lt;&#x2F;p&gt;
&lt;p&gt;On Guix-SD the &lt;code&gt;file-systems&lt;&#x2F;code&gt; are specified in the &lt;code&gt;operating-system&lt;&#x2F;code&gt;
section of the system configuration :&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(operating&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt; ...
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;(file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;systems
&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;cons&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;*
&lt;&#x2F;span&gt;&lt;span&gt;  ...
&lt;&#x2F;span&gt;&lt;span&gt;  (file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt;    (device &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;&#x2F;nas.snamellit.com&#x2F;public&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (options &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;uid=1000,gid=1000,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;mnt&#x2F;public&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (type &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;cifs&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount? #f)
&lt;&#x2F;span&gt;&lt;span&gt;    (create&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point? #t))
&lt;&#x2F;span&gt;&lt;span&gt;  (file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt;    (device &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;&#x2F;nas.snamellit.com&#x2F;multimedia&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (options &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;uid=1000,gid=1000,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;mnt&#x2F;multimedia&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (type &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;cifs&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount? #f)
&lt;&#x2F;span&gt;&lt;span&gt;    (create&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point? #t))
&lt;&#x2F;span&gt;&lt;span&gt;  (file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt;    (device &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;&#x2F;nas.snamellit.com&#x2F;home&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (options &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;uid=1000,gid=1000,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;home&#x2F;pti&#x2F;nas&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (type &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;cifs&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (mount? #f)
&lt;&#x2F;span&gt;&lt;span&gt;    (create&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mount&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;point? #t))
&lt;&#x2F;span&gt;&lt;span&gt;  %base&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;systems)))
&lt;&#x2F;span&gt;&lt;span&gt; &lt;&#x2F;span&gt;&lt;span style=&quot;background-color:#bf616a;color:#d8dee9;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Which is just a straightforward translation of the &lt;strong&gt;fstab&lt;&#x2F;strong&gt; columns in
&lt;a href=&quot;https:&#x2F;&#x2F;guix.gnu.org&#x2F;manual&#x2F;devel&#x2F;en&#x2F;html_node&#x2F;File-Systems.html&quot;&gt;Guix-ese.&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;automatic-mounting-with-autofs&quot;&gt;Automatic Mounting with AutoFs&lt;&#x2F;h2&gt;
&lt;p&gt;Of course the inefficiency of having to type &lt;code&gt;mount -a&lt;&#x2F;code&gt; almost on a
weekly basis is unbearable and this inefficiency has to be addressed
even if this means we cannot expect net positive effect in the coming
millenia.&lt;&#x2F;p&gt;
&lt;p&gt;Enter &lt;code&gt;autofs&lt;&#x2F;code&gt; which is an awesome system to dynamically mount and
unmount filesystems on an as needed basis. The kernel will notice when
a mounted folder is accessed and ask the &lt;strong&gt;autofs daemon&lt;&#x2F;strong&gt; to mount the
configured mount and unmount it after some timeout occurs without any
activity.&lt;&#x2F;p&gt;
&lt;p&gt;This is transparant for the user other than a slight delay when
accessing the folder the first time when it is unmounted.&lt;&#x2F;p&gt;
&lt;p&gt;This system is very flexible at it was clearly intended for far more
ambitious use-cases than accessing your personal music library from
your nas, but that does not mean we cannot strip it down and use it
for our purposes.&lt;&#x2F;p&gt;
&lt;p&gt;What is a bit confusing is the configuration. It uses 3 different
file types to configure the system.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;&#x2F;etc&#x2F;autofs.conf&lt;&#x2F;code&gt; file which configures the daemon operating
options, like the timeouts and the location of the main &lt;strong&gt;master file&lt;&#x2F;strong&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;the master file(s), there is always a main file, but this can
delegate to directory with additional parts of the file which can be
assumed to be imported in the main file. Its main purpose is to map
a parent folder of mount points to a &lt;strong&gt;map file&lt;&#x2F;strong&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;the map files which map a subfolder in the folder from the line in
the &lt;strong&gt;master file&lt;&#x2F;strong&gt; to a mount specification which will be used when
that folder is accessed.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;example-on-the-tuxedo&quot;&gt;Example on the Tuxedo:&lt;&#x2F;h3&gt;
&lt;p&gt;On my Tuxedo (running Tuxedo OS which is an Ubuntu 22.04 derivate) I have the following configuration:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;&#x2F;etc&#x2F;autofs.conf&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;[ autofs ]
&lt;&#x2F;span&gt;&lt;span&gt;#
&lt;&#x2F;span&gt;&lt;span&gt;# master_map_name - default map name for the master map.
&lt;&#x2F;span&gt;&lt;span&gt;#
&lt;&#x2F;span&gt;&lt;span&gt;master_map_name = &#x2F;etc&#x2F;auto.master
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;so the &lt;strong&gt;master map&lt;&#x2F;strong&gt; is in the file &lt;code&gt;&#x2F;etc&#x2F;auto.master&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;&#x2F;etc&#x2F;auto.master&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;-  &#x2F;etc&#x2F;autofs.direct  -ro
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The &quot;&#x2F;-&quot; is a special case which means &quot;any&quot; directory. In this case
the folder name in the &lt;strong&gt;map file&lt;&#x2F;strong&gt; is assumed to be a fully qualified
directory name instead of a subfolder in the folder mentioned in the
first column.  In this case the &lt;strong&gt;map file&lt;&#x2F;strong&gt; is &lt;code&gt;&#x2F;etc&#x2F;autofs.direct&lt;&#x2F;code&gt; and the
default options are &lt;code&gt;-ro&lt;&#x2F;code&gt; .&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&#x2F;etc&#x2F;autofs.direct&lt;&#x2F;code&gt;:&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;&#x2F;home&#x2F;pti&#x2F;nas -fstype=cifs,rw,noperm,vers=3.0,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials    :&#x2F;&#x2F;nas.snamellit.com&#x2F;home
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
This shows that the mount point &lt;code&gt;&#x2F;home&#x2F;pti&#x2F;nas&lt;&#x2F;code&gt; will mount the share
&lt;code&gt;&#x2F;&#x2F;nas.snamellit.com&#x2F;home&lt;&#x2F;code&gt; of file system type cifs with the options
(the rest of the 2nd column) as mount options.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;example-on-the-guix-sd-desktop&quot;&gt;Example on the Guix-SD desktop&lt;&#x2F;h3&gt;
&lt;p&gt;Unfortunately there is not (yet) packaged support for an &lt;strong&gt;autofs&lt;&#x2F;strong&gt;
service-type, so we have to make it ourselves.&lt;&#x2F;p&gt;
&lt;p&gt;First we define a configuration record type for our new service:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;record&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;* &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt;autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;  autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration make&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration
&lt;&#x2F;span&gt;&lt;span&gt;  autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration?
&lt;&#x2F;span&gt;&lt;span&gt;  (pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file
&lt;&#x2F;span&gt;&lt;span&gt;            (default &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;var&#x2F;run&#x2F;autofs.pid&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;  (autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;direct autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;direct
&lt;&#x2F;span&gt;&lt;span&gt;                 (default (plain&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;autofs.direct&amp;quot; &amp;quot;&#x2F;home&#x2F;pti&#x2F;autonas -fstype=cifs,rw,noperm,vers=3.0,credentials=&#x2F;home&#x2F;pti&#x2F;.smbcredentials  :&#x2F;&#x2F;nas.snamellit.com&#x2F;home&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I should probably not put my actual configuration in the default, but
it makes my life easier at the moment and I&#x27;ll refactor it
later. (Yeah, sure...)&lt;&#x2F;p&gt;
&lt;p&gt;Since the autofs service needs some boilerplate configuration files I
generate them with an activation function:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(define (autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;activation config)
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;Return the activation GEXP to create the config files for autofs&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;with-&lt;&#x2F;span&gt;&lt;span&gt;imported&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;modules &amp;#39;((guix build utils))
&lt;&#x2F;span&gt;&lt;span&gt;                         #~(begin
&lt;&#x2F;span&gt;&lt;span&gt;                             (use&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;modules (guix build utils)
&lt;&#x2F;span&gt;&lt;span&gt;                                          (ice&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;9&lt;&#x2F;span&gt;&lt;span&gt; textual&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;ports))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;                             (define (touch file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;name)
&lt;&#x2F;span&gt;&lt;span&gt;                               (call&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-with-&lt;&#x2F;span&gt;&lt;span&gt;output&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;name (const #t)))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;                             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; &amp;#39;sshd&amp;#39; complains if the authorized-key directory and its parents
&lt;&#x2F;span&gt;&lt;span&gt;                             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; are group-writable, which rules out &#x2F;gnu&#x2F;store.  Thus we copy the
&lt;&#x2F;span&gt;&lt;span&gt;                             &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; authorized-key directory to &#x2F;etc.
&lt;&#x2F;span&gt;&lt;span&gt;                             (call&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-with-&lt;&#x2F;span&gt;&lt;span&gt;output&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;etc&#x2F;autofs.conf&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;                               (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;lambda &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span&gt;) (put&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;string f &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;[ autofs ]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;master_map_name = &#x2F;etc&#x2F;auto.master
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;timeout = 300
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)))
&lt;&#x2F;span&gt;&lt;span&gt;                             (call&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-with-&lt;&#x2F;span&gt;&lt;span&gt;output&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;etc&#x2F;auto.master&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;                               (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;lambda &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span&gt;) (put&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;string f &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;format &lt;&#x2F;span&gt;&lt;span&gt;#f &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;-  ~a -ro&lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; #$(autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;direct config)))))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;                             )))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You&#x27;ll recognize the absolutely stripped down versions of the files
mentioned above being generated. The &lt;code&gt;&#x2F;etc&#x2F;auto.master&lt;&#x2F;code&gt; file maps the
&lt;strong&gt;directfs&lt;&#x2F;strong&gt; map file to the file generated in the configuration record.&lt;&#x2F;p&gt;
&lt;p&gt;This should tie up nicely the links between the 3 files.&lt;&#x2F;p&gt;
&lt;p&gt;Then I need a &lt;strong&gt;shepherd service&lt;&#x2F;strong&gt; to start the &lt;strong&gt;autofs&lt;&#x2F;strong&gt; daemon:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(define (autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;shepherd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service config)
&lt;&#x2F;span&gt;&lt;span&gt;  (define pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file (autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file config))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;   (shepherd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service
&lt;&#x2F;span&gt;&lt;span&gt;    (provision &amp;#39;(autofs))
&lt;&#x2F;span&gt;&lt;span&gt;    (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;documentation &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;AutoFS Service.&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (requirement &amp;#39;(networking))
&lt;&#x2F;span&gt;&lt;span&gt;    (start #~(make&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;forkexec&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;constructor
&lt;&#x2F;span&gt;&lt;span&gt;              (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;               #$(file&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append&lt;&#x2F;span&gt;&lt;span&gt; autofs &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;sbin&#x2F;automount&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;-f&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; run in foreground to give shepherd more control
&lt;&#x2F;span&gt;&lt;span&gt;               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;-p&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; #$(autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file config)
&lt;&#x2F;span&gt;&lt;span&gt;               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;etc&#x2F;auto.master&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;              #:pid-file #$(autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;pid&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;file config)))
&lt;&#x2F;span&gt;&lt;span&gt;    (stop #~(make&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;kill&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;destructor))
&lt;&#x2F;span&gt;&lt;span&gt;    )))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We point it to the generated &lt;strong&gt;auto.master&lt;&#x2F;strong&gt; file from the activation
function. (I could probably refactor this to use guix instantiated
files but at this stage that extra level of indirection would only
confuse me and make debugging harder. I find jumping through 3 files
already hard enough to follow).&lt;&#x2F;p&gt;
&lt;p&gt;Then we need to put a bow around it and define an &lt;code&gt;autofs-service-type&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(define autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type
&lt;&#x2F;span&gt;&lt;span&gt;  (service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type (name &amp;#39;autofs)
&lt;&#x2F;span&gt;&lt;span&gt;                (description &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;Run the autofs daemon to automount folders on access.&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;                (extensions
&lt;&#x2F;span&gt;&lt;span&gt;                 (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;                  (service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;extension activation&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;activation)
&lt;&#x2F;span&gt;&lt;span&gt;                  (service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;extension shepherd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;root&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;shepherd&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service)))
&lt;&#x2F;span&gt;&lt;span&gt;                (compose &lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;concatenate&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;                (default&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;value (autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;configuration)))
&lt;&#x2F;span&gt;&lt;span&gt;  )
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This just extends the &lt;code&gt;activation-service-type&lt;&#x2F;code&gt; and the
&lt;code&gt;shepherd-root-service-type&lt;&#x2F;code&gt; to run our initialisation code and ensure
the &lt;strong&gt;autofs&lt;&#x2F;strong&gt; daemon gets started.&lt;&#x2F;p&gt;
&lt;p&gt;Then we can add this to our system configuration:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(operating&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system
&lt;&#x2F;span&gt;&lt;span&gt; ...
&lt;&#x2F;span&gt;&lt;span&gt; (packages
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append
&lt;&#x2F;span&gt;&lt;span&gt;   (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;    ...
&lt;&#x2F;span&gt;&lt;span&gt;    autofs)))
&lt;&#x2F;span&gt;&lt;span&gt; (services
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append
&lt;&#x2F;span&gt;&lt;span&gt;   (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list
&lt;&#x2F;span&gt;&lt;span&gt;    ...
&lt;&#x2F;span&gt;&lt;span&gt;    (service autofs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;service&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;type))
&lt;&#x2F;span&gt;&lt;span&gt;   ...)))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;i.e. add the &lt;code&gt;autofs&lt;&#x2F;code&gt; package to install the daemon and support stuff
and enable the service of type &lt;code&gt;autofs-service-type&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;&#x2F;h2&gt;
&lt;p&gt;I can now use files on my nas transparantly. I was a bit flippant on
my reasons to enable &lt;strong&gt;autofs&lt;&#x2F;strong&gt;. The real reason was that I want to keep
automatic backup copies of my forge running on an VPS somewhere on my
NAS with a cron job, which means I would not be there to run a &lt;code&gt;mount -a&lt;&#x2F;code&gt; at the time. (I now realize I could do that as part of the cron
job : 20&#x2F;20 hindsight). In any case this is a major quality of life
improvement. As a side effect, my music library now gets properly
indexed and is made available on the default music player. Apparently
I still use CIFS more than I care to admit.&lt;&#x2F;p&gt;
&lt;p&gt;The big problem with SMB&#x2F;CIFS is getting the initial connection
going. Once that is achieved and the credentials are safely stored
away in &lt;strong&gt;credentials&lt;&#x2F;strong&gt; file, they can be easily reused with a lot less
surprising things along the way.&lt;&#x2F;p&gt;
&lt;p&gt;It also pays to test things out in the smallest possible meaningful
scope, in this case &lt;strong&gt;smbclient&lt;&#x2F;strong&gt; before adding more obfuscation layers on
top of it, as that just adds more complexity, pitfalls and rabbit
holes to get lost in. By going step by step, building on previous
result I often get results faster (or at all) even if I have to do
additional steps which turn out to no longer be needed in the final
solution.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Workflows for Unix Password Store with Emacs and Shell</title>
          <pubDate>Tue, 25 Jun 2024 00:00:00 +0000</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/</link>
          <guid>https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/</guid>
          <description xml:base="https://www.snamellit.com/posts/20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin/">&lt;h1 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#orgeea54c9&quot;&gt;Managing Secrets using Pass&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org44c3160&quot;&gt;Installation&lt;&#x2F;a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org7920015&quot;&gt;GUIX&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#orgbee77ce&quot;&gt;Debian, Ubuntu et al&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#orgad61fe8&quot;&gt;Emacs Integration&lt;&#x2F;a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#orgf739a63&quot;&gt;Enable the Unix Password Store.&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org1c798ff&quot;&gt;Helper Function&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org25108ee&quot;&gt;Using in Emacs Configuration&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org849f72f&quot;&gt;Shell integration&lt;&#x2F;a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org299dd7c&quot;&gt;DirEnv integration&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org158dbf2&quot;&gt;Tips&lt;&#x2F;a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org00fffd0&quot;&gt;Entering passwords on the terminal&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;www.snamellit.com&#x2F;posts&#x2F;20240624t104859-secrets-management-using-unix-password-store-pass-linux-osx-sysadmin&#x2F;#org6ab1e11&quot;&gt;Getting fields from multi field secrets&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;a id=&quot;orgeea54c9&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;managing-secrets-using-pass&quot;&gt;Managing Secrets using Pass&lt;&#x2F;h1&gt;
&lt;p&gt;On UNIX there is a well known tool to manage secrets called
&lt;strong&gt;password-store&lt;&#x2F;strong&gt; or &lt;strong&gt;pass&lt;&#x2F;strong&gt; for short.&lt;&#x2F;p&gt;
&lt;p&gt;It is a very minimal tool, more to facilitate workflows that to do
real work, very much in the UNIX philosophy. It stores all secrets in
plain files in a folder structure. It does not care about what is in
the files and encrypts them using a GPG public key so only the owner
of the private key can decrypt them. It does offer special access to
the first line so a password can be quickly fetched and copied to the
clipboard or stdout or wherever some &lt;strong&gt;pass&lt;&#x2F;strong&gt; aware integration needs it.&lt;&#x2F;p&gt;
&lt;p&gt;Certain folders can be configured to use a different public keys to
allow pragmatic secret delegation to different systems without
exposing all secrets.&lt;&#x2F;p&gt;
&lt;p&gt;It leverages the &lt;strong&gt;gpg&lt;&#x2F;strong&gt; infrastructure for key management, distribution,
unlocking with &lt;strong&gt;pinentry&lt;&#x2F;strong&gt;, caching with &lt;strong&gt;gpg-agent&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;org44c3160&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;installation&quot;&gt;Installation&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a id=&quot;org7920015&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;guix&quot;&gt;GUIX&lt;&#x2F;h2&gt;
&lt;p&gt;Add &lt;strong&gt;password-store&lt;&#x2F;strong&gt;, &lt;strong&gt;gpg&lt;&#x2F;strong&gt; and &lt;strong&gt;pinentry&lt;&#x2F;strong&gt; to your package list.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;strong&gt;pinentry&lt;&#x2F;strong&gt; program provides a client to securely unlock your keys in
a GUI and terminal environment. There are other options to make it
better fit your environment, but this is fine for me.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;orgbee77ce&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;debian-ubuntu-et-al&quot;&gt;Debian, Ubuntu et al&lt;&#x2F;h2&gt;
&lt;p&gt;Add &lt;strong&gt;pass&lt;&#x2F;strong&gt;, &lt;strong&gt;gpg&lt;&#x2F;strong&gt;, &lt;strong&gt;gpg-agent&lt;&#x2F;strong&gt; and &lt;strong&gt;pinentry-gnome&lt;&#x2F;strong&gt; of &lt;strong&gt;pinentry-qt&lt;&#x2F;strong&gt; using&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;$ apt-get install pass gpg gpg-agent pinentry-qt
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Both the gnome and qt versions at least fall back gracefully if no
graphical environment are available.&lt;&#x2F;p&gt;
&lt;p&gt;The current selected pinentry program is provided as
&lt;strong&gt;&#x2F;usr&#x2F;bin&#x2F;pinentry&lt;&#x2F;strong&gt; and this link is managed by the usual alternatives
machinery in debian based distros.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;orgad61fe8&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;emacs-integration&quot;&gt;Emacs Integration&lt;&#x2F;h1&gt;
&lt;p&gt;Emacs &lt;strong&gt;auth-source&lt;&#x2F;strong&gt; infrastructure supports &lt;strong&gt;pass&lt;&#x2F;strong&gt; out of the box.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;orgf739a63&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;enable-the-unix-password-store&quot;&gt;Enable the Unix Password Store.&lt;&#x2F;h2&gt;
&lt;p&gt;We have to make sure the password-store is added to the
auth-sources. There is a handy function for that:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;;; enable unix password-store
&lt;&#x2F;span&gt;&lt;span&gt;(auth-source-pass-enable)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;We add that somewhere in the init.el before any secrets are needed.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;org1c798ff&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;helper-function&quot;&gt;Helper Function&lt;&#x2F;h2&gt;
&lt;p&gt;Auth-sources is a flexible system and works like a database, i.e. you
can query, browse through results and have multiple fields per secret.&lt;&#x2F;p&gt;
&lt;p&gt;Example:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(defun snam-password (host user)
&lt;&#x2F;span&gt;&lt;span&gt;  &amp;quot;Get password from the unix password store.
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;Searches the password file for a secret in the folder corresponding to
&lt;&#x2F;span&gt;&lt;span&gt;the HOST name given, which is the folder with the &amp;#39;&#x2F;&amp;#39; replaced by a &amp;#39;.&amp;#39;.
&lt;&#x2F;span&gt;&lt;span&gt;The filename in the folder corresponds to the USER argument with a
&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;.pgp&amp;#39; extension.&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;  (auth-info-password
&lt;&#x2F;span&gt;&lt;span&gt;   (car (auth-source-search
&lt;&#x2F;span&gt;&lt;span&gt;         :max 1
&lt;&#x2F;span&gt;&lt;span&gt;         :host host
&lt;&#x2F;span&gt;&lt;span&gt;         :user user))))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;`auth-source-search` returns a list of results, so we have to get the
first entry with `car`. The secret is lightly obfuscated, hence the
need to decode it with the `auth-info-password` function.&lt;&#x2F;p&gt;
&lt;p&gt;Luckily there is a function &lt;a href=&quot;help:auth-source-pass-get&quot;&gt;auth-source-pass-get&lt;&#x2F;a&gt; to get a password
from the password store which also follows the recommended conventions
for multiple fields in a pass file.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(auth-source-pass-get &amp;#39;secret &amp;quot;snamellit&#x2F;znc&amp;quot;)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The pseudo key `&#x27;secret` returns the first line of the password store
entry which contains the password, per &lt;strong&gt;pass&lt;&#x2F;strong&gt; conventions.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;org25108ee&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;using-in-emacs-configuration&quot;&gt;Using in Emacs Configuration&lt;&#x2F;h2&gt;
&lt;p&gt;For single secrets, like connecting to my &lt;strong&gt;znc&lt;&#x2F;strong&gt; IRC bouncer:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(erc-tls :id &amp;#39;znc :server &amp;quot;********&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;         :port &amp;quot;****&amp;quot; :user &amp;quot;xyz&amp;quot; :nick
&lt;&#x2F;span&gt;&lt;span&gt;         &amp;quot;foobar&amp;quot; :password (auth-source-pass-get &amp;#39;secret &amp;quot;foobar&#x2F;znc&amp;quot;)))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;For multifield secrets, like for google authentication, we can
leverage the multiple fields in the password store. Here is my
&lt;strong&gt;org-gcal&lt;&#x2F;strong&gt; configuration:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(setq org-gcal-client-id (auth-source-pass-get &amp;#39;secret &amp;quot;snamellit&#x2F;org-gcal-client&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;      org-gcal-client-secret (auth-source-pass-get &amp;quot;id&amp;quot; &amp;quot;snamellit&#x2F;org-gcal-client&amp;quot;)
&lt;&#x2F;span&gt;&lt;span&gt;      org-gcal-fetch-file-alist &amp;#39;((&amp;quot;xyz@foobar.com&amp;quot; .  &amp;quot;~&#x2F;org&#x2F;schedule.org&amp;quot;)))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;a id=&quot;org849f72f&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;shell-integration&quot;&gt;Shell integration&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a id=&quot;org299dd7c&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;direnv-integration&quot;&gt;DirEnv integration&lt;&#x2F;h2&gt;
&lt;p&gt;When developping 12-factor or similar inspired apps, the configuration
is passed using environment variables. Using &lt;strong&gt;.envrc&lt;&#x2F;strong&gt; files with
&lt;strong&gt;direnv&lt;&#x2F;strong&gt; integration in the shell is a very smooth way to work in
multiple projects.&lt;&#x2F;p&gt;
&lt;p&gt;It is of course less than ideal to have the secrets exposed in the
&lt;strong&gt;.envrc&lt;&#x2F;strong&gt; files in your project tree even if it is in the &lt;strong&gt;.gitignore&lt;&#x2F;strong&gt;
file, although that is infinitely better than having secrets end up in
the git repository.&lt;&#x2F;p&gt;
&lt;p&gt;Secrets in the &lt;strong&gt;.envrc&lt;&#x2F;strong&gt; files can be easily moved to the password store
by entering the folder. The following snippet prints the current value
to the screen and then inserts it in the password store, and verifies
it actually is entered correctly.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;$ echo $FOO_BAR_PASSWORD
&lt;&#x2F;span&gt;&lt;span&gt;$ echo $FOO_BAR_PASSWORD | pass add -e foo&#x2F;bar
&lt;&#x2F;span&gt;&lt;span&gt;$ pass foo&#x2F;bar
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and then editing the &lt;strong&gt;.envrc&lt;&#x2F;strong&gt; file from&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;FOO_BAR_PASSWORD=&amp;lt;some secret&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;to&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;FOO_BAR_PASSWORD=$(pass foo&#x2F;bar)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;After modification you&#x27;ll be asked to allow to read the new &lt;strong&gt;.envrc&lt;&#x2F;strong&gt;
file content and you can check if it still works by comparing the
password with the one printed previously.&lt;&#x2F;p&gt;
&lt;p&gt;Printing the passwords allows to fix any typos. If this are the only
copies you have of them you might rug-pull yourself. Ideally it should
be possible to quickly recreate secrets if you lose any, but reality
is often far from ideal. Echoing all these passwords is also not
ideal, but preferable over keeping a little black book of secrets. If
these passwords are coming from another password manager it is not
needed of course.&lt;&#x2F;p&gt;
&lt;p&gt;Do not forget to clear your terminal scroll back history with&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;$ clear
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;To help migration of &lt;strong&gt;.envrc&lt;&#x2F;strong&gt; files I created a bash script I stored in
&lt;strong&gt;~&#x2F;.local&#x2F;bin&#x2F;envrc-to-pass&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;#!&#x2F;bin&#x2F;bash
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;if [ &amp;quot;$#&amp;quot; -ne 2 ]; then
&lt;&#x2F;span&gt;&lt;span&gt;    echo &amp;quot;Usage: $0 &amp;lt;variable_name&amp;gt; &amp;lt;namespace&amp;gt;&amp;quot; &amp;gt;&amp;amp;2
&lt;&#x2F;span&gt;&lt;span&gt;    exit 1
&lt;&#x2F;span&gt;&lt;span&gt;fi
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;VAR_NAME=$1
&lt;&#x2F;span&gt;&lt;span&gt;SLUG=$(echo $VAR_NAME | sed &amp;#39;s&#x2F;_&#x2F;-&#x2F;g&amp;#39; | tr &amp;#39;[:upper:]&amp;#39; &amp;#39;[:lower:]&amp;#39;)
&lt;&#x2F;span&gt;&lt;span&gt;NAMESPACE=$2
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;echo &amp;quot;Moving variable $VAR_NAME to $NAMESPACE&#x2F;$SLUG in password store&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;SECRET=$(grep &amp;quot;$VAR_NAME=&amp;quot; .envrc | cut -d&amp;#39;=&amp;#39; -f2)
&lt;&#x2F;span&gt;&lt;span&gt;if (echo $SECRET | grep &amp;#39;^\$(pass.*)&amp;#39;); then
&lt;&#x2F;span&gt;&lt;span&gt;    echo &amp;quot;secret already migrated&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;else
&lt;&#x2F;span&gt;&lt;span&gt;    echo $SECRET | pass insert -e $NAMESPACE&#x2F;$SLUG
&lt;&#x2F;span&gt;&lt;span&gt;fi
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;sed -i &amp;quot;s#$VAR_NAME=.*#$VAR_NAME=\\\$(pass $NAMESPACE\&#x2F;$SLUG)#&amp;quot; .envrc
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This makes short work of migrating projects to use the password-store.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;org158dbf2&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;tips&quot;&gt;Tips&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a id=&quot;org00fffd0&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;entering-passwords-on-the-terminal&quot;&gt;Entering passwords on the terminal&lt;&#x2F;h2&gt;
&lt;p&gt;Usually invoking `pass add foobar&#x2F;baz` will ask to enter the password
and confirm it in the shell.&lt;&#x2F;p&gt;
&lt;p&gt;However when piping a secret into the password-store
with&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;echo FOO_BAR_PASSWORD | pass add foo&#x2F;bar
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;will silently fail although the man pages tell that `pass add` will
read from &lt;strong&gt;stdin&lt;&#x2F;strong&gt;. It is not clear IMO that you have to specify the &lt;strong&gt;-e&lt;&#x2F;strong&gt;
flag like :&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;echo FOO_BAR_PASSWORD | pass -e add foo&#x2F;bar
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;to suppress the confirmation and make it work as expected.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a id=&quot;org6ab1e11&quot;&gt;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;getting-fields-from-multi-field-secrets&quot;&gt;Getting fields from multi field secrets&lt;&#x2F;h2&gt;
&lt;p&gt;Often secrets come in multiple parts which are nice to be stored in a
single entry in order not to complicate the tree. The &lt;strong&gt;pass&lt;&#x2F;strong&gt;
documentation suggests:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;&amp;lt;password or main secret&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;field1: &amp;lt;some data&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;field2: &amp;lt;more data&amp;gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;the main secret is just the first line, and can have the same
structure as the other lines, if that makes more sense.&lt;&#x2F;p&gt;
&lt;p&gt;e.g. for a google integration:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;service-account: 1234567-abcdefghijklm@developer.gserviceadmin.com(some-project)
&lt;&#x2F;span&gt;&lt;span&gt;email: xyz@foobar.com
&lt;&#x2F;span&gt;&lt;span&gt;private-key: ...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In this case it is useful to &lt;span class=&quot;underline&quot;&gt;document&lt;&#x2F;span&gt; which kind of secret it is as it
could also be an api-key, or a refresh-token, or whatever part of the
authentication menagerie that Google offers.&lt;&#x2F;p&gt;
&lt;p&gt;To get these fields individually I use:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;GOOGLE_EMAIL=$(pass foo&#x2F;bar | awk &amp;#39;&#x2F;^email:&#x2F; {print $2}) 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;in emacs this syntax is supported directly and the same info can be
fetched with&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(let
&lt;&#x2F;span&gt;&lt;span&gt;    ((google-email (auth-source-pass-get &amp;quot;email&amp;quot; &amp;quot;foo&#x2F;bar&amp;quot;)))
&lt;&#x2F;span&gt;&lt;span&gt;  ... )
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
</description>
      </item>
      <item>
          <title>Terraform workflow using Guix and Emacs</title>
          <pubDate>Wed, 05 Jun 2024 00:00:00 +0000</pubDate>
          <author>Peter Tillemans</author>
          <link>https://www.snamellit.com/posts/terraform-workflow-using-guix-and-emacs/</link>
          <guid>https://www.snamellit.com/posts/terraform-workflow-using-guix-and-emacs/</guid>
          <description xml:base="https://www.snamellit.com/posts/terraform-workflow-using-guix-and-emacs/">&lt;h1 id=&quot;terraform-deployments&quot;&gt;Terraform Deployments&lt;&#x2F;h1&gt;
&lt;p&gt;Terraform allows infrastructure to be defined to deploy applications
and other solutions as code and supports a plethora of on-premise and
cloud deployment targets.&lt;&#x2F;p&gt;
&lt;p&gt;It is essentially based on building a graph of dependencies between
resources, data and modules using the terraform language.&lt;&#x2F;p&gt;
&lt;p&gt;Due to the nature of the beast these things tend to run in the CI
pipelines which makes editing these files frustrating as the edits
have to be committed, pushed, runners have to be scheduled and usually
the deploy pipeline is not the first job.&lt;&#x2F;p&gt;
&lt;p&gt;So good local tooling is needed to get fast feedback.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;terraform-tooling-on-guix&quot;&gt;Terraform tooling on GUIX&lt;&#x2F;h1&gt;
&lt;p&gt;In order to run terraform I need to first package it as it is not
available in the GUIX repositories.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;(define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;public terraform
&lt;&#x2F;span&gt;&lt;span&gt;  (package
&lt;&#x2F;span&gt;&lt;span&gt;   (name &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;snam-terraform&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;   (version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;1.8.4&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;   (source (origin
&lt;&#x2F;span&gt;&lt;span&gt;            (method url&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;fetch)
&lt;&#x2F;span&gt;&lt;span&gt;            (uri (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;releases.hashicorp.com&#x2F;terraform&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;terraform_&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;_linux_amd64.zip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;            (sha256
&lt;&#x2F;span&gt;&lt;span&gt;             (base32
&lt;&#x2F;span&gt;&lt;span&gt;	       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;1i181cmzwlrx8d40z1spilcwgnhkzwalrg8822d23sqdmrs7a5hj&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))))
&lt;&#x2F;span&gt;&lt;span&gt;   (build&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system binary&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;build&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;system)
&lt;&#x2F;span&gt;&lt;span&gt;   (supported&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;systems &amp;#39;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;x86_64-linux&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;   (arguments &amp;#39;(
&lt;&#x2F;span&gt;&lt;span&gt;      #:install-plan
&lt;&#x2F;span&gt;&lt;span&gt;      `((&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;.&amp;quot; &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;terraform&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;bin&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;      #:phases
&lt;&#x2F;span&gt;&lt;span&gt;      (modify&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;phases %standard&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;phases
&lt;&#x2F;span&gt;&lt;span&gt;		     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; this is required because standard unpack expects
&lt;&#x2F;span&gt;&lt;span&gt;		     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; the archive to contain a directory with everything inside it,
&lt;&#x2F;span&gt;&lt;span&gt;		     &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; while babashka&amp;#39;s release .tar.gz only contains the `bb` binary.
&lt;&#x2F;span&gt;&lt;span&gt;		     (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;replace&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;unpack
&lt;&#x2F;span&gt;&lt;span&gt;			      (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;lambda&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;* &lt;&#x2F;span&gt;&lt;span&gt;(#:key inputs #:allow-other-keys)
&lt;&#x2F;span&gt;&lt;span&gt;				(system&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;* &lt;&#x2F;span&gt;&lt;span&gt;(which &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;unzip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;					 (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;assoc&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;ref inputs &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;source&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;				#t)))))
&lt;&#x2F;span&gt;&lt;span&gt;   (inputs
&lt;&#x2F;span&gt;&lt;span&gt;    `((&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;libstdc++&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ,(make&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;libstdc&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;++&lt;&#x2F;span&gt;&lt;span&gt; gcc))
&lt;&#x2F;span&gt;&lt;span&gt;      (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;zlib&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ,zlib)))
&lt;&#x2F;span&gt;&lt;span&gt;   (native&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;inputs
&lt;&#x2F;span&gt;&lt;span&gt;    `((&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;unzip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ,unzip)))
&lt;&#x2F;span&gt;&lt;span&gt;   (synopsis &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;A tool to describe and deploy infrastructure as code&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;   (description
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;Terraform allows you to describe your complete infrastructure in the form of code. Even if your servers come from different providers such as AWS or Azure, Terraform helps you build and manage these resources in parallel across providers.&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;   (home&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;page &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;hashicorp.com&#x2F;terraform&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;   (license #f)))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;(define&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;public snam&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;terraform&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;1.6
&lt;&#x2F;span&gt;&lt;span&gt;  (package
&lt;&#x2F;span&gt;&lt;span&gt;    (inherit terraform)
&lt;&#x2F;span&gt;&lt;span&gt;    (version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;1.6.6&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt;    (source (origin
&lt;&#x2F;span&gt;&lt;span&gt;             (method url&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;fetch)
&lt;&#x2F;span&gt;&lt;span&gt;             (uri (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;append &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;releases.hashicorp.com&#x2F;terraform&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;&#x2F;terraform_&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; version &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;_linux_amd64.zip&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;span&gt;             (sha256
&lt;&#x2F;span&gt;&lt;span&gt;              (base32
&lt;&#x2F;span&gt;&lt;span&gt;	       &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;002g0ypkkfqy5nf989jyk3m1l7l0455hsaq11xfhr5lbv4zqh5yi&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;))))))
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I immediately added support to build older versions because that&#x27;s
what the customer is on and terraform is quite version dependent
AFAICT.&lt;&#x2F;p&gt;
&lt;p&gt;Now I can create a manifest for this project. I usually bootstrap them
with &lt;code&gt;guile shell --export-manifes go gopls&lt;&#x2F;code&gt; or similar and then add
stuff when it comes up.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; What follows is a &amp;quot;manifest&amp;quot; equivalent to the command line you gave.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; You can store it in a file that you may then pass to any &amp;#39;guix&amp;#39; command
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; that accepts a &amp;#39;--manifest&amp;#39; (or &amp;#39;-m&amp;#39;) option.
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;(specifications&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&amp;gt;&lt;&#x2F;span&gt;&lt;span&gt;manifest
&lt;&#x2F;span&gt;&lt;span&gt;  (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;list &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;go&amp;quot; &amp;quot;gopls&amp;quot; 
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;google-cloud-sdk&amp;quot; 
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;postgresql&amp;quot; 
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;snam-terraform-1.6&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;; from snamellit channel
&lt;&#x2F;span&gt;&lt;span&gt;        ))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;direnv-support&quot;&gt;Direnv support&lt;&#x2F;h1&gt;
&lt;p&gt;In order to manage my project environment and align it with the CI
environment I added the expected variables and use the guix support in
the stdlib of direnv. This will create a guix environment configured
from the manifest.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span&gt;use guix
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;export DB_URL=&amp;quot;postgresql:&#x2F;&#x2F;&amp;lt;db_ip&amp;gt;&#x2F;myproj&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;export DB_USER=&amp;quot;xyz&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;export DB_PASSWORD=&amp;quot;secret&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;export PGPASSWORD=$DB_PASSWORD
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;export VAULT_TOKEN=&amp;quot;&amp;lt;blablabla&amp;gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;export APPTIO_URL=https:&#x2F;&#x2F;acme.tpondemand.com
&lt;&#x2F;span&gt;&lt;span&gt;export APPTIO_TOKEN=&amp;lt;blablabla&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;export OPENAI_API_KEY=&amp;lt;blablabla&amp;gt;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;export VAULT_ADDR=https:&#x2F;&#x2F;vault.acme.com
&lt;&#x2F;span&gt;&lt;span&gt;export STATE_BUCKET=com-acme-test-myproj-tf-state
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;export TF_VAR_project_short=myproj
&lt;&#x2F;span&gt;&lt;span&gt;export TF_VAR_project=com-acme-test-${TF_VAR_project_short}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;PATH_add .&#x2F;node_modules&#x2F;.bin
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;emacs-support&quot;&gt;Emacs support&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;direnv-support-1&quot;&gt;Direnv Support&lt;&#x2F;h2&gt;
&lt;p&gt;Emacs &lt;em&gt;direnv mode&lt;&#x2F;em&gt; will load the configuration from the &lt;em&gt;.envrc&lt;&#x2F;em&gt; file
when opening a file in that project. The variables and apps are then
available for complition, LSP, shell, etc.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; enable direnv mode
&lt;&#x2F;span&gt;&lt;span&gt;(direnv&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mode)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;I just enable it globally because I want that always, not just for
terraform.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;terraform-support&quot;&gt;Terraform Support&lt;&#x2F;h2&gt;
&lt;p&gt;Enable some syntax highlighting and more importantly documentation
help. Also set &lt;code&gt;format-on-save&lt;&#x2F;code&gt; and the indent to 2 spaces&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;lisp&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-lisp &quot;&gt;&lt;code class=&quot;language-lisp&quot; data-lang=&quot;lisp&quot;&gt;&lt;span style=&quot;color:#616e88;&quot;&gt;;; configure terraform support
&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;require&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;terraform&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mode)
&lt;&#x2F;span&gt;&lt;span&gt;(add&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;hook &amp;#39;terraform&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mode&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;hook 
&lt;&#x2F;span&gt;&lt;span&gt;          (&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;lambda &lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;            (outline&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;minor&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;mode &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;)))
&lt;&#x2F;span&gt;&lt;span&gt;(custom&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;variables
&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;(terraform&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;indent&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;level &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span&gt;)
&lt;&#x2F;span&gt;&lt;span&gt; &amp;#39;(terraform&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;format&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span&gt;save &lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;t&lt;&#x2F;span&gt;&lt;span&gt;))
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and expose the functionality in similar keybindings as I use for LSP
support :&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2e3440;color:#d8dee9;&quot;&gt;&lt;code&gt;&lt;span&gt;(evil-define-key &amp;#39;normal terraform-mode-map
&lt;&#x2F;span&gt;&lt;span&gt;  (kbd &amp;quot;&amp;lt;leader&amp;gt;c k&amp;quot;) #&amp;#39;terraform-open-doc
&lt;&#x2F;span&gt;&lt;span&gt;  (kbd &amp;quot;&amp;lt;leader&amp;gt;c f&amp;quot;) #&amp;#39;terraform-format
&lt;&#x2F;span&gt;&lt;span&gt;  (kbd &amp;quot;&amp;lt;leader&amp;gt;c F&amp;quot;) #&amp;#39;terraform-format-buffer
&lt;&#x2F;span&gt;&lt;span&gt;  (kbd &amp;quot;&amp;lt;leader&amp;gt;c n&amp;quot;) &amp;#39;flymake-goto-next-error
&lt;&#x2F;span&gt;&lt;span&gt;  (kbd &amp;quot;&amp;lt;leader&amp;gt;c p&amp;quot;) &amp;#39;flymake-goto-prev-error)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;&lt;SPACE c k&gt;&lt;&#x2F;em&gt; will now open a browser window with the documentation of
the terraform element under the cursor. This does need terraform to be
installed though.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;add-support-to-makefile&quot;&gt;Add support to Makefile&lt;&#x2F;h2&gt;
&lt;p&gt;In order to save me from remembering the commandlines and because I
keep the terraform files in a &lt;em&gt;terraform&lt;&#x2F;em&gt; directory I make some &lt;em&gt;make&lt;&#x2F;em&gt;
targets to quickly access them.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;makefile&quot; style=&quot;background-color:#2e3440;color:#d8dee9;&quot; class=&quot;language-makefile &quot;&gt;&lt;code class=&quot;language-makefile&quot; data-lang=&quot;makefile&quot;&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;tfinit&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;: 
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;terraform&lt;&#x2F;span&gt;&lt;span&gt; -chdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;terraform init -backend-config&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;bucket=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;${&lt;&#x2F;span&gt;&lt;span&gt;STATE_BUCKET&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&amp;quot;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;tfcheck&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;terraform&lt;&#x2F;span&gt;&lt;span&gt; -chdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;terraform validate
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;tfapply&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;terraform&lt;&#x2F;span&gt;&lt;span&gt; -chdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;terraform apply
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;tfplan&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;terraform&lt;&#x2F;span&gt;&lt;span&gt; -chdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;terraform plan
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;tflint&lt;&#x2F;span&gt;&lt;span style=&quot;color:#81a1c1;&quot;&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;	&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span&gt; run --rm -v `&lt;&#x2F;span&gt;&lt;span style=&quot;color:#88c0d0;&quot;&gt;pwd&lt;&#x2F;span&gt;&lt;span&gt;`&#x2F;terraform:&#x2F;data -t ghcr.io&#x2F;terraform-linters&#x2F;tflint
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;workflow-tips&quot;&gt;Workflow tips&lt;&#x2F;h1&gt;
&lt;p&gt;Most of it is essentially hidden in the normal workflow. i.e. opening
a terraform file will load it, saving formats it. The &lt;em&gt;compile&lt;&#x2F;em&gt; feature
can be used to do file checking and linting.&lt;&#x2F;p&gt;
&lt;p&gt;Magit commit - push triggers the CI pipeline to run the deploy.&lt;&#x2F;p&gt;
&lt;p&gt;It is easy to test things out locally with the Makefile and it reduces
the number of steps in the CI script , so less things which can do
weird things.&lt;&#x2F;p&gt;
</description>
      </item>
    </channel>
</rss>
