{ ... }: {
  flake.homeManagerModules.wisdomBrowsersFlow =
    { config, lib, pkgs, ... }:
    let
      root = config.chiasson.home;
      cfg = config.chiasson.home.browsers.flow;

      flow-browser =
        let
          pname = "flow-browser";
          version = "0.11.0";

          suffix = if pkgs.stdenv.hostPlatform.isAarch64 then "arm64" else "x86_64";

          hash =
            if pkgs.stdenv.hostPlatform.isAarch64 then
              "sha256-rTRKbNyVRJAw7ZyDR6kx+XJ4rWmErZqA0b6LP9t5eOA="
            else
              "sha256-/Tca4uUBfgbZQEeXdYkCz6CWxqvCl40CQpACFry1k9s=";

          src = pkgs.fetchurl {
            url = "https://github.com/MultiboxLabs/flow-browser/releases/download/v${version}/flow-browser-${version}-${suffix}.AppImage";
            inherit hash;
          };

          appimageContents = pkgs.appimageTools.extractType2 { inherit pname version src; };
        in
        pkgs.appimageTools.wrapType2 {
          inherit pname version src;

          nativeBuildInputs = [ pkgs.makeWrapper ];

          extraInstallCommands = ''
            wrapProgram $out/bin/${pname} \
              --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"

            install -m 444 -D ${appimageContents}/flow-browser.desktop -t $out/share/applications
            substituteInPlace $out/share/applications/flow-browser.desktop \
              --replace-fail 'Exec=AppRun --ozone-platform-hint=auto' 'Exec=${pname} --ozone-platform-hint=auto'

            install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/512x512/apps/flow-browser.png \
              $out/share/icons/hicolor/512x512/apps/flow-browser.png
          '';

          meta = {
            description = "Chromium-based browser (upstream AppImage)";
            homepage = "https://github.com/MultiboxLabs/flow-browser";
            license = lib.licenses.gpl3Plus;
            sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
            platforms = [ "x86_64-linux" "aarch64-linux" ];
            mainProgram = pname;
            maintainers = [ ];
          };
        };
    in
    {
      options.chiasson.home.browsers.flow.enable = lib.mkEnableOption ''
        [Flow](https://github.com/MultiboxLabs/flow-browser) — upstream AppImage wrapped for NixOS.
      '';

      config = lib.mkIf (root.enable && cfg.enable) {
        home.packages = lib.optional (
          lib.meta.availableOn pkgs.stdenv.hostPlatform flow-browser
        ) flow-browser;
      };
    };
}
