app-id: org.getmonero.Monero
runtime: org.kde.Platform
runtime-version: 5.15-22.08
sdk: org.kde.Sdk
finish-args:
  - --share=network
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --device=all
  - --filesystem=~/Monero:create
  - --persist=.bitmonero

cleanup:
  - /include
  - /etc
  - /share/man
  - /lib/pkgconfig
  - /lib/cmake
  - '*.a'
  - '*.la'

command: monero-wallet-gui
modules:
  - name: protobuf
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
    sources:
      - type: git
        url: https://github.com/protocolbuffers/protobuf
        tag: v22.4
        commit: 40e1daca18708c21c7edf07c489a688355bd297b

  - name: boost
    buildsystem: simple
    build-commands:
      - ./bootstrap.sh --prefix=$FLATPAK_DEST --with-libraries=chrono,date_time,filesystem,locale,program_options,regex,serialization,system,thread
      - ./b2 headers
      - ./b2 -j$FLATPAK_BUILDER_N_JOBS install variant=release --layout=system
    sources:
      - type: archive
        url: https://boostorg.jfrog.io/artifactory/main/release/1.82.0/source/boost_1_82_0.tar.gz
        sha256: 66a469b6e608a51f8347236f4912e27dc5c60c60d7d53ae9bfe4683316c6f04c

  - name: libunbound
    config-opts:
      - --with-libunbound-only
    sources:
      - type: archive
        url: https://nlnetlabs.nl/downloads/unbound/unbound-1.17.1.tar.gz
        sha256: ee4085cecce12584e600f3d814a28fa822dfaacec1f94c84bfd67f8a5571a5f4

  - name: libsodium
    sources:
      - type: archive
        url: https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz
        sha256: 6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1

  - name: libusb
    sources:
      - type: archive
        url: https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2
        sha256: 12ce7a61fc9854d1d2a1ffe095f7b5fac19ddba095c259e6067a46500381b5a5

  - name: hidapi
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
    sources:
      - type: archive
        url: https://github.com/libusb/hidapi/archive/hidapi-0.13.1.tar.gz
        sha256: 476a2c9a4dc7d1fc97dd223b84338dbea3809a84caea2dcd887d9778725490e3

  - name: libzmq
    config-opts:
      - --with-libsodium
      - --disable-Werror
    sources:
      - type: archive
        url: https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz
        sha256: c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5

  - name: libgss
    sources:
      - type: archive
        url: https://ftp.gnu.org/gnu/gss/gss-1.0.4.tar.gz
        sha256: ecceabdef4cae3fce7218b2ecb83eb4227dba44b53b61b8c2b2e88ae02419c73

  - name: libuv
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
    sources:
      - type: archive
        url: https://github.com/libuv/libuv/archive/v1.44.2.tar.gz
        sha256: e6e2ba8b4c349a4182a33370bb9be5e23c51b32efb9b9e209d0e8556b73a48da

  - name: p2pool
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
      - -DWITH_LTO=OFF
    sources:
      - type: git
        url: https://github.com/SChernykh/p2pool
        tag: v3.2
        commit: 92827035e07ff15da6b7645a332f3e59aa0ab1c4
    post-install:
      - install -Dm755 p2pool $FLATPAK_DEST/bin/p2pool

  - name: monero-gui
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
      - -DWITH_DESKTOP_ENTRY=OFF
      - -DWITH_UPDATER=OFF
    build-options:
      arch:
        aarch64:
          config-opts:
            - -DARCH=armv8-a
            - -DBUILD_TAG=linux-armv8
        x86_64:
          config-opts:
            - -DARCH=default
    sources:
      - type: dir
        path: ../
    post-install:
      - install -Dpm644 share/org.getmonero.Monero.desktop $FLATPAK_DEST/share/applications/$FLATPAK_ID.desktop
      - install -Dpm644 share/org.getmonero.Monero.metainfo.xml $FLATPAK_DEST/share/metainfo/$FLATPAK_ID.metainfo.xml
      - for x in 16 24 32 48 64 96 128 256; do install -Dpm644 images/appicons/${x}x${x}.png $FLATPAK_DEST/share/icons/hicolor/${x}x${x}/apps/$FLATPAK_ID.png; done
