diff options
Diffstat (limited to 'content/post')
-rw-r--r-- | content/post/_index.md | 6 | ||||
-rw-r--r-- | content/post/a-new-site.md | 2 | ||||
-rw-r--r-- | content/post/cedit-and-paredit.md | 2 | ||||
-rw-r--r-- | content/post/emacs-package-archive-statistics.md | 24 | ||||
-rw-r--r-- | content/post/homesteading.md | 13 | ||||
-rw-r--r-- | content/post/nixos-on-nanopi-r5s.md | 142 | ||||
-rw-r--r-- | content/post/now-on-three-continents.md | 25 | ||||
-rw-r--r-- | content/post/opening-projects-with-projectile.md | 10 | ||||
-rw-r--r-- | content/post/postfix-as-null-client-with-external-catchall.md | 6 | ||||
-rw-r--r-- | content/post/repository-management-with-ghq.md | 6 | ||||
-rw-r--r-- | content/post/self-hosted-git.md | 10 |
11 files changed, 210 insertions, 36 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/a-new-site.md b/content/post/a-new-site.md index 1b06653..af61143 100644 --- a/content/post/a-new-site.md +++ b/content/post/a-new-site.md @@ -10,6 +10,6 @@ I finally got around to making a website. I decided to use [Hugo][] with a slig Someday I'll make my own theme, probably using [Stylus][] for CSS processing. But for now, this will do. The more important thing is just to create some content. -[Hugo]: http://hugo.spf13.com/ +[Hugo]: https://gohugo.io [Hyde theme]: https://github.com/spf13/hyde [Stylus]: http://learnboost.github.io/stylus/ diff --git a/content/post/cedit-and-paredit.md b/content/post/cedit-and-paredit.md index cd395e9..89f8cb3 100644 --- a/content/post/cedit-and-paredit.md +++ b/content/post/cedit-and-paredit.md @@ -28,7 +28,7 @@ paredit. Turns out it provides that control whether a space should be inserted. So, solving the formatting issue turned out to be pretty simple: -```elisp +```lisp (defun ap/cedit-space-delimiter-p (endp delimiter) "Don't insert a space before delimiters in c-style modes" (not cedit-mode)) diff --git a/content/post/emacs-package-archive-statistics.md b/content/post/emacs-package-archive-statistics.md index 9a8e8bf..6efa5bd 100644 --- a/content/post/emacs-package-archive-statistics.md +++ b/content/post/emacs-package-archive-statistics.md @@ -10,7 +10,7 @@ I use [cask][] for managing the dependencies of my Emacs configuration. Whenever I opened my `Cask` file, I wondered if I really was using all the sources I had defined: -```elisp +```lisp (source gnu) (source marmalade) (source melpa) @@ -44,7 +44,7 @@ decided to try to figure out how to generate some usage statistics. I found [how to get a list of installed packages][], but that just gives a list: -```elisp +```lisp (ace-jump-mode ag auto-compile auto-indent-mode autopair ...) ``` @@ -52,7 +52,7 @@ I needed to get more information about those packages. I looked at where `list-packages` gets that information from. It seems that `package-archive-contents` is a list of cons cells: -```elisp +```lisp (org-plus-contrib . [(20140714) nil "Outline-based notes management and organizer" tar "org"]) @@ -62,7 +62,7 @@ Then created a function to loop over the contents of `package-activated-list`, retrieving the corresponding contents of `package-archive-contents`: -```elisp +```lisp (defun package-list-installed () (loop for pkg in package-activated-list collect (assq pkg package-archive-contents))) @@ -74,7 +74,7 @@ There are some helper functions in package.el such as needed. I happened to be using a pretest version of Emacs at the time and didn't know that it's not in 24.3, so I just made sure it was defined: -```elisp +```lisp (if (not (fboundp #'package-desc-archive)) (defsubst package-desc-archive (desc) (aref desc (1- (length desc))))) @@ -89,7 +89,7 @@ To generate a list of statistics, I just needed to loop over the installed packages from `package-list-installed` and update a count for each archive: -```elisp +```lisp (defun package-archive-stats () (let ((archives (makehash)) (assoc '())) @@ -105,7 +105,7 @@ for each archive: Running this gives a list of cons cells: -```elisp +```lisp (("gnu" . 0) ("org" . 1) ("melpa-stable" . 2) @@ -116,7 +116,7 @@ Running this gives a list of cons cells: I wrapped it in an interactive function so that I could check the numbers quickly: -```elisp +```lisp (defun package-show-archive-stats () (interactive) (message "%s" (package-archive-stats))) @@ -126,7 +126,7 @@ With that, I removed `(source gnu)` from my `Cask` file. Now I had another question. What package was installed from [marmalade][]? In the lisp fashion, I created yet another function: -```elisp +```lisp (defun package-show-installed-from-archive (archive) (interactive (list (helm-comp-read "Archive: " (mapcar #'car package-archives) :must-match t))) @@ -142,7 +142,7 @@ the lisp fashion, I created yet another function: Running this with the argument `"marmalade"` gives: -```elisp +```lisp (php-extras) ``` @@ -161,8 +161,8 @@ repository, which would allow [MELPA Stable][] to be used even when [state of emacs package archives]: http://blog.jorgenschaefer.de/2014/06/the-sorry-state-of-emacs-lisp-package.html [marmalade]: http://marmalade-repo.org/ [GNU ELPA]: http://elpa.gnu.org/packages/ -[MELPA]: http://hiddencameras.milkbox.net/ -[MELPA Stable]: http://melpa-stable.milkbox.net/ +[MELPA]: https://melpa.org/ +[MELPA Stable]: http://stable.melpa.org/ [org archive]: http://orgmode.org/elpa.html [how to get a list of installed packages]: http://stackoverflow.com/questions/13866848/how-to-save-a-list-of-all-the-installed-packages-in-emacs-24 [php-extras]: https://github.com/arnested/php-extras 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/opening-projects-with-projectile.md b/content/post/opening-projects-with-projectile.md index 775e2be..b44c5e8 100644 --- a/content/post/opening-projects-with-projectile.md +++ b/content/post/opening-projects-with-projectile.md @@ -12,7 +12,7 @@ With this in mind, I decided to try to add support for opening projects under a I saw that projectile uses [Dash.el][] in some places, and after reading about [anaphoric macros], I decided that I'd try to use them to aid me. -```elisp +```lisp (defun ap/subfolder-projects (dir) (--map (file-relative-name it dir) (-filter (lambda (subdir) @@ -23,14 +23,14 @@ I saw that projectile uses [Dash.el][] in some places, and after reading about [ First, this filters the non-special files under `dir`, filtering non-directories. Then it runs the list of `projectile-project-root-files-functions` on it to determine if it looks like a projectile project. To make the list more readable, it makes the filenames relative to the passed-in directory. It runs like this: -```elisp +```lisp (ap/subfolder-projects "~/projects") => ("dotfiles" "ggtags" …) ``` So, we've got ourselves a list, but now we need to be able to open the project that's there, even though the folders are relative. -```elisp +```lisp (defun ap/open-subfolder-project (from-dir &optional arg) (let ((project-dir (projectile-completing-read "Open project: " (ap/subfolder-projects from-dir)))) @@ -43,7 +43,7 @@ We get support for multiple completion systems for free, since projectile has a Then I defined some helper functions to make it easy to open work and home projects. -```elisp +```lisp (defvar work-project-directory "~/work") (defvar home-project-directory "~/projects") @@ -62,7 +62,7 @@ With this all set up, whenever I want to start working on a project I just type I also considered trying to add all the projects under a directory to the projectile known project list. I didn't find it quite as easy to use, but it's available below if anyone would prefer that style. -```elisp +```lisp (defun ap/-add-known-subfolder-projects (dir) (-map #'projectile-add-known-project (--map (concat (file-name-as-directory dir) it) (ap/subfolder-projects dir)))) diff --git a/content/post/postfix-as-null-client-with-external-catchall.md b/content/post/postfix-as-null-client-with-external-catchall.md index 4a604b5..b3fd5a4 100644 --- a/content/post/postfix-as-null-client-with-external-catchall.md +++ b/content/post/postfix-as-null-client-with-external-catchall.md @@ -3,7 +3,7 @@ title = 'Postfix on a NixOS null client with external catch-all' date = 2020-09-11T18:49:00+02:00 [taxonomies] -tags = ["development","git","nixos"] +tags = ["nixos","infrastructure"] +++ I wanted to set up a server so that any local email (e.g. generated by cron jobs/systemd timers) would be forwarded to an external address, regardless of the user. I also wanted the from address to keep the system hostname whilst not allowing any external use of the mailserver. @@ -11,7 +11,7 @@ It took me a while to figure out how to this, so I thought I'd share my method. Here's the config that can be used to do this on any NixOS host, after redefining the first two variables. -```txt {linenos=table,hl_lines=["2-3"]} +```txt,linenos,hl_lines=2-3 services.postfix = let localUser = "example-user"; forwardingAddress = "user@external.domain"; @@ -36,7 +36,7 @@ Emails to any user without a domain part are all sent to the forwarding address First, the basic setup for a null client can be found in the [postfix documentation][0]. The example config would be translated into NixOS like so: -```txt {linenos=table} +```txt services.postfix = { enable = true; destination = []; 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 1cceff3..ab88e78 100644 --- a/content/post/self-hosted-git.md +++ b/content/post/self-hosted-git.md @@ -63,7 +63,7 @@ means that I can create a remote repository automatically by cloning a repository URL that doesn't already exist. I can clone and create a new repo simultaneously like so: -```shell +```bash cd ~/projects git clone alanpearce.eu:some-new-repository ``` @@ -71,7 +71,7 @@ git clone alanpearce.eu:some-new-repository But with [ghq][], which I [blogged about before][using-ghq], I don't have to concern myself with where to put the repository: -```shell +```bash $ ghq get alanpearce.eu:some-new-repository clone ssh://alanpearce.eu/some-new-repository -> /Volumes/Code/projects/alanpearce.eu/some-new-repository git clone ssh://alanpearce.eu/some-new-repository /Volumes/Code/projects/alanpearce.eu/some-new-repository @@ -93,7 +93,7 @@ Host alanpearce.eu This repository would be private by default, but I can change that by an SSH command. Here's how I would do it: -```shell +```bash ssh alanpearce.eu perms some-new-repository + READERS gitweb ssh alanpearce.eu perms some-new-repository + READERS daemon ``` @@ -106,7 +106,7 @@ user and not `gitweb`, if I wanted. I can also add or change the description of a repository shown on cgit like so: -```shell +```bash ssh alanpearce.eu desc some-new-repository 'A new repository' ``` @@ -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" |