ente-auth: init at 4.0.2

This commit is contained in:
Niklas Korz 2024-09-29 17:13:27 +02:00
parent 17fb773308
commit fcea60c49c
4 changed files with 2431 additions and 0 deletions

View File

@ -0,0 +1,117 @@
{
lib,
flutter324,
fetchFromGitHub,
webkitgtk,
sqlite,
libayatana-appindicator,
makeDesktopItem,
copyDesktopItems,
imagemagick,
makeWrapper,
xdg-user-dirs,
}:
let
# fetch simple-icons directly to avoid cloning with submodules,
# which would also clone a whole copy of flutter
simple-icons = fetchFromGitHub (lib.importJSON ./simple-icons.json);
in
flutter324.buildFlutterApplication rec {
pname = "ente-auth";
version = "4.0.2";
src = fetchFromGitHub {
owner = "ente-io";
repo = "ente";
sparseCheckout = [ "auth" ];
rev = "auth-v${version}";
hash = "sha256-me+fT79vwqBBNsRWWo58GdzBf58LNB4Mk+pmCLvn/ik=";
};
sourceRoot = "${src.name}/auth";
pubspecLock = lib.importJSON ./pubspec.lock.json;
patchPhase = ''
rmdir assets/simple-icons
ln -s ${simple-icons} assets/simple-icons
'';
gitHashes = {
desktop_webview_window = "sha256-jdNMpzFBgw53asWlGzWUS+hoPdzcL6kcJt2KzjxXf2E=";
ente_crypto_dart = "sha256-XBzQ268E0cYljJH6gDS5O0Pmie/GwuhMDlQPfopSqJM=";
flutter_local_authentication = "sha256-r50jr+81ho+7q2PWHLf4VnvNJmhiARZ3s4HUpThCgc0=";
flutter_secure_storage_linux = "sha256-x45jrJ7pvVyhZlpqRSy3CbwT4Lna6yi/b2IyAilWckg=";
sqflite = "sha256-TdvCtEO7KL1R2oOSwGWllmS5kGCIU5CkvvUqUJf3tUc=";
};
nativeBuildInputs = [
copyDesktopItems
imagemagick
makeWrapper
];
buildInputs = [
webkitgtk
sqlite
libayatana-appindicator
];
# Based on https://github.com/ente-io/ente/blob/main/auth/linux/packaging/rpm/make_config.yaml
# and https://github.com/ente-io/ente/blob/main/auth/linux/packaging/ente_auth.appdata.xml
desktopItems = makeDesktopItem {
name = "ente_auth";
exec = "ente_auth";
icon = "ente-auth";
desktopName = "Ente Auth";
genericName = "Ente Authentication";
comment = "Open source 2FA authenticator, with end-to-end encrypted backups";
categories = [ "Utility" ];
keywords = [
"Authentication"
"2FA"
];
mimeTypes = [ "x-scheme-handler/enteauth" ];
startupNotify = false;
};
postInstall = ''
FAV=$out/app/data/flutter_assets/assets/icons/auth-icon.png
ICO=$out/share/icons
install -D $FAV $ICO/ente-auth.png
for size in 24 32 42 64 128 256 512; do
D=$ICO/hicolor/''${size}x''${size}/apps
mkdir -p $D
magick $FAV -resize ''${size}x''${size} $D/ente-auth.png
done
install -Dm444 linux/packaging/ente_auth.appdata.xml -t $out/share/metainfo
wrapProgram $out/bin/ente_auth \
--prefix PATH : ${lib.makeBinPath [ xdg-user-dirs ]}
'';
passthru.updateScript = ./update.sh;
meta = {
description = "End-to-end encrypted, cross platform and free app for storing your 2FA codes with cloud backups";
longDescription = ''
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.
'';
homepage = "https://ente.io/auth/";
changelog = "https://github.com/ente-io/ente/releases/tag/auth-v${version}";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [
niklaskorz
schnow265
zi3m5f
gepbird
];
mainProgram = "ente_auth";
platforms = [
"x86_64-linux"
"aarch64-linux"
];
};
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"owner": "simple-icons",
"repo": "simple-icons",
"rev": "bffc992b7d1365ee44b1683f8397e9f7a44d0c2c",
"hash": "sha256-aqX6X/UsXXprWYU0xYK+wM9vWULYI8enCbVFebEM0yw="
}

View File

@ -0,0 +1,35 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gojq nix-prefetch-github common-updater-scripts
set -eou pipefail
pkg_dir="$(dirname "$0")"
gh-curl () {
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "$1"
}
version="$(gh-curl "https://api.github.com/repos/ente-io/ente/releases" | gojq 'map(select(.draft == false and .prerelease == false and (.tag_name | startswith("auth-v")))) | first | .tag_name' --raw-output)"
short_version="${version:6}"
if [[ "$short_version" == "$UPDATE_NIX_OLD_VERSION" ]]; then
echo "ente-auth is already up-to-date: $short_version"
exit 0
fi
echo "Updating to $short_version"
# Subtree needed for lockfile and icons
auth_tree="$(gh-curl "https://api.github.com/repos/ente-io/ente/git/trees/$version" | gojq '.tree[] | select(.path == "auth") | .url' --raw-output)"
# Get lockfile, filter out incompatible sqlite dependency and convert to JSON
echo "Updating lockfile"
pubspec_lock="$(gh-curl "$auth_tree" | gojq '.tree[] | select(.path == "pubspec.lock") | .url' --raw-output)"
gh-curl "$pubspec_lock" | gojq '.content | @base64d' --raw-output | gojq --yaml-input 'del(.packages.sqlite3_flutter_libs)' > "$pkg_dir/pubspec.lock.json"
# Get rev and hash of simple-icons submodule
echo "Updating icons"
assets_tree="$(gh-curl "$auth_tree" | gojq '.tree[] | select(.path == "assets") | .url' --raw-output)"
simple_icons_rev="$(gh-curl "$assets_tree" | gojq '.tree[] | select(.path == "simple-icons") | .sha' --raw-output)"
nix-prefetch-github --rev "$simple_icons_rev" simple-icons simple-icons > "$pkg_dir/simple-icons.json"
# Update package version and hash
echo "Updating package source"
update-source-version ente-auth "$short_version" --file="$pkg_dir/package.nix"