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 NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System (current post) 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, if you run ls -alh /etc on a computer running NixOS,...

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 NixOS Series 3: Software Packaging 101 (current post) 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, binaries compiled for other Linux distros will not run on NixOS at all. Therefore,...
Reverse Engineered Linux Driver for HP OMEN Macro Keys
I got a new laptop some time ago, an HP OMEN 17t-ck000. While it's a nice laptop with excellent build quality and performance, it has one problem: it's drivers under Linux are far from complete. No support for fan speed control. You can see the fan speed but that's it. In addition, HP's default fan control strategy is very agressive, in the sense that even with fan spin down enabled in BIOS, the fan keeps running with the CPU being around 40 degrees celsius and GPU being idle. Actually, NBFC can be used to control the fan speed by directly writing to EC registers, but in an unfortunate accident I lost my configuration file. I was trying NixOS on my new laptop when I set up NBFC. When the accident happened, I had removed NixOS from the laptop,...
Low-cost GeoDNS with NS1 and UptimeRobot/Freshping
Some parts of the content come from https://hostedtalk.net/t/connecting-uptime-robot-with-ns1-dns-api/3883 。 Goal I have quite a few VPSes around the world, but my website had been served by a single VPS in Los Angeles for a long time. Because I purchase VPSes from small providers for their specific routing configuration or low price, the network of this VPS can be unstable from time to time. Although it's rare, I had to manually point the DNS to another VPS in case of an outage and switch back after it's back up. Therefore, I want to serve my website with all my VPSes, and automatically reroute traffic to other VPSes if one VPS is down. Synchronizing website data is of no difficulty since I use Hexo, a static site generator....

I Moved My SSD to My New Laptop. This is What Happened To My Btrfs Data
What Happened The quality of my previous laptop (Lenovo Legion R720) isn't great. After 4 years of use, I swapped its keyboard once and replaced its failed mechanical hard drive with a SATA SSD. In addition, every time I opened its back panel, some plastic residue or even screws would fall out from the back panel or the hinge. These were strong indications that the laptop already had one foot in the grave. So I took advantage of a special deal and got a new laptop for cheap, and planned to migrate my data over to the new laptop. The operating system I daily drive, Arch Linux, sits on a Western Digital SN550 1T SSD I bought half a year ago (including the EFI boot partition and the Btrfs-formatted root partition). The usual procedure is to reinstall the operating system on the new laptop....

NixOS Series 2: Basic Config, Nix Flake & Batch Deploy
List of NixOS series posts: NixOS Series 1: Why I fell in love NixOS Series 2: Basic Config, Nix Flake & Batch Deploy (current post) NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System NixOS Series 5: Creating Disk Image for Low RAM VPS This is the second post in my NixOS series and mainly focuses on: Basic format of NixOS config files and how to edit them Flake functionality of Nix package manager Deploy-RS deployment tool This post assumes that you've installed NixOS with NixOS's official installation manual . Changelog 2023-05-10: Add a recommended post: NixOS & Nix Flakes - A Guide for Beginners by Ryan Yin. 2021-12-18: NixOS 21.11 still doesn't come with Flake functionality by default. Relevant information is updated....

NixOS Series 1: Why I fell in love
List of NixOS series posts: NixOS Series 1: Why I fell in love (current post) NixOS Series 2: Basic Config, Nix Flake & Batch Deploy NixOS Series 3: Software Packaging 101 NixOS Series 4: "Stateless" Operating System NixOS Series 5: Creating Disk Image for Low RAM VPS Right now, I'm gradually migrating my servers from Devuan Linux to NixOS . NixOS is a Linux distribution centered on a set of Nix configuration files located in /etc/nixos , which is used to install and configure the whole operating system. Because this configuration set defines ALL config files and packages on the system, as long as you use the same config files, you will absolutely get the same operating system every time you reinstall. Nix configuration language is also Turing complete,...
Replace Jenkins with Drone CI
Jenkins is a free and open-source CI/CD software widely used in all kinds of scenarios. The main advantage of Jenkins is its grand collection of plugins capable of all sorts of jobs, including deploying with SCP or Ansible , analyzing code with Cppcheck , and notifying job status with Telegram or DingTalk . Previously I also used Jenkins for automation of numerous jobs, like rebuilding my Docker images , deploying the blog you're visiting right now, and even auto sign-in to Genshin Impact . But Jenkins is a CI with a long history, and its predecessor Hudson was released back in 2005. Therefore, Jenkins executes commands directly when it comes to running jobs instead of using modern approaches such as containers....
Lookup Any Public WHOIS with this nginx-based Server
After I set up a DN42 WHOIS server with Nginx , I configured my DN42 Looking Glass to use this service. As my Looking Glass is capable of running as a Telegram bot, fellow group members are looking up WHOIS information of IPs and domains with it. But soon we noticed a problem. A significant part of members have applied for ASNs and IP ranges on the public Internet after they're familiar enough with DN42, and they're peering at Internet Exchange Points. Therefore, they often need to lookup some public Internet IPs, ASNs, and domains, yet none of the Telegram bots in our group can do so. It would be quite helpful for us if there exists a WHOIS server that proxies lookups to relevant registries. Proxying is exactly what Nginx is good at. With some modifications to Nginx,...