This content originally appeared on DEV Community and was authored by NACAMURA Mitsuhiro
NixNG
NixNG is a Linux distribution currently under development, derived
from NixOS. It is being positioned as a lightweight alternative to
NixOS, specifically targeting container environments.
The project achieves its reduced size by omitting systemd from
NixOS and minimizing the default package set. Since NixOS container
images are a bit heavy, a lighter alternative is definitely welcome.
Dropping systemd also opens up possibilities for using
lighter-weight init systems like runit, which I find to be an exciting
prospect.
But just how much smaller is NixNG in practice, compared to an image
based on the original NixOS? I created both images to compare their
sizes.
The experiment
The official Nix image is available on DockerHub. I built
a comparable NixNG image that includes only the Nix package manager and
then compared the sizes of the two.
| Distro | Package | Base image/Build |
|---|---|---|
| Official Nix | Nix 2.32.2 | DockerHub nixos/nix:2.32.2
|
| NixNG | Nix 2.32.2 | Built using the method below |
I ensured that the platform was consistent: x86_64-linux.
NixNG build flake setup
I set up a minimal flake project for the test.
flake.nix:
{
inputs = {
nixng.url = "github:nix-community/NixNG";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs =
{
self,
nixng,
nixpkgs,
...
}:
{
examples.nixng-nix = import ./examples/nixng-nix.nix {
inherit (nixng) nglib;
inherit nixpkgs;
system = "x86_64-linux";
};
};
}
The system of interest for comparison is defined in
examples.nixng-nix, based on
an example from the NixNG repository:
examples/nixng-nix.nix:
{
nglib,
nixpkgs,
system,
}:
nglib.makeSystem {
inherit nixpkgs;
inherit system;
name = "nixng-nix";
config =
{ pkgs, ... }:
{
dumb-init = {
enable = true;
type.shell = { };
};
nix = {
enable = true;
package = pkgs.nixVersions.nix_2_32;
config = {
experimental-features = [
"nix-command"
"flakes"
];
sandbox = false;
};
};
};
}
Build and load the OCI image
I generated and loaded the Docker image tar file:
$ docker run --rm --platform linux/amd64 -v $(pwd):/work -w /work \
nixos/nix:2.32.2 bash -c '
{
echo "filter-syscalls = false"
echo "experimental-features = nix-command flakes"
} >> /etc/nix/nix.conf
nix build .#examples.nixng-nix.config.system.build.ociImage.stream
./result > nixng-nix-image.tar
'
$ docker image load -i nixng-nix-image.tar
Note: Since I use Docker Desktop on an ARM Mac, I
had to add filter-syscalls = false to the Nix configuration
to avoid an error during the build.
The result
With the official Nix image already available, I checked the sizes:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
nixos/nix 2.32.2 f9b3c7811e27 55 years ago 436MB
nixos/nix latest f9b3c7811e27 55 years ago 436MB
nixng-nix latest 26361447b07f 55 years ago 356MB
The official image was 436MB, while the NixNG image came in
at 356MB. That's a size reduction of 80MB (approximately
18%).
Final thoughts
To be blunt, the default advice for minimizing container size is
often: "Use Alpine or Distroless!"
However, if committed to using Nix in a project and want to
save a bit on cloud storage or bandwidth costs, NixNG should be
a viable option.
Translated from the original post
at https://m15a.dev/ja/posts/nixng-image-size/.
This content originally appeared on DEV Community and was authored by NACAMURA Mitsuhiro
NACAMURA Mitsuhiro | Sciencx (2025-11-08T09:48:27+00:00) How much smaller are NixNG container images compared to NixOS, really?. Retrieved from https://www.scien.cx/2025/11/08/how-much-smaller-are-nixng-container-images-compared-to-nixos-really/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.