Pixel 7 — GrapheneOS with robotnix

Overview

Custom GrapheneOS image for Pixel 7 (codename panther), built declaratively with robotnix. The image includes F-Droid with a privileged extension (automatic installs), SeedVault as the system backup transport, and a GrapheneOS OTA updater pointing at a self-hosted server. A private F-Droid repository on the NixOS server acts as a selective mirror — it hosts only curated apps and the phone auto-installs everything in it.

NixOS modules:

Module Purpose
hosts/pixel7/robotnix/configuration.nix robotnix build config (device, flavor, apps)
modules/features/fdroid-repo.nix fdroidserver service, nginx, daily update timer
modules/features/ota-server.nix nginx serving OTA zips at ota.yhkze.net

Domains:

Domain Service
fdroid.yhkze.net Private F-Droid repo (Traefik → nginx :8093)
ota.yhkze.net GrapheneOS OTA updates (Traefik → nginx :8094)

Prerequisites

Android signing keys

Robotnix needs a set of Android signing keys for APK and verified boot (AVB) signing. These keys are generated once and must never be regenerated — changing them breaks the OTA update chain and verified boot. The keys live on the server at /persist/pixel7-keys/ outside the Nix store.

Build the key generation script first. This is a thin wrapper around Android’s make_key and avbtool that creates all the required key pairs (releasekey, platform, shared, media, networkstack, and an AVB key).

nix build path:.#pixel7-generateKeysScript -o generate-keys

Run it, passing the target directory. The script prompts for passwords — leaving them empty produces an unencrypted keystore (protected by filesystem permissions, not encryption at rest).

./generate-keys /persist/pixel7-keys

This directory must be backed up. Losing these keys means no compatible OTA update can ever be produced for a phone flashed with them.

Private F-Droid repository

The F-Droid repository is managed by fdroidserver and served by nginx at fdroid.yhkze.net. The repository holds only curated apps, and the phone’s F-Droid client is configured with pushRequests = "always" for this repo, meaning every app in it gets auto-installed silently on provision via the privileged extension.

Initializing the repository

SSH into the server. The fdroid-repo.nix module creates a fdroid system user and persists its working directory at /persist/fdroid-repo. The fdroidserver workspace needs to be initialized there, which generates a signing keystore for the repository index.

cd /persist/fdroid-repo
sudo -u fdroid fdroid init

fdroidserver asks for a keystore password. Generate one and note it down — it goes into the SOPS vault in the next step. The command creates keystore.p12 (the repo signing key) along with an empty repo/ directory and a skeleton config.yml.

There is no need to hand-edit config.yml. The systemd service overwrites it on each run with the correct values, substituting the keystore password from the SOPS secret.

Adding the keystore password to SOPS

The fdroidserver module expects a SOPS secret at fdroid-repo/keystorepass. Add it to the server’s secrets vault:

fdroid-repo:
  # the password chosen during fdroid init
  keystorepass:

Extracting the repo public key

After the first fdroid update runs (either via the timer or manually with sudo -u fdroid fdroid update), the repo index is signed and the public key fingerprint can be extracted. This fingerprint goes into the robotnix configuration so the phone trusts the repo.

keytool -printcert -file /persist/fdroid-repo/repo/index-v2.jar \
  | grep "SHA-256" | sed 's/.*: //' | tr -d ':' | tr '[:lower:]' '[:upper:]'

Copy the output and paste it into hosts/pixel7/robotnix/configuration.nix as the pubkey value in apps.fdroid.additionalRepos.personal.

Adding apps to the repository

Each app lives as a metadata YAML file in /persist/fdroid-repo/metadata/. The filename is the app’s package ID with a .yml extension. The key fields are Binaries (URL template for the upstream APK) and AllowedAPKSigningKeys (SHA-256 fingerprint of the upstream developer’s signing certificate). When fdroidserver runs checkupdates and update, it fetches the latest APK from the URL, verifies its signature matches the allowed key, and adds it to the repo index. No manual APK downloading required.

Here is an example for Aurora Store. Create /persist/fdroid-repo/metadata/com.aurora.store.yml:

Categories:
  - System
License: GPL-3.0-only
SourceCode: https://gitlab.com/AuroraOSS/AuroraStore
AutoName: Aurora Store

RepoType: git
Repo: https://gitlab.com/AuroraOSS/AuroraStore.git

Builds: []

UpdateCheckMode: HTTP
UpdateCheckData: >-
  https://gitlab.com/api/v4/projects/AuroraOSS%2FAuroraStore/releases|"tag_name":"([0-9.]+)"|.|"tag_name":"([0-9.]+)"

