{
  description = "Meshy - a GTK4/libadwaita client for MeshCore";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};

        pythonEnv = pkgs.python3.withPackages (
          ps: with ps; [
            pygobject3
            pycryptodome
            pyzbar
            pyserial
            segno
          ]
        );

        meshy = pkgs.stdenv.mkDerivation {
          pname = "meshy";
          version = "git";

          src = self;

          nativeBuildInputs = with pkgs; [
            meson
            ninja
            pkg-config
            wrapGAppsHook4
            gobject-introspection
            blueprint-compiler
            desktop-file-utils
            appstream
            glib
            gettext
          ];

          buildInputs = with pkgs; [
            gtk4
            libadwaita
            gst_all_1.gstreamer
            libshumate
            geoclue2

            pythonEnv
          ];

          mesonFlags = [ "--buildtype=release" ];

          dontWrapGApps = false;

          preFixup = ''
            gappsWrapperArgs+=(
              --prefix PYTHONPATH : "${pythonEnv}/${pythonEnv.sitePackages}"
            )
          '';

          meta = with pkgs.lib; {
            description = "GTK4/libadwaita client for MeshCore";
            longDescription = ''
              Meshy is a native Linux desktop application providing a
              GTK4/libadwaita UI for MeshCore companion radio nodes. It
              supports connecting to nodes via serial, BLE, and TCP.
            '';
            homepage = "https://codeberg.org/sesivany/meshy";
            license = licenses.gpl3Plus;
            maintainers = [ ];
            platforms = platforms.linux;
            mainProgram = "meshy";
          };
        };
      in
      {
        packages = {
          inherit meshy;
          default = meshy;
        };
      }
    );
}
