systemd udev Rules to Detect USB Device Plugging (including Bus and Device Number)

The other day, I was working on some udev rules to invoke a script when a USB device is added or removed from my machine. I needed the USB bus and USB port number to further process that event. I decided to use udev for that. However, getting the relevant attributes was not as intuitive as I expected, and existing documentation wasn’t that good. Here’s what I did and how I solved it. Read more…

Fixing “Illegal path references in fixed-output derivation” in Nix

The other day I was working with fixed-output derivations. After copying several files to $out, I was facing a “Illegal path references in fixed-output derivation error”. The only helpful reference on the internet I could find was the Nix source code on GitHub. It took me a while to figure out what’s going on. You get this error when your fixed-output derivation places something in $out which contains a Nix store path! This Read more…

Screenshot: Nix build: "illegal path referenced in fixed-output derivation". The part on the top shows all Nix store paths that accidentally landed in the derivation (obtained by "grep")
Code Snippet: Fixed output derivation in Nix

Accessing Network from a Nix Derivation (via Fixed output derivations)

Usually, Nix derivations are build in a sandbox that prevent any program from accessing the network. This has a good reason: We want reproducibility in Nix, and using the network is not reproducible for many reasons! But there must be a way of accessing the network from a derivation, right? Why? Because, builtins.fetchGit or builtins.fetchTarball are not flexible enough to cope with the nature of Maven, Cargo, npm or other tools that download Read more…

How to use `gcc_multi` with a specific GCC version in nixpkgs?

I recently came across the problem that pkgs.gcc_multi comes with gcc in version 12 but I needed version 11. While nixpkgs exports gcc in multiple versions (pkgs.gcc, pkgs.gcc11, pkgs.gcc12, pkgs.gcc13), pkgs.gcc_multi is only exported once, backed with the version coming from pkgs.gcc. However, using another, specific gcc version is fairly simple. In <nixpkgs at NixOS 23.11>/pkgs/top-level/all-packages.nix we can find gcc_multi. This is aliased to pkgs.wrapCCMulti gcc (function call), which is defined in the Read more…

Screenshot: PhipsBoot Output

Introducing PhipsBoot – My x86 Relocatable Bootloader

Today, I’d like to introduce you to PhipsBoot. 🎉 I started working on it in September 2023 or so, but polished it just recently. A lot of knowledge from my previous blog post about x86 Kernel Development & Relocatable Binaries went into this project. PhipsBoot is a relocatable x86_64 bootloader written in Rust and assembly that loads a kernel into 64-bit mode. It abstracts a lot of boot-related x86_64 complexity away. It is Read more…

x86 Kernel Development & Relocatable Binaries – What I learned about Toolchains and Relocatable Code

This post is roughly a summary of the obscure knowledge I learned about toolchains and relocatable code in the last couple of years by studying the code of the microkernels NOVA and Hedron, my professional hands-on experience with kernel development, and several learning projects. I present some of the “hard and not obvious” properties of producing kernel binaries, information that only stands “between the lines” in existing projects, and topics I didn’t find Read more…