NixOS port for Fairphone 5
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-30 01:00:21 +02:00
.docs Add pictures to README.md 2025-11-15 18:19:23 +01:00
hosts feat: add configuration en_US,fr_FR for typing-booster dictionary 2026-09-30 01:00:10 +02:00
modules feat(gnome-mobile): enable IBus Typing Booster 2026-09-30 01:00:21 +02:00
overlays Switch to U-Boot 2026-09-06 17:26:19 +02:00
packages feat: Enable Fairphone 5 call audio with Q6 Voice and UCM routing 2026-09-29 02:08:31 +00:00
.gitignore Switch to U-Boot 2026-09-06 17:26:19 +02:00
AGENTS.md Switch to U-Boot 2026-09-06 17:26:19 +02:00
flake.lock Switch to U-Boot 2026-09-06 17:26:19 +02:00
flake.nix fix: disable Firefox PGO to prevent out-of-memory build failures 2026-09-28 13:07:41 +00:00
README.md Update README.md 2026-09-06 17:26:19 +02:00

NixOS on Fairphone 5

This repository aims to port NixOS to the Fairphone 5, a modular and sustainable smartphone. The goal is to provide a fully functional NixOS system that can run on the Fairphone 5, and to support as many of its hardware features as possible.

The Fairphone 5 uses a Qualcomm QCM6490 SoC, which is based on the ARM architecture and is very similar to the Qualcomm SC7280 SoC found in various other devices. This repository builds on existing work by the amazing PostmarketOS community, mainly their work on porting the Linux kernel and other essential components to the Fairphone 5. For more information regarding the status of the port, see the Fairphone 5 page in the PostmarketOS Wiki.

Home screen on Fairphone 5 running NixOS with GNOME Mobile Terminal on Fairphone 5 running NixOS with GNOME Mobile

Current Status

Supported Hardware

  • Audio: Works (speaker and microphone)
  • Battery: Works
  • Bluetooth: Works (with audio support)
  • Camera: Selfie and wide-angle cameras work (quality is not amazing)
  • Cellular modem: Works
  • Screen: Works
  • Sensors: Partially works
    • Accelerometer: Reports the correct device orientation, but GNOME Mobile 48 autorotate does not work for some reason
    • Ambient light: Detected, but only reports an initial value of 0 lux without useful updates
  • Touchscreen: Works
  • Wi-Fi: Works

Additional details will be added here as development progresses.

Note: Hardware was tested using the GNOME Mobile builds. When using the minimal images, the device boots up and the screen works, but the device has to be controlled remotely over USB Serial or SSH, because there is no virtual keyboard (and thus no way to log in on the device itself).

Getting Started

Caution

Cross-compilation is currently not supported, so you need to build the images on an aarch64-linux NixOS host. However, because Nix has excellent support for remote builders, you can also delegate the build to a remote aarch64 builder (more info can be found further down below).

Prerequisites:

  • A Fairphone 5 device, obviously :)
  • The device must have an unlocked bootloader. Follow the instructions on the Fairphone 5 page in the PostmarketOS Wiki if you haven't done this yet.
  • An aarch64-linux NixOS host to build the images. Other distributions that have Nix installed may also work, but have not been tested. Alternatively, you can use a remote builder from any Nix-enabled system.

Optional: Set up Remote Builder

I recommend using nixbuild.net as a remote builder. It's pretty easy to set up, works well in my testing, and they provide the necessary aarch64-linux builders. The builds of each derivation are even cached, so subsequent builds are usually pretty fast!

First, set up an account, add your SSH public key to the service as described in their getting started guide. Note: You don't need to set their server as a builder for your entire NixOS configuration as described in their guide (section "Quick NixOS Configuration"); you can simply set the programs.ssh.extraConfig and programs.ssh.knownHosts options in your config as described in their guide, and ignore the nix.distributedBuilds and nix.buildMachines options. This way, you can use the remote builder on-demand as needed.

Verify whether you are able to connect to their server via SSH:

sudo ssh eu.nixbuild.net shell

If you're able to connect, you're ready to use the remote builder to build your images.

Add Module to your NixOS Configuration

If you want to use NixOS on your own Fairphone 5, the example configurations provided by this repository will probably not be sufficient. Add the Fairphone 5 module to your own configuration and expose the two image artifacts (for the initial flash) like this:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixos-fairphone-fp5.url = "github:gian-reto/nixos-fairphone-fp5";
  };

  outputs = { self, nixpkgs, nixos-fairphone-fp5, ... }: {
    nixosConfigurations.my-fairphone = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";
      modules = [
        # Import the Fairphone 5 NixOS module.
        nixos-fairphone-fp5.nixosModules.default

        # Import your own custom configuration.
        ./hosts/my-fairphone/default.nix
      ];
    };

    # Use the `mkUbootImage` and `mkDiskImage` functions provided by this flake to be able to build
    # boot and rootfs images from your custom configuration, so you can easily flash the first
    # generation of your configuration to your Fairphone 5 using `fastboot`.
    packages.aarch64-linux =
      let
        pkgs = nixpkgs.legacyPackages.aarch64-linux;
      in {
        # U-Boot image for an Android boot slot.
        uboot-image = nixos-fairphone-fp5.lib.mkUbootImage pkgs;

        # Nested GPT image containing the ESP and your complete NixOS system.
        disk-image = nixos-fairphone-fp5.lib.mkDiskImage
          self.nixosConfigurations.my-fairphone;
      };
  };
}

