Trying to use an extension

I am a newcomer using flatpak (I had some experience in the past). I created an extension org.freedesktop.Sdk.Extension.nim:

id: org.freedesktop.Sdk.Extension.nim
branch: '23.08'
runtime: org.freedesktop.Sdk
build-extension: true
sdk: org.freedesktop.Sdk
runtime-version: '23.08'

build-options:
  prefix: /usr/lib/sdk/nim

finish-args:
  - --share=network # We need this to install libraries with `nimble`

modules: 
        
  - name: nim
    buildsystem: simple
    sources:
      - type: file #archive
        only-arches:
          - x86_64
        
        dest: download
        url: https://nim-lang.org/download/nim-2.2.0-linux_x64.tar.xz
        sha256: 942e047879fd81193b2ff3c105436a0c5016800c4e97864f90039ae204f89ded

    build-options:
      prefix: /app/extensimcon_directory/nim
      prepend-path: /app/extension_directory/nim/bin

    build-commands:
      - tar -xf download/nim-2.2.0-linux_x64.tar.xz
      - install -v -Dm755 nim-2.2.0/bin/* -t ${FLATPAK_DEST}/bin/

I built it like:

flatpak-builder --force-clean --user --install ./tmpdir org.freedesktop.Sdk.Extension.nim.yml

At this point, if I debug the extension:

$ flatpak-builder --run ./tmpdir org.freedesktop.Sdk.Extension.nim.yml sh
sh-5.2$ /usr/lib/sdk/nim/bin/nim --version
Nim Compiler Version 2.2.0 [Linux: amd64]
Compiled at 2024-10-02
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 78983f1876726a49c69d65629ab433ea1310ece1
active boot switches: -d:release

Then, I would to use it in an app org.gnome.myapp.yml:

id: org.gnome.myapp
runtime: org.gnome.Platform
runtime-version: '47'
sdk: org.gnome.Sdk
command: myapp
sdk-extensions:
  - org.freedesktop.Sdk.Extension.nim:
      version: '23.08'

append-path: /usr/lib/sdk/nim/bin

modules:
  - name: myapp
    buildsystem: simple
    build-commands:
      - nimble install owlkettle
      - nimble build
      - install -Dm755 myapp /app/bin/myapp

I build it and it fails in one of the steps (it doesn’t find nimble):

$ flatpak-builder --user --force-clean --install ./tmpdir org.gnome.myapp.yml

If I debug it, /usr/lib/sdk appears empty. I would expect that to contain nim folder.

$ flatpak-builder --run ./tmpdir org.gnome.myapp.yml sh
sh-5.2$ ls /usr/lib/sdk
sh-5.2$ 

What am I doing wrong?

finish-args has no use in an extension.

doesn’t take versions, not sure where you are finding these syntaxes. Follow the docs Extensions - Flatpak documentation.

runtime-version: ‘47’

is based on freedesktop SDK 24.08, so you have to build a 24.08 branch of the extension:

id: org.freedesktop.Sdk.Extension.nim
branch: '24.08'
runtime: org.freedesktop.Sdk
build-extension: true
sdk: org.freedesktop.Sdk
runtime-version: '24.08'

Thanks a lot. I was a bit lost. I don’t remember from where I took that (maybe chatgpt).

This topic was automatically closed after 3 days. New replies are no longer allowed.