app-id: io.gpt4all.gpt4all
default-branch: stable
runtime: org.kde.Platform
runtime-version: '6.5'
sdk: org.kde.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.node14
finish-args:
  - --share=ipc
  - --socket=wayland
  - --socket=x11
  - --share=network
  - --device=dri
  - --env=LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/lib/x86_64-linux-gnu/
  - --filesystem=xdg-documents:ro
command: chat
cleanup:
  - /include

modules:
  - name: qthttpserver
    buildsystem: cmake
    sources:
      - type: archive
        url: https://invent.kde.org/qt/qt/qthttpserver/-/archive/6.5.2/qthttpserver-6.5.2.zip
        sha256: 9fb7b14774b4ed62fe9097e13fa593af06ba75537783fc62f34652bada26abee

  - name: python-html5lib
    buildsystem: simple
    build-commands:
    - 'pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}" --prefix=${FLATPAK_DEST} "html5lib" --no-build-isolation'
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
        sha256: a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78
        x-checker-data:
            type: pypi
            name: webencodings
            packagetype: bdist_wheel
      - type: file
        url: https://files.pythonhosted.org/packages/6c/dd/a834df6482147d48e225a49515aabc28974ad5a4ca3215c18a882565b028/html5lib-1.1-py2.py3-none-any.whl
        sha256: 0d78f8fde1c230e99fe37986a60526d7049ed4bf8a9fadbad5f00e22e58e041d
        x-checker-data:
            type: pypi
            name: html5lib
            packagetype: bdist_wheel
    cleanup:
    - '*'

  - name: qtwebengine
    buildsystem: cmake
    builddir: true
    config-opts:
      - -DQT_FEATURE_qtwebengine_build=OFF
      - -DQT_FEATURE_qtpdf_build=ON
    build-options:
      append-path: /usr/lib/sdk/node14/bin
      env:
        - npm_config_nodedir=/usr/lib/sdk/node14
    sources:
      - type: git
        url: https://invent.kde.org/qt/qt/qtwebengine.git
        tag: v6.5.2
        commit: ac887518e8243828333e923b5a1e61a007babde5
  
  - name: vulkan-headers
    buildsystem: cmake
    builddir: true
    sources:
      - type: git
        url: https://github.com/KhronosGroup/Vulkan-Headers.git
        tag: v1.3.224
        commit: 2b55157592bf4c639b76cc16d64acaef565cc4b5

  - name: fmt
    buildsystem: cmake
    builddir: true
    sources:
      - type: git
        url: https://github.com/fmtlib/fmt.git
        tag: 10.1.1
        commit: f5e54359df4c26b6230fc61d38aa294581393084

  - name: vulkan-tools
    buildsystem: cmake
    builddir: true
    sources:
      - type: git
        url: https://github.com/KhronosGroup/Vulkan-Tools.git
        tag: v1.3.224
        commit: 497f232680b046db34ba9e9da065e6303a125851

    

    modules:
      - name: shaderc
        buildsystem: cmake-ninja
        builddir: true
        config-opts:
          - -DSHADERC_SKIP_COPYRIGHT_CHECK=ON
          - -DSHADERC_SKIP_EXAMPLES=ON
          - -DSHADERC_SKIP_TESTS=ON
          - -DSPIRV_SKIP_EXECUTABLES=ON
          - -DENABLE_GLSLANG_BINARIES=OFF
        cleanup:
          - /bin
          - /include
          - /lib/cmake
          - /lib/pkgconfig
        sources:
          - type: git
            url: https://github.com/google/shaderc.git
            tag: v2023.4
            commit: 45b735dfddefe26a99b77e5a74e30d860713ac64
#           x-checker-data:
#             type: git
#             tag-pattern: ^v(\d{4}\.\d{1,2})$
          - type: git
            url: https://github.com/KhronosGroup/SPIRV-Tools.git
            tag: v2023.2
            commit: 44d72a9b36702f093dd20815561a56778b2d181e
            dest: third_party/spirv-tools
            x-checker-data:
              type: git
              tag-pattern: ^v(\d{4}\.\d{1})$
          - type: git
            url: https://github.com/KhronosGroup/SPIRV-Headers.git
            tag: sdk-1.3.250.1
            commit: 268a061764ee69f09a477a695bf6a11ffe311b8d
            dest: third_party/spirv-headers
            x-checker-data:
              type: git
              tag-pattern: ^sdk-([\d.]+)$
          - type: git
            url: https://github.com/KhronosGroup/glslang.git
            tag: 12.2.0
            commit: d1517d64cfca91f573af1bf7341dc3a5113349c0
            dest: third_party/glslang
          
          


  - name: gpt4all
    buildsystem: simple
    build-commands:
      - git submodule update --init --recursive
      - mkdir build
      - cmake  -S ./gpt4all-chat -B build -DKOMPUTE_OPT_USE_BUILT_IN_VULKAN_HEADER=OFF -DKOMPUTE_OPT_USE_BUILT_IN_FMT=OFF -DCMAKE_INSTALL_PREFIX=/app
      - cmake --build build --config Release -- -j
      - cmake --install build --prefix "/app"
      - install -Dm644 logo.svg /app/share/icons/hicolor/scalable/apps/io.gpt4all.gpt4all.svg
      - install -Dm644 io.gpt4all.gpt4all.desktop /app/share/applications/io.gpt4all.gpt4all.desktop
      - install -Dm644 io.gpt4all.gpt4all.appdata.xml  /app/share/appdata/io.gpt4all.gpt4all.appdata.xml
    sources:
      - type: git
        url: https://github.com/nomic-ai/gpt4all
        tag: v2.4.19
        commit: 84905aa28171545542fc653dbeca501ae5af383e
      - type: file
        url: https://raw.githubusercontent.com/nomic-ai/gpt4all/main/gpt4all-chat/icons/logo.svg
        sha256: 4c4e8476d0e2020585b69c6e2fc9e7d0cb12cbb36aa7b83c3a2e48ed4a9a424c
      - type: file
        path: io.gpt4all.gpt4all.desktop
      - type: file
        path: io.gpt4all.gpt4all.appdata.xml