Binaries: https://gitlab.com/AuroraOSS/AuroraStore/-/releases/%v/downloads/AuroraStore_%v.apk

AllowedAPKSigningKeys: <sha256-fingerprint-of-aurora-signing-cert>

AutoUpdateMode: Version
CurrentVersion: 4.6.2
CurrentVersionCode: 46

To get the signing key fingerprint for an APK:

apksigner verify --print-certs AuroraStore.apk | grep "SHA-256"

Or with keytool:

keytool -printcert -jarfile AuroraStore.apk | grep "SHA-256"

Repeat for each desired app (Syncthing-Fork, etc). After adding metadata files, either wait for the daily timer or trigger manually:

sudo -u fdroid bash -c 'cd /persist/fdroid-repo && fdroid checkupdates && fdroid update'

The repo index is rebuilt and the new APK becomes available at fdroid.yhkze.net.

Building the image

The image can be built on any x86_64-linux machine — it does not need to run on the server. GrapheneOS builds are resource-intensive: expect several hours on the first build (subsequent builds are faster with Nix’s build cache). The build fetches AOSP source, GrapheneOS patches, and vendor blobs (extracted automatically by adevtool).

Signing happens outside the Nix sandbox via releaseScript, avoiding the need for sandbox path exceptions for the signing keys.

Build the release script:

nix build path:.#pixel7-releaseScript -o release-script

Run it, pointing at the key directory and an output directory:

./release-script /persist/pixel7-keys /tmp/pixel7-signed

The output directory contains the signed factory image (for initial flashing) and signed OTA zip (for subsequent updates).

Initial flash

Unlock the bootloader on the Pixel 7 (Settings → System → Developer options → OEM unlocking). Reboot into fastboot mode (hold Power + Volume Down).

Flash the factory image:

cd /tmp/pixel7-signed
fastboot update panther-factory-*.zip

After the phone boots, re-lock the bootloader for verified boot:

fastboot flashing lock

The phone boots into GrapheneOS with F-Droid pre-installed. If the private F-Droid repo is already populated and the server is reachable, apps begin auto-installing within a few minutes.

OTA updates

To push an OS update, rebuild and re-sign the image (same releaseScript flow as above), then deploy the OTA zip and its metadata to the server:

rsync /tmp/pixel7-signed/panther-ota-*.zip server:/persist/ota/
rsync /tmp/pixel7-signed/metadata/ server:/persist/ota/

The GrapheneOS updater app on the phone polls ota.yhkze.net on a schedule. When it sees a new OTA, it downloads and installs it in the background with A/B seamless updates — no user interaction required beyond a reboot prompt.

SeedVault backup to OpenCloud

SeedVault is included as the system backup transport in the image. The backup destination is configured at runtime inside the app, not at build time.

Open the SeedVault app (Settings → System → Backup). Choose “Custom cloud (WebDAV)” as the storage backend and enter:

The seedvault account is created in the Keycloak realm internal first, in the opencloud_service_group group; OpenCloud provisions it on its first sign-in.

Syncthing

Syncthing-Fork auto-installs from the private F-Droid repo (if the metadata file was added) or can be installed from IzzyOnDroid. The device ID is found under the hamburger menu → Show device ID.

Add the device ID to modules/features/syncthing.nix by replacing the placeholder in the phone entry of deviceIds and uncommenting "phone" in the server’s peers list. Rebuild the server.

The phone then appears as a Syncthing peer and can share folders with the server using the same hub-spoke topology as the other hosts.

FLAG_SECURE (screenshots in protected apps)

FLAG_SECURE is an Android framework flag that apps set to prevent screenshots and screen recording of their windows (banking apps, password managers, etc.). Stock GrapheneOS does not provide a way to bypass this — the “Private screenshots” feature only strips metadata from screenshots, it does not override FLAG_SECURE.

Disabling FLAG_SECURE globally requires a source-level patch to the Android framework via source.dirs in the robotnix config. The patch needs to target the screenshot enforcement check in frameworks/base, typically in WindowState.java or ScreenshotController.java. The exact file and pattern depend on the Android version GrapheneOS is based on and must be verified against the current source tree before building.

A placeholder is included in hosts/pixel7/robotnix/configuration.nix. Once the correct patch is identified, it would look something like:

source.dirs."frameworks/base".postPatch = ''
  # Example — verify file and pattern against current GrapheneOS source
  sed -i 's/isSecureLocked()/false/' \
    services/core/java/com/android/server/wm/ScreenshotController.java
'';