NixOS: Enabling LXD virtual machines using Flakes

Nixpkgs is an ever-increasing collection of software packages for Nix and NixOS. Even with more than 80,000 packages, you easily run in a situation where there is a functionality that is not yet implemented.

Earlier this year, we wrote a tutorial on how to implement your own package in NixOS. The implementation of the package in the system was tedious and required keeping track of the package you wanted to implement.

Let’s dive into a practical example: LXD is a container and virtual machine manager. It endorses virtual machines natively since LXD 4.0. However, running on NixOS breaks the feature, and we have to find workarounds to use it. To allow LXD to start virtual machines on NixOS, we need a fix, and we want it to be both reproducible and portable.

To do so, we are using the lxd-agent feature which effectively fix the aforementionned issue. It was released by astridyu, a contributor to nixpkgs. It has not yet been implemented in the Master branch of nixpkgs and is, as of 19/04/2022, a pull request.

Our goal is to integrate the pull request to our nixpkgs to be able to start virtual machines. For this, we will use Flakes. It is an experimental feature of the Nix package manager that allows reproducibility in the deployment of dependencies. We use it to assemble different nixpkgs together. It is a trait known as composability.

If the pull request has been merged, this tutorial becomes

Read more
Intro to virtual threads: A new approach to Java concurrency

One of the most much-achieving Java 19 updates is the introduction of virtual threads. Virtual threads are aspect of Venture Loom, and are obtainable in Java 19 as a preview.

How digital threads perform

Virtual threads introduce an abstraction layer amongst functioning-program procedures and application-stage concurrency. Said differently, digital threads can be employed to program duties that the Java virtual equipment orchestrates, so the JVM mediates between the functioning process and the method. Figure 1 displays the architecture of virtual threads.

Architecture of virtual threads in Java. IDG

Determine 1. The architecture of virtual threads in Java.

In this architecture, the software instantiates virtual threads and the JVM assigns the compute resources to handle them. Contrast this to standard threads, which are mapped specifically on to functioning procedure (OS) processes. With conventional threads, the software code is dependable for provisioning and dispensing OS resources. With digital threads, the software instantiates virtual threads and thus expresses the require for concurrency. But it is the JVM that obtains and releases the methods from the operating system.

Digital threads in Java are analogous to goroutines in the Go language. When making use of digital threads, the JVM is only ready to assign compute resources when the application’s digital threads are parked, that means that they are idle and awaiting new work. This idling is prevalent with most servers: they assign a thread to a ask for and then it idles, awaiting a new function like a reaction from a datastore or further input from the network.

Utilizing typical

Read more