diff --git a/.github/workflows/build-on-demand.yml b/.github/workflows/build-on-demand.yml new file mode 100644 index 00000000..56742aa0 --- /dev/null +++ b/.github/workflows/build-on-demand.yml @@ -0,0 +1,59 @@ +name: build-on-demand + +on: + workflow_dispatch: + inputs: + target: + description: "Target" + required: true + type: choice + options: + - aarch64-apple-darwin + - aarch64-unknown-linux-musl + - armv6l-unknown-linux-musleabihf + - armv7l-unknown-linux-musleabihf + - i686-unknown-linux-musl + - i686-w64-mingw32 + - x86_64-apple-darwin + - x86_64-unknown-linux-musl + - x86_64-w64-mingw32 + defaultFeatures: + description: "Enable default cargo features" + default: true + type: bool + features: + description: "Cargo features (comma-separated)" + type: string + +jobs: + build-on-demand: + runs-on: ${{ inputs.target == "x86_64-apple-darwin" && "macos-13" || inputs.target == "aarch64-apple-darwin" && "macos-14" || "ubuntu-latest" }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Nix + uses: cachix/install-nix-action@v27 + with: + nix_path: nixpkgs=channel:nixos-24.05 + enable_kvm: true + - name: Cache Nix store + uses: cachix/cachix-action@v15 + with: + name: soywod + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + extraPullNames: nix-community + - name: Build release + env: + NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM: 1 + run: | + nix-build \ + --argstr target ${{ inputs.target }} \ + --arg defaultFeatures ${{ inputs.defaultFeatures }} \ + --argstr features ${{ inputs.features }} + - name: Upload release artifact + uses: actions/upload-artifact@v4 + with: + name: "himalaya.${{ inputs.target }}" + path: | + result/bin/himalaya* + result/bin/share diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 52155d7e..e862d930 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -10,28 +10,24 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-musl - - os: ubuntu-latest - target: i686-unknown-linux-gnu - - os: ubuntu-latest - target: i686-unknown-linux-musl - - os: ubuntu-latest - target: arm-unknown-linux-gnueabihf - - os: ubuntu-latest - target: armv7-unknown-linux-gnueabihf - - os: ubuntu-latest - target: x86_64-w64-mingw32 - - os: macos-13 - target: x86_64-apple-darwin - - os: macos-14 - target: aarch64-apple-darwin + - target: aarch64-apple-darwin + os: macos-14 + - target: aarch64-unknown-linux-musl + os: ubuntu-latest + - target: armv6l-unknown-linux-musleabihf + os: ubuntu-latest + - target: armv7l-unknown-linux-musleabihf + os: ubuntu-latest + - target: i686-unknown-linux-musl + os: ubuntu-latest + - target: i686-w64-mingw32 + os: ubuntu-latest + - target: x86_64-apple-darwin + os: macos-13 + - target: x86_64-unknown-linux-musl + os: ubuntu-latest + - target: x86_64-w64-mingw32 + os: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/default.nix b/default.nix index d82be7f9..202437ae 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ target ? null }: +{ target ? null, defaultFeatures ? true, features ? "" }: let pkgs = import ( @@ -6,7 +6,7 @@ let else { crossSystem.config = target; } ); - inherit (pkgs) lib hostPlatform buildPlatform; + inherit (pkgs) lib hostPlatform; fenix = import (fetchTarball "https://github.com/soywod/fenix/archive/main.tar.gz") { }; @@ -36,6 +36,8 @@ let installManPages = false; notmuch = pkgs.notmuch; gpgme = pkgs.gpgme; + buildNoDefaultFeatures = !defaultFeatures; + buildFeatures = lib.strings.splitString "," features; }; in @@ -44,7 +46,7 @@ himalaya.overrideAttrs (drv: { version = "1.0.0"; postInstall = lib.optionalString hostPlatform.isWindows '' - export WINEPREFIX="$(${lib.getExe pkgs.buildPackages.mktemp} -d)" + export WINEPREFIX="$(${lib.getExe' pkgs.buildPackages.mktemp "mktemp"} -d)" '' + '' mkdir -p $out/bin/share/{applications,completions,man,services} cp assets/himalaya.desktop $out/bin/share/applications/ diff --git a/package.nix b/package.nix index 09af5419..d9f97bbb 100644 --- a/package.nix +++ b/package.nix @@ -28,6 +28,13 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-YS8IamapvmdrOPptQh2Ef9Yold0IK1XIeGs0kDIQ5b8="; + TARGET_CC = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; + CARGO_BUILD_RUSTFLAGS = [ + "-Clinker=${TARGET_CC}" + "-Clink-args=-static -latomic" + "-Ctarget-feature=+crt-static" + ]; + # unit tests only doCheck = false; cargoTestFlags = [ "--lib" ];