Build and Flash Images

Caution

Flashing the image permanently erases everything in userdata, including Android apps, files, and settings. Back up anything you need before continuing.

Tip

If you use remote builders, I recommend configuring Nix to always use remote builders by default on your Fairphone. This way, you don't have to rebuild locally on your phone when running nixos-rebuild boot or nixos-rebuild switch. Otherwise, builds might take a very long time or even fail due to insufficient resources.

  1. Build both images from the configuration shown above:

    nix build .#packages.aarch64-linux.uboot-image --out-link result-uboot
    nix build .#packages.aarch64-linux.disk-image --out-link result-disk
    

    To delegate your configuration's builds to nixbuild.net, run:

    nix build .#packages.aarch64-linux.uboot-image --out-link result-uboot --max-jobs 0 --builders "ssh://eu.nixbuild.net aarch64-linux - 100 1 big-parallel,benchmark" --option builders-use-substitutes true
    nix build .#packages.aarch64-linux.disk-image --out-link result-disk --max-jobs 0 --builders "ssh://eu.nixbuild.net aarch64-linux - 100 1 big-parallel,benchmark" --option builders-use-substitutes true
    
  2. Turn off the phone, then hold Volume Down and Power until the fastboot screen appears.

  3. Connect the phone to the build host over USB-C.

  4. From the directory containing result-uboot and result-disk, start a shell containing the fastboot tools:

    nix shell nixpkgs#android-tools
    
  5. Flash the images and reboot:

    fastboot flash boot result-uboot
    fastboot erase dtbo
    fastboot flash userdata result-disk/image.raw
    fastboot reboot
    

The first boot may take a while while the root filesystem expands to the available space.

Important

When booting NixOS, the display will show various artifacts, and the screen will be black for a brief moment. This is expected behavior and doesn't mean something is wrong. Just wait a bit until the device has fully booted and the login prompt or screen appears.

Restore Android

Caution

Reinstalling Android erases NixOS and everything in userdata. It cannot recover previous Android user data.

Reinstall Fairphone OS using Fairphone's official manual installation instructions.

Advanced Usage

In some advanced use cases, you might want to change the process of building the images, or do other customizations. In that case, you can use the fairphone-fp5 overlay provided by this flake directly, which allows you to use the included packages in the way you want.

{
  inputs.nixos-fairphone-fp5.url = "github:gian-reto/nixos-fairphone-fp5";

  outputs = { nixpkgs, nixos-fairphone-fp5, ... }: {
    nixosConfigurations.my-fairphone = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";
      modules = [
        {
          nixpkgs.overlays = [ nixos-fairphone-fp5.overlays.default ];

          # Now you have access to all Fairphone packages:
          # pkgs.kernel-fairphone-fp5
          # pkgs.firmware-fairphone-fp5
          # pkgs.uboot-fairphone-fp5
          # pkgs.pd-mapper, pkgs.qrtr, pkgs.rmtfs, etc.
        }
        # Your custom configuration...
      ];
    };
  };
}

Development & Contribution

This flake outputs the uboot-image package, as well as disk-image-minimal and disk-image-gnome-mobile packages for the example host configurations in ./hosts. These can be built and flashed as described above. By default, the example user is called "admin", and the password is "admin" as well.

At the moment, the development process is mostly done by changing code, building new images, and then testing them on the device. This can be quite tedious, as the build times are relatively long (even with a remote builder), but for now this is the best way to make sure everything works as expected on the actual hardware.

AI

The development in this repository is partially assisted by AI tools. Contributions made with the help of AI are welcome, provided that they are reviewed and tested by human contributors to ensure quality and correctness.

Coding agents must adhere to the instructions and guidelines outlined in AGENTS.md when working in this repository.

Thanks

  • Huge thanks to the PostmarketOS community for their incredible work on porting Linux to the Fairphone 5 (especially to Luca Weiss, the main maintainer of the Fairphone ports) and other devices. Their efforts have laid the groundwork for this NixOS port, and their documentation and resources have been invaluable throughout the development process.
  • Special thanks to Marcus Ramberg for his extensive work on his NixOS Fairphone 5 fork, which provided valuable implementations for many of this project's improvements (U-Boot, speaker and microphone support, light sensor and camera improvements, etc.).
  • This port was also inspired by MatthewCroughan/nixos-qcm6490, which is an attempt to port NixOS to the SHIFTphone 8 (otter), which uses the same SoC as the Fairphone 5. Not sure if the port was successful, but the code was still an invaluable reference. Thanks, Matthew!
  • chuangzhu/nixpkgs-gnome-mobile was an invaluable resource for getting GNOME Mobile to work on NixOS.