-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathflake.nix
109 lines (100 loc) · 3.5 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{
description = "Moxxy v2";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
bab.url = "git+https://codeberg.org/PapaTutuWawa/bits-and-bytes.git";
};
outputs = { self, nixpkgs, flake-utils, bab }: flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
allowUnfree = true;
# Fix to allow building the NDK package
# TODO: Remove once https://github.com/tadfisher/android-nixpkgs/issues/62 is resolved
# permittedInsecurePackages = [
# "python-2.7.18.6"
# "openssl-1.1.1w"
# ];
};
};
# Everything to make Flutter happy
android = pkgs.androidenv.composeAndroidPackages {
# TODO: Find a way to pin these
#toolsVersion = "26.1.1";
#platformToolsVersion = "31.0.3";
#buildToolsVersions = [ "31.0.0" ];
#includeEmulator = true;
#emulatorVersion = "30.6.3";
cmakeVersions = [ "3.18.1" ];
platformVersions = [ "30" "31" "32" "33" "34" ];
ndkVersions = [ "21.4.7075529" "23.1.7779620" ];
buildToolsVersions = [ "30.0.3" "33.0.2" "34.0.0" ];
includeSources = false;
includeSystemImages = false;
systemImageTypes = [ "default" ];
abiVersions = [ "x86_64" "arm6" ];
includeNDK = true;
useGoogleAPIs = false;
useGoogleTVAddOns = false;
};
lib = pkgs.lib;
babPkgs = bab.packages."${system}";
pinnedJDK = pkgs.jdk17;
flutterVersion = pkgs.flutter;
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
requests pyyaml # For the build scripts
pycryptodome # For the Monal UDP Logger
]);
in {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
# Android
pinnedJDK android.platform-tools ktlint
scrcpy
# Flutter
flutterVersion
# Build scripts
pythonEnv gnumake
# Code hygiene
gitlint jq ripgrep
];
ANDROID_SDK_ROOT = "${android.androidsdk}/libexec/android-sdk";
ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk";
JAVA_HOME = pinnedJDK;
# Fix an issue with Flutter using an older version of aapt2, which does not know
# an used parameter.
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${android.androidsdk}/libexec/android-sdk/build-tools/34.0.0/aapt2";
};
apps = let
providerArg = pkgs.writeText "provider-arg.cfg" ''
name = OpenSC-PKCS11
description = SunPKCS11 via OpenSC
library = ${pkgs.opensc}/lib/opensc-pkcs11.so
slotListIndex = 0
'';
mkBuildScript = skipBuild: pkgs.writeShellScript "build-moxxy.sh" ''
${babPkgs.flutter-build}/bin/flutter-build \
--name Moxxy \
--not-signed \
--zipalign ${android.androidsdk}/libexec/android-sdk/build-tools/34.0.0/zipalign \
--apksigner ${android.androidsdk}/libexec/android-sdk/build-tools/34.0.0/apksigner \
--pigeon ./pigeon/quirks.dart \
--flutter ${flutterVersion}/bin/flutter \
--provider-config ${providerArg} ${lib.optionalString skipBuild "--skip-build"}
'';
in {
# Skip the build and just sign
onlySign = {
type = "app";
program = "${mkBuildScript true}";
};
# Build everything and sign
build = {
type = "app";
program = "${mkBuildScript false}";
};
};
});
}