about summary refs log tree commit diff stats
path: root/content/post
diff options
context:
space:
mode:
Diffstat (limited to 'content/post')
-rw-r--r--content/post/_index.md6
-rw-r--r--content/post/homesteading.md13
-rw-r--r--content/post/nixos-on-nanopi-r5s.md142
-rw-r--r--content/post/now-on-three-continents.md25
-rw-r--r--content/post/repository-management-with-ghq.md6
-rw-r--r--content/post/self-hosted-git.md2
6 files changed, 184 insertions, 10 deletions
diff --git a/content/post/_index.md b/content/post/_index.md
deleted file mode 100644
index e0d2523..0000000
--- a/content/post/_index.md
+++ /dev/null
@@ -1,6 +0,0 @@
-+++
-title = "Posts"
-sort_by = "date"
-paginate_reversed = true
-transparent = true
-+++
diff --git a/content/post/homesteading.md b/content/post/homesteading.md
new file mode 100644
index 0000000..52ce713
--- /dev/null
+++ b/content/post/homesteading.md
@@ -0,0 +1,13 @@
++++
+title = "Homesteading"
+description = "Running my own code"
+date = 2023-09-22T10:09:22.141Z
+[taxonomies]
+tags = ["website"]
++++
+
+I switched away from [Zola](https://www.getzola.org/) and made my own [static site builder](https://git.alanpearce.eu/website/tree) that uses only HTML templates. I've been wanting to do this since at least 2017, when I started to work on a [homestead project](https://git.alanpearce.eu/homestead/tree/src?h=2017), which I didn't quite finish.
+
+The recent release of [Bun](https://bun.sh/), which touts itself as an "all-in-one JavaScript toolkit" encouraged me to play around with it.  I have to say, I am surprised by how energising it was; an antidote to the "JavaScript fatigue" I've read about and definitely experienced. 
+
+I decided that I'd start by serving my site using Bun's web server, then I added site generation later. I have been intrigued by the idea of DOM templating ever since I read about it on [Camen Design](https://camendesign.com/dom_templating) [in 2012](https://camendesign.com/code/dom_templating/domtemplate_v4.rem) and I've enjoyed putting it into practice.
diff --git a/content/post/nixos-on-nanopi-r5s.md b/content/post/nixos-on-nanopi-r5s.md
new file mode 100644
index 0000000..185bd30
--- /dev/null
+++ b/content/post/nixos-on-nanopi-r5s.md
@@ -0,0 +1,142 @@
++++
+title = "Running NixOS on a NanoPi R5S"
+date = 2023-07-30T08:51:46Z
+[taxonomies]
+tags = ["nixos", "home-networking", "infrastructure"]
++++
+
+I managed to get [NixOS](https://nixos.org) running on my [NanoPi R5S](https://www.friendlyelec.com/index.php?route=product/product&product_id=287) ([FriendlyElec Wiki](https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R5S)).
+
+Firstly, I flashed a pre-built stock Debian image from [inindev](https://github.com/inindev/nanopi-r5) to an SD card. This can be used as a rescue system later on. 
+
+From that SD card, I then flashed the same system onto the internal <abbr title="embedded MultiMediaCard">eMMC</abbr> Storage. I only really needed to this to ensure UBoot was correctly installed; I think there will be an easier way to do it.
+
+I had nix already installed on the <abbr title="Non-Volatile Memory Express">NVMe</abbr> <abbr title="Solid-State Drive">SSD</abbr> along with a home directory. I bind-mounted `/nix` and `/home` following the fstab I had previously set up:
+
+```conf
+UUID=replaceme  /mnt    ext4    relatime,lazytime   0 2
+/mnt/nix        /nix    none    defaults,bind       0 0
+/mnt/srv        /srv    none    defaults,bind       0 0
+/mnt/home       /home   none    defaults,bind       0 0
+```
+
+I then created a user for myself using that home directory, I had full access to nix in the new Debian environment. This meant I had access to `nixos-install`. 
+
+I wanted to use the [extlinux support in UBoot](https://u-boot.readthedocs.io/en/latest/develop/distro.html#boot-configuration-files), so I made `/mnt/boot` point to `/boot` on the <abbr>eMMC</abbr>:
+
+```sh
+mkdir /mnt/{emmc,boot}
+mount LABEL=rootfs /mnt/emmc
+mount --bind /mnt/emmc /mnt/boot
+```
+
+<aside>
+One could <em>probably</em> delete everything else on the <abbr>eMMC</abbr> and move the contents of <code>/mnt/emmc/boot</code> to <code>/mnt/emmc</code>, thus obviating the need to bind-mount <code>/boot</code>
+</aside>
+
+I ran `nixos-generate-config` as usual, which set up the mount points in `hardware-configuration.nix` correctly. `configuration.nix` needed a bit of tweaking. My first booting configuration was something like this, mostly borrowed from [Artem Boldariev's comment](https://github.com/inindev/nanopi-r5/issues/11#issue-1789308883):
+
+```nix
+{ config
+, pkgs
+, lib
+, ...
+}:
+let
+  fsTypes = [ "f2fs" "ext" "exfat" "vfat" ];
+in
+{
+  imports = [ ./hardware-configuration.nix ];
+  boot = {
+    kernelPackages = pkgs.linuxKernel.packages.linux_6_4;
+
+    # partial Rockchip related changes from Debian 12 kernel version 6.1
+    # Also, see here:
+    # https://discourse.nixos.org/t/how-to-provide-missing-headers-to-a-kernel-build/11422/3
+    kernelPatches = [
+      {
+        name = "rockchip-config.patch";
+        patch = null;
+        extraConfig = ''
+          PHY_ROCKCHIP_PCIE Y
+          PCIE_ROCKCHIP_EP y
+          PCIE_ROCKCHIP_DW_HOST y
+          ROCKCHIP_VOP2 y
+        '';
+      }
+      {
+        name = "status-leds.patch";
+        patch = null;
+        # old:
+        # LEDS_TRIGGER_NETDEV y
+        extraConfig = ''
+          LED_TRIGGER_PHY y
+          USB_LED_TRIG y
+          LEDS_BRIGHTNESS_HW_CHANGED y
+          LEDS_TRIGGER_MTD y
+        '';
+      }
+    ];
+    
+    supportedFilesystems = fsTypes;
+    initrd.supportedFilesystems = fsTypes;
+
+    initrd.availableKernelModules = [
+      ## Rockchip
+      ## Storage
+      "sdhci_of_dwcmshc"
+      "dw_mmc_rockchip"
+
+      "analogix_dp"
+      "io-domain"
+      "rockchip_saradc"
+      "rockchip_thermal"
+      "rockchipdrm"
+      "rockchip-rga"
+      "pcie_rockchip_host"
+      "phy-rockchip-pcie"
+      "phy_rockchip_snps_pcie3"
+      "phy_rockchip_naneng_combphy"
+      "phy_rockchip_inno_usb2"
+      "dwmac_rk"
+      "dw_wdt"
+      "dw_hdmi"
+      "dw_hdmi_cec"
+      "dw_hdmi_i2s_audio"
+      "dw_mipi_dsi"
+    ];
+    loader = {
+      timeout = 3;
+      grub.enable = false;
+      generic-extlinux-compatible = {
+        enable = true;
+        useGenerationDeviceTree = true;
+      };
+    };
+  };
+  # this file is from debian and should be in /boot/
+  hardware.deviceTree.name = "../../rk3568-nanopi-r5s.dtb";
+  # Most Rockchip CPUs (especially with hybrid cores) work best with "schedutil"
+  powerManagement.cpuFreqGovernor = "schedutil";
+  
+  boot.kernelParams = [
+    "console=tty1"
+    "console=ttyS2,1500000"
+    "earlycon=uart8250,mmio32,0xfe660000"
+  ];
+  # Let's blacklist the Rockchips RTC module so that the
+  # battery-powered HYM8563 (rtc_hym8563 kernel module) will be used
+  # by default
+  boot.blacklistedKernelModules = [ "rtc_rk808" ];
+
+  # ... typical config omitted for brevity
+}
+```
+
+Due to the custom kernel configuration, building takes a while. I set up a [distributed build](https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html) to speed things up, using a [Hetzner Cloud](https://www.hetzner.com/cloud) CAX21 ARM64 instance (although I could have used an x86_64 system with one of the methods mentioned on the [NixOS on ARM NixOS wiki page](https://nixos.wiki/wiki/NixOS_on_ARM#Build_your_own_image_natively)). This made for a very long `nixos-install` command line:
+
+```sh
+sudo env PATH=$PATH =nixos-install --root /mnt --no-channel-copy --channel https://nixos.org/channels/nixos-23.05 --option builders'ssh://my-host aarch64-linux /root/.ssh/id_pappel_nixpkgs 4 2 big-parallel' --option builders-use-substitutes true --max-jobs 0
+```
+
+I added `setenv bootmeths "extlinux"` to `/boot/boot.txt` and ran `/boot/mkscr.sh` as root to ensure that UBoot would search for the `extlinux.conf` file
diff --git a/content/post/now-on-three-continents.md b/content/post/now-on-three-continents.md
new file mode 100644
index 0000000..1a2828a
--- /dev/null
+++ b/content/post/now-on-three-continents.md
@@ -0,0 +1,25 @@
++++
+title = "Now on three continents"
+description = "This website is now hosted on three continents"
+date = 2023-07-02T07:55:35Z
+[taxonomies]
+tags = ["website", "infrastructure"]
++++
+
+This website is now hosted on three continents.
+
+I recently changed the hosting for this site to [fly](http://fly.io), since I was rather intrigued by the idea of being able to run three small <abbr>VMs</abbr> (<dfn id="VMs">Virtual Machines</dfn>) worldwide for free. I would gladly have paid a small amount for their services. If they didn't have a free allowance for <abbr>VMs</abbr> then it would only be around $6 a month, so I'm not worried about them removing the free allowance.
+
+Previously it was running on one [Hetzner](https://www.hetzner.com) <abbr title="Virtual Machine">VM</abbr> in Nuremberg, Germany that I set up and maintained myself. The maintenance wasn't a problem for me, but rather the idea of slow loading times for anyone reading this outside of Europe.
+
+American visitors should notice a definite speedup now, as there's a server on the west coast and for the few visitors in the Asia-Pacific region, there's also a server in Australia. I kept track of the response time before and after the change using the [Online or not](https://onlineornot.com/) [Do I need a CDN?](https://onlineornot.com/do-i-need-a-cdn) tool, which you can see in the table below (measured in <abbr title="milliseconds">ms</abbr>)
+
+| Region                  | Before | After |
+|-------------------------|--------|-------|
+| Europe (Frankfurt)      | 62     | 32    |
+| US East (N. Virginia)   | 348    | 185   |
+| US West (N. California) | 503    | 61    |
+| Asia Pacific (Tokyo)    | 732    | 251   |
+| Asia Pacific (Sydney)   | 1114   | 76    |
+
+I do find it rather amusing that I spend more time tinkering with the site than actually posting anything, but, for once, tinkering has actually led to me posting something (this post). I would like to think that this might encourage me to post more in the future, but only time will tell.
diff --git a/content/post/repository-management-with-ghq.md b/content/post/repository-management-with-ghq.md
index c225ace..dd21db9 100644
--- a/content/post/repository-management-with-ghq.md
+++ b/content/post/repository-management-with-ghq.md
@@ -67,10 +67,10 @@ sequence:
 bindkey '\es' cd-project-widget
 ```
 
-Now I can press `M-s` in a shell, start typing "dotfiles" and press enter to `cd`
-to my [dotfiles][] project. Pretty neat!
+Now I can press `M-s` in a shell, start typing "nixfiles" and press enter to `cd`
+to my [nixfiles][] project. Pretty neat!
 
 [ghq]:https://github.com/motemen/ghq
 [fzf]:https://github.com/junegunn/fzf
 [fzf-cd-widget]:https://github.com/junegunn/fzf/blob/337cdbb37c1efc49b09b4cacc6e9ee1369c7d76d/shell/key-bindings.zsh#L40-L54
-[dotfiles]:https://git.alanpearce.eu/dotfiles
+[nixfiles]:https://git.alanpearce.eu/dotfiles
diff --git a/content/post/self-hosted-git.md b/content/post/self-hosted-git.md
index 3bdbffb..ab88e78 100644
--- a/content/post/self-hosted-git.md
+++ b/content/post/self-hosted-git.md
@@ -144,4 +144,4 @@ I want, without consuming many system resources with daemons.
 [dotfiles-github]:https://github.com/alanpearce/dotfiles
 [wildrepos]:http://gitolite.com/gitolite/wild/
 [ghq]:https://github.com/motemen/ghq
-[using-ghq]:{{< relref "/post/repository-management-with-ghq.md" >}} "Repository management with ghq"
+[using-ghq]:/post/repository-management-with-ghq/ "Repository management with ghq"