Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to build an appimage #190

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
strategy:
matrix:
target:
- target: linux
os: ubuntu-latest
make: bash scripts/build-linux.sh
package: echo "Linux packaging is done in build step"
- target: macos
os: macos-latest
make: bash scripts/build-macos.sh
Expand All @@ -30,7 +34,7 @@
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 37 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Build (linux, ubuntu-latest, bash scripts/build-linux.sh, echo "Linux packaging is done in build ...

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... - uses: DeterminateSystems/magic-nix-cache-action@main ...with... - uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 37 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Build (macos, macos-latest, bash scripts/build-macos.sh, bash scripts/package-macos.sh)

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... - uses: DeterminateSystems/magic-nix-cache-action@main ...with... - uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- uses: DeterminateSystems/flake-checker-action@main
- uses: Swatinem/rust-cache@v2
with:
Expand All @@ -52,6 +56,7 @@
run: nix develop --command bash -c "scripts/sign-macos.sh"

- name: Package DMG
if: matrix.target.target == 'macos'
run: nix develop --command bash -c "${{ matrix.target.package }}"

- name: Create Release and Upload Assets
Expand All @@ -62,4 +67,6 @@
draft: true
prerelease: false
generate_release_notes: true
files: target/release/macos/harbor.dmg
files: |
target/release/macos/harbor.dmg
target/release/linux/Harbor-*-x86_64.AppImage
58 changes: 26 additions & 32 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@
pkgs.darwin.apple_sdk.frameworks.AppKit
pkgs.darwin.apple_sdk.frameworks.CoreText
pkgs.darwin.apple_sdk.frameworks.WebKit
]
++ lib.optionals pkgs.stdenv.isLinux [
# Added for Linux AppImage builds
pkgs.appimagekit
pkgs.imagemagick
# Linux-specific graphics dependencies
pkgs.mesa
pkgs.libglvnd
pkgs.xorg.libX11
pkgs.xorg.libXcursor
pkgs.xorg.libXi
pkgs.xorg.libXrandr
pkgs.xorg.libxcb
pkgs.libxkbcommon
pkgs.wayland
pkgs.wayland-protocols
pkgs.wayland-scanner
pkgs.vulkan-loader
];
in
{
Expand All @@ -69,44 +87,20 @@
};

devShell = pkgs.mkShell rec {
packages = inputs ++ [
pkgs.mesa
pkgs.libglvnd # Adds EGL support
pkgs.xorg.libX11
pkgs.xorg.libXcursor
pkgs.xorg.libXi
pkgs.xorg.libXrandr
pkgs.xorg.libxcb
pkgs.libxkbcommon
pkgs.wayland
# Wayland-specific dependencies
pkgs.wayland-protocols
pkgs.wayland-scanner
# For Vulkan fallback (wgpu might need this)
pkgs.vulkan-loader
];
packages = inputs;

# Important environment variables for EGL and Wayland
# EGL_PLATFORM = "wayland"; # Changed from x11 to wayland
# WAYLAND_DISPLAY = "wayland-0"; # Default Wayland display
LD_LIBRARY_PATH = lib.makeLibraryPath ([
pkgs.mesa
pkgs.libglvnd
pkgs.xorg.libX11
pkgs.libxkbcommon
pkgs.wayland
]);

shellHook = ''
export LIBCLANG_PATH=${pkgs.libclang.lib}/lib/
# Add important Mesa paths
export LIBGL_DRIVERS_PATH=${pkgs.mesa.drivers}/lib/dri
export __EGL_VENDOR_LIBRARY_DIRS=${pkgs.mesa.drivers}/share/glvnd/egl_vendor.d/
# Wayland specific environment variables
export XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}
${lib.optionalString pkgs.stdenv.isLinux ''
# Add important Mesa paths (Linux only)
export LIBGL_DRIVERS_PATH=${pkgs.mesa}/lib/dri
export __EGL_VENDOR_LIBRARY_DIRS=${pkgs.mesa}/share/glvnd/egl_vendor.d/
# Wayland specific environment variables
export XDG_RUNTIME_DIR=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}
''}
'';
};

}
);
}
30 changes: 30 additions & 0 deletions harbor-ui/assets/linux/cash.harbor.harbor.metainfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<content_rating type="oars-1.1">
</content_rating>
<id>cash.harbor.harbor</id>
<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
<name>Harbor</name>
<summary>Harbor is a Lightning Wallet for better bitcoin privacy.</summary>
<description>
<p>
Harbor is a Lightning Wallet focused on privacy and security. It allows you to manage your bitcoin and
lightning funds with enhanced privacy features, making it easier to maintain financial sovereignty while
using the Lightning Network.
</p>
</description>
<launchable type="desktop-id">cash.harbor.harbor.desktop</launchable>
<url type="homepage">https://github.com/futurepaul/harbor</url>
<url type="bugtracker">https://github.com/futurepaul/harbor/issues</url>
<screenshots>
<screenshot type="default">
<caption>Harbor logo</caption>
<image>https://raw.githubusercontent.com/futurepaul/harbor/main/harbor-ui/assets/harbor_icon.png</image>
</screenshot>
</screenshots>
<developer_name>Harbor Wallet Devs</developer_name>
<releases>
<release version="0.1.0" date="2024-02-14"/>
</releases>
</component>
10 changes: 10 additions & 0 deletions harbor-ui/assets/linux/harbor.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Name=Harbor
Comment=Lightning Wallet for better bitcoin privacy
Type=Application
Keywords=bitcoin;lightning;privacy;wallet;
Categories=Office;Finance;
Exec=harbor
Icon=cash.harbor.harbor
StartupWMClass=cash.harbor.harbor
Terminal=false
71 changes: 71 additions & 0 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -e # Exit on error

