Preface Almost four and a half years ago, I migrated the blog's site system from Typecho to Hexo (Chinese only link) . Hexo is a static site generator that by itself doesn't connect to databases like MySQL and PostgreSQL and dynamically generate pages. Instead, it generated all HTML pages in one go based on the given Markdown files. Compared to dynamic solutions like WordPress and Typecho, pre-generating static pages eliminates the need of dynamic language support on the web server (like PHP), and has lower performance requirements on the server. Hexo itself, however, is not a new solution. It's first version was released back in July 2013 . By then, single page application frameworks, leaded by React, were just released (React: May 2013)....
NixOS Series 5: Creating Disk Image for Low RAM VPS
List of NixOS Series Posts: NixOS Series 1: Why I fell in love NixOS Series 2: Basic Config, Nix Flake & Batch Deploy Recommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan Yin NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System NixOS Series 5: Creating Disk Image for Low RAM VPS Black friday has passed. Some readers, I believe, have perchased some VPSes or cloud servers on sale, and want to install NixOS on them. However, since NixOS is nowhere as famous as popular Linux distros, such as CentOS, Debian and Ubuntu, almost no VPS provider will offer a disk image preinstalled with NixOS. This lefts the user one of the following options to perform the installation manually: Mounting NixOS's installer ISO,...
Nix Trigonometric Math Library from Ground Zero
(Title image sourced from: Wikipedia - Trigonometry ) Why I wanted to calculate the network latency between all my VPS nodes, and add the latency into the configuration file of Bird BGP daemon, so the network packets are forwarded through the lowest latency route. However, I have 17 nodes as of today, and I didn't want to manually run a ping command between each pair. So I came up with a solution: I can mark the latitudes and longitudes of the physical locations of my nodes, calculate the physical distance, and divide that by half the light speed to get the approximate latencies. I randomly sampled a few node pairs, and found that the Internet routing between them are mostly straightforward, with no significant detours. In this case,...
Preventing Pipewire from being SIGKILLed
Problem I frequently encounter the situation that the Pipewire audio server is suddenly stopped: The problem usually appears when I connect/disconnect my laptop from the power adapter. My computer usually lags for a short time while switching between performance profiles. systemctl --user status pipewire.service only shows that the Pipewire process was terminated by a SIGKILL signal, without any other useful log information. Neither coredumpctl nor dmesg shows the existence of a core dump event. Cause The Pipewire process runs with realtime priority, with which its scheduling needs are satisfied first, so it can process audio data in time to prevent stuttering. To increase its process priority,...
How to Kill the DN42 Network (Updated 2023-05-12)
DN42, aka Decentralized Network 42, is a large, decentralized VPN-based network. You can read more about DN42 in this post: DN42 Experimental Network: Intro and Registration DN42 is an experimental network , where everyone helps everyone. Nobody is going to blame you if you screwed up. You may seek help at DN42's IRC channel , mailing list or the unofficial Telegram group . Since DN42 is a network for experimentation, a lot of relatively inexperienced users also participate in it. Therefore, occasionally an inexperienced user may misconfigure his/her system and impact the whole DN42 network or even shut it down. As a more experienced user,...
NVIDIA GPU Passthrough on an Optimus MUXed Laptop (Updated 2023-05)
A year ago, to simultaneously browse webpages and write codes on my Arch Linux installation and use Windows to run tasks infeasible on Linux (such as gaming), I tried GPU passthrough on my Lenovo R720 gaming laptop . But since that laptop has an Optimus MUXless architecture (as mentioned in that post), its dedicated GPU doesn't have output ports, and the integrated GPU is in charge of all the displays. Therefore, severe limitations exist for that setup, and I eventually gave up on it. But now, I've purchased a new laptop. The HDMI output port on this laptop is directly connected to its NVIDIA dedicated graphics card, or in other words, it has an Optimus MUXed architecture. Since there is a way to make the virtual machine aware of a "monitor on the dedicated GPU",...
Fix China Telecom 4G Roaming on AOSP ROM by Changing APN
Since the support life of my OnePlus 8T's official ROM is about to end, I flashed Nameless OS, a Lineage OS based third party Android ROM, onto my phone. But after flashing the ROM, I found that my China Telecom SIM card cannot roam on the 4G network of local mobile service providers, only 2G or 3G work. Since the local providers are recently shutting down 2G and 3G networks, the roaming cellular signal strength is really bad. I experience a high latency on receiving or sending messages, nor can I use VoLTE to make calls normally. I tested other Lineage OS based third party ROMS, and experienced the same problem. After numerous attempts, I found that the problem seems to be with the phone's APN settings. I use the term seems to be because while changing APN settings fixed my problem,...
Notes on Setting Up NAS+Router on Old HP Workstation
I purchased an old HP workstation to use as a NAS and router at my home. This post is a short note of my process of setting it up. Hardware Choice For a NAS, you usually have these hardware choices: Ready-to-use NAS (e.g. Synology) Pros: ready to use out of the box. Cons: Expensive, to the extent of "free hardware for software purchase". Harder to customize, when comparing the stock operating system with various Linux distributions. Second-hand servers Pros: Cheap. Most servers are thrown away by datacenters once their warranty ends, and are obtained at minimum cost, refurbished and then resold. Stable. These servers are built to last, and are used in a datacenter with controlled temperature, humidity and no dust. Cons: Noise. In order to lower the fan speed,...
NixOS Series 4: "Stateless" Operating System
List of NixOS Series Posts: NixOS Series 1: Why I fell in love NixOS Series 2: Basic Config, Nix Flake & Batch Deploy Recommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan Yin NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System NixOS Series 5: Creating Disk Image for Low RAM VPS Changelog: 2023-02-18: Fix config not applied to the root user, in the "Move Temp Directory of Nix Daemon" section. One of the most famous features of NixOS is that most software configurations on the system are generated and managed exclusively by a Nix-language config file. Even if such software modifies its config file while running, the config file will still be overwritten on the next Nix config switch or the next reboot. For example,...
NixOS Series 3: Software Packaging 101
List of NixOS Series Posts: NixOS Series 1: Why I fell in love NixOS Series 2: Basic Config, Nix Flake & Batch Deploy Recommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan Yin NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System NixOS Series 5: Creating Disk Image for Low RAM VPS One characteristic of NixOS is that all binary applications and libraries are stored in /nix/store directory and managed by Nix package manager. This means that NixOS doesn't conform to the FHS standard of Linux , and there's not even a dynamic library loader like ld-linux-x86-64.so.2 in /lib or /lib64 , let alone other shared libraries like libc.so . Therefore, unless the program is statically linked,...