Can I build an app for F-Droid via Nix?

Hey,

I’ve been trying to figure out if it’s possible to build our app - Status.im - for F-Droid in this GitHub issue:

And I’m having some serious issues trying to get anything to work. So I’m just going to ask here in case what I’m trying to do is actually impossible with F-Droid.

My understanding is that F-Droid is opinionated about how to run Gradle, and wants to run it itself, to build the APK. That does not seem compatible with how we build our app, which is using the Nix Package Manager.

Nix is a package manager that can be installed on top of any Linux OS and puts its files under /nix and requires root permissions to be installed.

The way we build it is via Nix derivation, that you can find the exact place where we run Gradle here:

The way that is called is for example via the release-android target in our Makefile:

Which in turn runs a script that calls Nix:
https://github.com/status-im/status-react/blob/develop/scripts/release-android.sh

The crucial question is:

Can this process be ported as-is to F-Droid? Or does F-Droid have to run Gradle itself?

I still have one issue. I’m getting the following errors:

ERROR: Found unknown maven repo '(' at android/build.gradle
ERROR: Found unknown maven repo '(' at android/build.gradle

Due to the following lines:

And I’m not sure what to do about that. I know they are the issue because the errors don’t show up after I’ve removed the lines using:

    prebuild:
      - sed -i '54,61d' android/build.gradle

But I don’t think the app will build without those.
It was suggested by @licaon-kter that I could set:

    scanignore:
      - android/build.gradle

But that just resulted in:

ERROR: Unused scanignore path: android/build.gradle

So not sure what I’m supposed to do.

I got some answers from lovely @licaon-kter at GigHub while working on my issue.

First of all I can avoid F-Droid wanting to run Gradle by NOT setting:

    gradle:
      - yes

Secondly, it appears that I will have available root permissions via the sudo metadata setting. So that means I can create the required /nix folder where Nix will be installed.

In case of using a Docker container I had to create the user and the folder with my own Dockerfile

FROM registry.gitlab.com/fdroid/docker-executable-fdroidserver:latest
RUN useradd -u 1000 builder
RUN mkdir -m 0755 /nix && chown builder /nix

F-Droid provides all the pieces that you get from Nix, so it seems redundant

That’s kinda irrelevant considering our build process uses Nix.

If you’re using nix to setup gradle, then there are many ways to get
gradle setup, then the rest of the build would be standard. I see no
reason to tie a standard Android gradle build to any particular OS or
package manager.

If you’re doing other tricks with Nix, then you’ll be the pathfinder on
that one. All I’m saying is don’t expect things to just work with
non-standard Android build setups, and I wish you all the best with your
nix tricks.

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.