nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, flutter37
3, python3
4, fetchFromGitHub
5, pcre2
6, gnome
7, makeWrapper
8, removeReferencesTo
9}:
10
11flutter37.buildFlutterApplication rec {
12 pname = "yubioath-flutter";
13 version = "6.1.0";
14
15 src = fetchFromGitHub {
16 owner = "Yubico";
17 repo = "yubioath-flutter";
18 rev = version;
19 sha256 = "sha256-N9/qwC79mG9r+zMPLHSPjNSQ+srGtnXuKsf0ijtH7CI=";
20 };
21
22 passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; };
23
24 depsListFile = ./deps.json;
25 vendorHash = "sha256-WfZiB7MO4wHUg81xm67BMu4zQdC9CfhN5BQol+AI2S8=";
26
27 postPatch = ''
28 substituteInPlace linux/CMakeLists.txt \
29 --replace "../build/linux/helper" "${passthru.helper}/libexec/helper"
30 '';
31
32 preInstall = ''
33 # Make sure we have permission to delete things CMake has copied in to our build directory from elsewhere.
34 chmod -R +w build
35 '';
36
37 postInstall = ''
38 # Swap the authenticator-helper symlink with the correct symlink.
39 ln -fs "${passthru.helper}/bin/authenticator-helper" "$out/app/helper/authenticator-helper"
40
41 # Move the icon.
42 mkdir $out/share/icons
43 mv $out/app/linux_support/com.yubico.yubioath.png $out/share/icons
44
45 # Cleanup.
46 rm -rf \
47 "$out/app/README.adoc" \
48 "$out/app/desktop_integration.sh" \
49 "$out/app/linux_support" \
50 $out/bin/* # We will repopulate this directory later.
51
52 # Symlink binary.
53 ln -sf "$out/app/authenticator" "$out/bin/yubioath-flutter"
54
55 # Needed for QR scanning to work.
56 wrapProgram "$out/bin/yubioath-flutter" \
57 --prefix PATH : ${lib.makeBinPath [ gnome.gnome-screenshot ]}
58
59 # Set the correct path to the binary in desktop file.
60 substituteInPlace "$out/share/applications/com.yubico.authenticator.desktop" \
61 --replace "@EXEC_PATH/authenticator" "$out/bin/yubioath-flutter" \
62 --replace "@EXEC_PATH/linux_support/com.yubico.yubioath.png" "$out/share/icons/com.yubico.yubioath.png"
63
64 # Remove unnecessary references to Flutter.
65 remove-references-to -t ${flutter37.unwrapped} $out/app/data/flutter_assets/shaders/ink_sparkle.frag
66 '';
67
68 nativeBuildInputs = [
69 makeWrapper
70 removeReferencesTo
71 ];
72
73 buildInputs = [
74 pcre2
75 ];
76
77 disallowedReferences = [
78 flutter37
79 flutter37.unwrapped
80 ];
81
82 meta = with lib; {
83 description = "Yubico Authenticator for Desktop";
84 homepage = "https://github.com/Yubico/yubioath-flutter";
85 license = licenses.asl20;
86 maintainers = with maintainers; [ lukegb ];
87 platforms = [ "x86_64-linux" "aarch64-linux" ];
88 };
89}