nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 flutter332,
4 fetchFromGitHub,
5 sqlite,
6 libayatana-appindicator,
7 makeDesktopItem,
8 copyDesktopItems,
9 makeWrapper,
10 jdk17_headless,
11 yq-go,
12}:
13let
14 # fetch simple-icons directly to avoid cloning with submodules,
15 # which would also clone a whole copy of flutter
16 simple-icons = fetchFromGitHub (lib.importJSON ./simple-icons.json);
17 desktopId = "io.ente.auth";
18in
19flutter332.buildFlutterApplication rec {
20 pname = "ente-auth";
21 version = "4.4.12";
22
23 src = fetchFromGitHub {
24 owner = "ente-io";
25 repo = "ente";
26 sparseCheckout = [ "mobile" ];
27 tag = "auth-v${version}";
28 hash = "sha256-1GJWGTzErV+wSkeAg3z0u7tBPFrq6hPc0fWniKT8w9M=";
29 };
30
31 sourceRoot = "${src.name}/mobile/apps/auth";
32
33 pubspecLock = lib.importJSON ./pubspec.lock.json;
34 gitHashes = lib.importJSON ./git-hashes.json;
35
36 patches = [
37 # Disable update notifications and auto-update functionality
38 ./0001-disable-updates.patch
39 ];
40
41 postPatch = ''
42 rmdir assets/simple-icons
43 ln -s ${simple-icons} assets/simple-icons
44 ${lib.getExe yq-go} -i 'del(.dependencies.sqlite3_flutter_libs)' pubspec.yaml
45 '';
46
47 nativeBuildInputs = [
48 copyDesktopItems
49 makeWrapper
50 ];
51
52 buildInputs = [
53 sqlite
54 libayatana-appindicator
55 # The networking client used by ente-auth (native_dio_adapter)
56 # introduces a transitive dependency on Java, which technically
57 # is only needed for the Android implementation.
58 # Unfortunately, attempts to remove it from the build entirely were
59 # unsuccessful.
60 jdk17_headless # JDK version used by upstream CI
61 ];
62
63 # https://github.com/juliansteenbakker/flutter_secure_storage/issues/965
64 CXXFLAGS = [ "-Wno-deprecated-literal-operator" ];
65
66 # Based on https://github.com/ente-io/ente/blob/main/auth/linux/packaging/rpm/make_config.yaml
67 # and https://github.com/ente-io/ente/blob/main/auth/linux/packaging/enteauth.appdata.xml
68 desktopItems = [
69 (makeDesktopItem {
70 name = desktopId;
71 exec = "enteauth";
72 icon = "enteauth";
73 desktopName = "Ente Auth";
74 genericName = "Ente Authentication";
75 comment = "Open source 2FA authenticator, with end-to-end encrypted backups";
76 categories = [ "Utility" ];
77 keywords = [
78 "Authentication"
79 "2FA"
80 ];
81 mimeTypes = [ "x-scheme-handler/enteauth" ];
82 startupNotify = false;
83 })
84 ];
85
86 postInstall = ''
87 mkdir -p $out/share/pixmaps
88 ln -s $out/app/ente-auth/data/flutter_assets/assets/icons/auth-icon.png $out/share/pixmaps/enteauth.png
89
90 install -Dm444 linux/packaging/enteauth.appdata.xml $out/share/metainfo/${desktopId}.metainfo.xml
91 substituteInPlace $out/share/metainfo/${desktopId}.metainfo.xml \
92 --replace-fail '<id>enteauth</id>' '<id>${desktopId}</id>' \
93 --replace-fail 'enteauth.desktop' '${desktopId}.desktop'
94
95 # For backwards compatibility
96 ln -s $out/bin/enteauth $out/bin/ente_auth
97
98 # Not required at runtime as it's only used on Android
99 rm $out/app/ente-auth/lib/libdartjni.so
100 '';
101
102 passthru.updateScript = ./update.sh;
103
104 meta = {
105 description = "End-to-end encrypted, cross platform and free app for storing your 2FA codes with cloud backups";
106 longDescription = ''
107 Ente's 2FA app. An end-to-end encrypted, cross platform and free app for storing your 2FA codes with cloud backups. Works offline. You can even use it without signing up for an account if you don't want the cloud backups or multi-device sync.
108 '';
109 homepage = "https://ente.io/auth/";
110 changelog = "https://github.com/ente-io/ente/releases/tag/auth-v${version}";
111 license = lib.licenses.agpl3Only;
112 maintainers = with lib.maintainers; [
113 niklaskorz
114 schnow265
115 zi3m5f
116 gepbird
117 ];
118 mainProgram = "enteauth";
119 platforms = [
120 "x86_64-linux"
121 "aarch64-linux"
122 ];
123 };
124}