Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add treefmt and re-format codebase #237

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/grapheneos-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
# buildNumber is the only quoted string inside upstream-params.nix so we can
# just use grep to extract the first quoted string and use xargs to strip the
# quotes
OLD_BUILD_NUMBER=$(grep -o -m 1 '"[^"]*"' ./flavors/grapheneos/upstream-params.nix | xargs)
echo "OLD_BUILD_NUMBER=$OLD_BUILD_NUMBER" | tee -a $GITHUB_ENV
OLD_BUILD_NUMBER="$(grep -o -m 1 '"[^"]*"' ./flavors/grapheneos/upstream-params.nix | xargs)"
echo "OLD_BUILD_NUMBER=$OLD_BUILD_NUMBER" | tee -a "$GITHUB_ENV"

nix develop -c ./flavors/grapheneos/extract-upstream-params.sh

NEW_BUILD_NUMBER=$(grep -o -m 1 '"[^"]*"' ./flavors/grapheneos/upstream-params.nix | xargs)
echo "NEW_BUILD_NUMBER=$NEW_BUILD_NUMBER" | tee -a $GITHUB_ENV
NEW_BUILD_NUMBER="$(grep -o -m 1 '"[^"]*"' ./flavors/grapheneos/upstream-params.nix | xargs)"
echo "NEW_BUILD_NUMBER=$NEW_BUILD_NUMBER" | tee -a "$GITHUB_ENV"
- name: "Update devices"
if: env.OLD_BUILD_NUMBER != env.NEW_BUILD_NUMBER
run: |
for DEVICE in crosshatch sunfish oriole; do
METADATA=$(curl -sSfL "https://releases.grapheneos.org/$DEVICE-beta")
BUILD_PREFIX=$(echo "$METADATA" | cut -d" " -f3)
METADATA="(curl -sSfL "https://releases.grapheneos.org/$DEVICE-beta")"
BUILD_PREFIX="$(echo "$METADATA" | cut -d" " -f3)"
git mv "./flavors/grapheneos/repo-$BUILD_PREFIX.$OLD_BUILD_NUMBER.json" \
"./flavors/grapheneos/repo-$BUILD_PREFIX.$NEW_BUILD_NUMBER.json"
nix develop -c ./flavors/grapheneos/update.sh "$BUILD_PREFIX.$NEW_BUILD_NUMBER"
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/instantiate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ jobs:
extra_nix_config: |
experimental-features = nix-command flakes
- run: |
nix run github:nix-community/nix-eval-jobs/3f305f4538e056e6f6f775e1f75410b6d4d8d9aa -- --workers $(nproc) --option allow-import-from-derivation false --show-trace ./release.nix | tee eval.json
nix run github:nix-community/nix-eval-jobs/3f305f4538e056e6f6f775e1f75410b6d4d8d9aa -- --workers "$(nproc)" --option allow-import-from-derivation false --show-trace ./release.nix | tee eval.json
jq -c 'select(.error)' eval.json | tee errors.json
if [[ "$(wc -l < errors.json)" > 0 ]]; then exit 1; fi
if [[ "$(wc -l < errors.json)" -gt 0 ]]; then exit 1; fi
robotnix-eval-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: cachix/install-nix-action@v12
- run: |
OUTPUT=$(nix-instantiate --eval --strict tests/eval.nix)
OUTPUT="$(nix-instantiate --eval --strict tests/eval.nix)"
if [[ "$OUTPUT" != "[ ]" ]]; then
echo "Instantiation tests failed:"
echo $OUTPUT
echo "$OUTPUT"
fi
nixos-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -55,10 +55,10 @@ jobs:
experimental-features = nix-command flakes
- run: |
nix flake check
export ORIG_DIR=$PWD
cd $(mktemp -d)
nix flake init -t $ORIG_DIR
nix flake check --override-input robotnix $ORIG_DIR
export ORIG_DIR="$PWD"
cd "$(mktemp -d)"
nix flake init -t "$ORIG_DIR"
nix flake check --override-input robotnix "$ORIG_DIR"
checks:
runs-on: ubuntu-latest
steps:
Expand Down
42 changes: 31 additions & 11 deletions apks/auditor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@
# SPDX-License-Identifier: MIT

# https://www.reddit.com/r/GrapheneOS/comments/bpcttk/avb_key_auditor_app/
{ callPackage, lib, stdenv, pkgs, substituteAll, fetchFromGitHub,
androidPkgs, jdk11_headless, gradle, gradleToNixPatchedFetchers,
{
callPackage,
lib,
stdenv,
pkgs,
substituteAll,
fetchFromGitHub,
androidPkgs,
jdk11_headless,
gradle,
gradleToNixPatchedFetchers,
domain ? "example.org",
applicationName ? "Robotnix Auditor",
applicationId ? "org.robotnix.auditor",
signatureFingerprint ? "", # Signature that this app will be signed by.
device ? "",
avbFingerprint ? ""
avbFingerprint ? "",
}:
let
androidsdk = androidPkgs.sdk (p: with p; [ cmdline-tools-latest platform-tools platforms-android-30 build-tools-30-0-3 ]);
buildGradle = callPackage ./gradle-env.nix {};
androidsdk = androidPkgs.sdk (
p: with p; [
cmdline-tools-latest
platform-tools
platforms-android-30
build-tools-30-0-3
]
);
buildGradle = callPackage ./gradle-env.nix { };
supportedDevices = import ./supported-devices.nix;
in
buildGradle rec {
Expand All @@ -31,12 +47,16 @@ buildGradle rec {

patches = [
# TODO: Enable support for passing multiple device fingerprints
(substituteAll ({
src = ./customized-auditor.patch;
inherit domain applicationName applicationId ;
signatureFingerprint = lib.toUpper signatureFingerprint;
}
// lib.genAttrs supportedDevices (d: if (device == d) then avbFingerprint else "DISABLED_CUSTOM_${d}")))
(substituteAll (
{
src = ./customized-auditor.patch;
inherit domain applicationName applicationId;
signatureFingerprint = lib.toUpper signatureFingerprint;
}
// lib.genAttrs supportedDevices (
d: if (device == d) then avbFingerprint else "DISABLED_CUSTOM_${d}"
)
))

# TODO: Ugly downgrades due to not being able to update to gradle 7.0.2, since its not working with gradle2nix
./build-hacks.patch
Expand Down
Loading