mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.13k stars 376 forks source link

Unable to build the library in NixOS #772

Closed Losses closed 2 months ago

Losses commented 2 months ago

Building log

[   +8 ms] : && /nix/store/svf4zn4qg9lsxfn4znyxk7nl80hlmgpm-clang-wrapper-17.0.6/bin/clang++ -isystem /nix/store/qzjbzg8is4zmsp57v922rf1l707wvzym-libX11-1.8.9-dev/include -isystem
/nix/store/liak2ih1rjid0yz7my7l5azmxpmjlvvq-xorgproto-2024.1/include -isystem /nix/store/dq03m14rqjvbz6pw42g555df4khh4bvr-zlib-1.3.1-dev/include -g
-Wl,-rpath,/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib -Wl,-rpath,/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib
-Wl,-rpath,/nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib -Wl,-rpath,/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib
-Wl,-rpath,/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib -Wl,-rpath,/nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib
-Wl,-rpath,/nix/store/lshzhii0i8kcs14ijgqvp6ldcnkydb9q-libepoxy-1.5.10/lib -Wl,-rpath,/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib
-Wl,-rpath,/nix/store/9hly244f95f2zmnr0mwsqingpyyr5yjp-libX11-1.8.9/lib -Wl,-rpath,/nix/store/d5d0lz3qnlqx6pw2mzkfcjy3fvwvgbcz-libdeflate-1.20/lib CMakeFiles/reader.dir/main.cc.o
CMakeFiles/reader.dir/my_application.cc.o CMakeFiles/reader.dir/flutter/generated_plugin_registrant.cc.o -o intermediates_do_not_run/reader
-Wl,-rpath,/home/losses/Development/reader/build/linux/x64/debug/plugins/fast_rsa:/home/losses/Development/reader/build/linux/x64/debug/plugins/flutter_acrylic:/home/losses/Development/reader/buil
d/linux/x64/debug/plugins/flutter_secure_storage_linux:/home/losses/Development/reader/build/linux/x64/debug/plugins/screen_retriever:/home/losses/Development/reader/build/linux/x64/debug/plugins/
system_theme:/home/losses/Development/reader/build/linux/x64/debug/plugins/url_launcher_linux:/home/losses/Development/reader/build/linux/x64/debug/plugins/window_manager:/home/losses/Development/
reader/linux/flutter/ephemeral:  plugins/fast_rsa/libfast_rsa_plugin.so  plugins/flutter_acrylic/libflutter_acrylic_plugin.so
plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so  plugins/screen_retriever/libscreen_retriever_plugin.so  plugins/system_theme/libsystem_theme_plugin.so
plugins/url_launcher_linux/liburl_launcher_linux_plugin.so  plugins/window_manager/libwindow_manager_plugin.so  /home/losses/Development/reader/linux/flutter/ephemeral/libflutter_linux_gtk.so
/nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib/libgtk-3.so  /nix/store/6ivp7s6qwf02d3siggfjrh3ayf2y056v-gtk+3-3.24.42/lib/libgdk-3.so
/nix/store/971g0fka30djkcww2ddpx7q66dr86c1q-zlib-1.3.1/lib/libz.so  /nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib/libpangocairo-1.0.so
/nix/store/461d831ri7sd2bc2dplgigqas3f09qa9-pango-1.52.2/lib/libpango-1.0.so  /nix/store/3kgm5ynckkxq46h5ycn6c73ndny6sdn7-harfbuzz-8.4.0/lib/libharfbuzz.so
/nix/store/yy2r81w57f927gzgj5spkzihcqlyip3i-at-spi2-core-2.52.0/lib/libatk-1.0.so  /nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib/libcairo-gobject.so
/nix/store/09788nmfm9gz27skmsr1cla96gsh938c-cairo-1.18.0/lib/libcairo.so  /nix/store/3jbl3zgj68ff6cngbzbkk82y1ckd5552-gdk-pixbuf-2.42.12/lib/libgdk_pixbuf-2.0.so
/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib/libgio-2.0.so  /nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib/libgobject-2.0.so
/nix/store/nm9608b5y801fq2p73nl7k80z8kcbmh2-glib-2.80.2/lib/libglib-2.0.so && :
[   +2 ms] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::resize(unsigned long, char)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::runtime_error::runtime_error(char const*)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__throw_bad_function_call()'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::runtime_error::runtime_error(std::runtime_error const&)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
[        ] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
[   +2 ms] /nix/store/wwfrj9kvfi14xclc38qfwm71ah6aawdh-binutils-2.41/bin/ld: plugins/flutter_secure_storage_linux/libflutter_secure_storage_linux_plugin.so: undefined reference to
`std::__throw_bad_array_new_length()'
[        ] clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Flakes config:

{
  description = "A combined Flutter and Rust devShell";

  inputs = {
    nixpkgs = {
      url = "github:NixOS/nixpkgs/nixos-unstable";
    };
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
    };
    flake-utils = {
      url = "github:numtide/flake-utils";
    };
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    android-nixpkgs = {
      url = "github:tadfisher/android-nixpkgs";
    };
  };

  outputs = { self, nixpkgs, rust-overlay, flake-utils, flake-compat, android-nixpkgs, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs {
          inherit system overlays;
          config = {
            allowUnfree = true;
            android_sdk = {
              accept_license = true;
            };
          };
        };

        androidEnvCustomPackage = pkgs.androidenv.composeAndroidPackages {
          toolsVersion = "26.1.1";
          platformToolsVersion = "34.0.5";
          buildToolsVersions = [ "30.0.3" "34.0.0" ];
          includeEmulator = true;
          emulatorVersion = "34.1.9";
          platformVersions = [ "28" "29" "30" "31" "32" "33" "34" ];
          includeSources = false;
          includeSystemImages = false;
          systemImageTypes = [ "google_apis_playstore" ];
          abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
          cmakeVersions = [ "3.10.2" ];
          includeNDK = true;
          ndkVersions = [ "22.0.7026061" ];
          useGoogleAPIs = false;
          useGoogleTVAddOns = false;
        };

        androidCustomPackage = android-nixpkgs.sdk.${system} (
          sdkPkgs: with sdkPkgs; [
            cmdline-tools-latest
            build-tools-30-0-3
            build-tools-33-0-2
            build-tools-34-0-0
            platform-tools
            emulator
            platforms-android-28
            platforms-android-29
            platforms-android-30
            platforms-android-31
            platforms-android-32
            platforms-android-33
            platforms-android-34
          ]
        );

        pinnedJDK = pkgs.jdk17;
      in {
        devShells.default = pkgs.mkShell {
          name = "Combined Flutter and Rust Dev Shell";
          buildInputs = with pkgs; [
            flutter
            android-studio
            rust-bin.beta.latest.default
            openssl
            pkg-config
            eza
            fd
            alsa-lib
            libpulseaudio
            pulseaudioFull
            rustup
          ] ++ [
            gtk3
            pinnedJDK
            androidCustomPackage
            protobuf_26
            pcre2
            ninja
            clang
            cmake
            libgcc
            libstdcxx5
            mount
            libsecret
            jsoncpp
          ];

          shellHook = ''
            alias ls=exa
            alias find=fd
            alias rinf='flutter pub run rinf'
            export RUST_BACKTRACE=1
            export CMAKE_INSTALL_PREFIX=$HOME/.local
            export JAVA_HOME=${pinnedJDK}
            export ANDROID_HOME=${androidCustomPackage}/share/android-sdk
            export GRADLE_USER_HOME=$HOME/.gradle
            export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidCustomPackage}/share/android-sdk/build-tools/34.0.0/aapt2"
            export PATH=${androidCustomPackage}/share/android-sdk/platform-tools:${androidCustomPackage}/share/android-sdk/tools:${androidCustomPackage}/share/android-sdk/tools/bin:$HOME/.cargo/bin:$HOME/.pub-cache/bin:$PATH
            export PKG_CONFIG_PATH=${pkgs.mount}/lib/pkgconfig:$PKG_CONFIG_PATH
            export LDFLAGS="-L${pkgs.libstdcxx5}/lib -lstdc++"
          '';
        };
      }
    );
}
Losses commented 2 months ago

Try this flake:

{
  description = "A combined Flutter and Rust devShell";

  inputs = {
    nixpkgs = {
      url = "github:NixOS/nixpkgs/nixos-unstable";
    };
    rust-overlay = {
      url = "github:oxalica/rust-overlay";
    };
    flake-utils = {
      url = "github:numtide/flake-utils";
    };
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    android-nixpkgs = {
      url = "github:tadfisher/android-nixpkgs";
    };
  };

  outputs = { self, nixpkgs, rust-overlay, flake-utils, flake-compat, android-nixpkgs, ... }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs {
          inherit system overlays;
          config = {
            allowUnfree = true;
            android_sdk = {
              accept_license = true;
            };
          };
        };

        androidEnvCustomPackage = pkgs.androidenv.composeAndroidPackages {
          toolsVersion = "26.1.1";
          platformToolsVersion = "34.0.5";
          buildToolsVersions = [ "30.0.3" "34.0.0" ];
          includeEmulator = true;
          emulatorVersion = "34.1.9";
          platformVersions = [ "28" "29" "30" "31" "32" "33" "34" ];
          includeSources = false;
          includeSystemImages = false;
          systemImageTypes = [ "google_apis_playstore" ];
          abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
          cmakeVersions = [ "3.10.2" ];
          includeNDK = true;
          ndkVersions = [ "22.0.7026061" ];
          useGoogleAPIs = false;
          useGoogleTVAddOns = false;
        };

        androidCustomPackage = android-nixpkgs.sdk.${system} (
          sdkPkgs: with sdkPkgs; [
            cmdline-tools-latest
            build-tools-30-0-3
            build-tools-33-0-2
            build-tools-34-0-0
            platform-tools
            emulator
            platforms-android-28
            platforms-android-29
            platforms-android-30
            platforms-android-31
            platforms-android-32
            platforms-android-33
            platforms-android-34
          ]
        );

        pinnedJDK = pkgs.jdk17;
      in {
        devShells.default = pkgs.mkShell {
          name = "Combined Flutter and Rust Dev Shell";
          buildInputs = with pkgs; [
            flutter
            android-studio
            rust-bin.beta.latest.default
            openssl
            pkg-config
            eza
            fd
            alsa-lib
            libpulseaudio
            pulseaudioFull
            rustup
          ] ++ [
            gtk3
            pinnedJDK
            androidCustomPackage
            protobuf_26
            pcre2
            ninja
            clang
            cmake
            stdenv
            mount
            libsecret
            jsoncpp
          ];

          shellHook = ''
            alias ls=exa
            alias find=fd
            alias rinf='flutter pub run rinf'
            export RUST_BACKTRACE=1
            export CMAKE_INSTALL_PREFIX=$HOME/.local
            export JAVA_HOME=${pinnedJDK}
            export ANDROID_HOME=${androidCustomPackage}/share/android-sdk
            export GRADLE_USER_HOME=$HOME/.gradle
            export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidCustomPackage}/share/android-sdk/build-tools/34.0.0/aapt2"
            export PATH=${androidCustomPackage}/share/android-sdk/platform-tools:${androidCustomPackage}/share/android-sdk/tools:${androidCustomPackage}/share/android-sdk/tools/bin:$HOME/.cargo/bin:$HOME/.pub-cache/bin:$PATH
            export PKG_CONFIG_PATH=${pkgs.util-linux}/lib/pkgconfig:${pkgs.mount}/lib/pkgconfig:$PKG_CONFIG_PATH
            export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH
          '';
        };
      }
    );
}