TARGET="harbor-ui"
RELEASE_DIR="target/release"
APP_NAME="Harbor"
LINUX_DIR="$RELEASE_DIR/linux"

# Get version from Cargo.toml
VERSION=$(grep -m1 '^version = ' harbor-ui/Cargo.toml | cut -d '"' -f2)
BUILD=$(git describe --always --dirty --exclude='*')

# Build binary
echo "Building Harbor for Linux..."
cargo build --release --features vendored

# Generate Linux icons
./scripts/generate-linux-icons.sh

# Create AppDir structure
APPDIR="$LINUX_DIR/$APP_NAME.AppDir"
mkdir -p "$APPDIR/usr/bin"
mkdir -p "$APPDIR/usr/share/applications"
mkdir -p "$APPDIR/usr/share/icons"
mkdir -p "$APPDIR/usr/share/metainfo"

# Copy binary
cp "$RELEASE_DIR/$TARGET" "$APPDIR/usr/bin/harbor"

# Copy desktop file and rename it
cp "harbor-ui/assets/linux/harbor.desktop" "$APPDIR/usr/share/applications/cash.harbor.harbor.desktop"

# Copy metadata file
cp "harbor-ui/assets/linux/cash.harbor.harbor.metainfo.xml" "$APPDIR/usr/share/metainfo/"

# Copy icons
cp -r "harbor-ui/assets/linux/icons" "$APPDIR/usr/share/"

# Create AppRun script
cat > "$APPDIR/AppRun" << 'EOF'
#!/bin/bash
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
export PATH="${HERE}/usr/bin/:${PATH}"
exec "${HERE}/usr/bin/harbor" "$@"
EOF

chmod +x "$APPDIR/AppRun"

# Create symlinks
cd "$APPDIR"
ln -sf usr/share/applications/cash.harbor.harbor.desktop .
ln -sf usr/share/icons/256x256/harbor.png cash.harbor.harbor.png
cd -

# Generate AppImage
echo "Generating AppImage..."
# Get architecture and normalize to common format
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
elif [ "$ARCH" = "x86_64" ]; then
ARCH="x86_64"
fi

# Set architecture explicitly for appimagetool
export ARCH
appimagetool --no-appstream "$APPDIR" "$LINUX_DIR/$APP_NAME-$VERSION-$ARCH.AppImage"

echo "✨ Created AppImage in $LINUX_DIR"
19 changes: 19 additions & 0 deletions scripts/generate-linux-icons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e # Exit on error

ICON_SOURCE="harbor-ui/assets/harbor_icon.png"
ICON_SIZES=(16 32 48 64 128 256)
OUTPUT_DIR="harbor-ui/assets/linux/icons"

# Create output directories for each size
for size in "${ICON_SIZES[@]}"; do
mkdir -p "$OUTPUT_DIR/${size}x${size}"
done

# Generate icons for each size
for size in "${ICON_SIZES[@]}"; do
magick convert "$ICON_SOURCE" -resize "${size}x${size}" "$OUTPUT_DIR/${size}x${size}/harbor.png"
done

echo "✨ Generated Linux icons in $OUTPUT_DIR"
Loading