release v1.0.0-beta.4

This commit is contained in:
Clément DOUIN 2024-04-16 21:26:00 +02:00
parent 23ae40e728
commit 10de8e9fb4
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
10 changed files with 209 additions and 242 deletions

View file

@ -22,22 +22,21 @@ jobs:
draft: false
prerelease: false
deploy-unix-releases:
deploy-releases:
runs-on: ${{ matrix.os }}
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: linux
- target: x86_64-linux
os: ubuntu-latest
- target: linux-musl
- target: arm64-linux
os: ubuntu-latest
- target: macos
- target: x86_64-windows
os: ubuntu-latest
- target: x86_64-macos
os: macos-latest
# TODO: uncomment once nix build .#windows works
# - target: windows
# os: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
@ -51,34 +50,18 @@ jobs:
with:
name: soywod
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build release
run: nix build -L .#${{ matrix.target }}
- name: Copy binary
- name: Build release archive
run: |
nix build -L .#${{ matrix.target }}
cp result/bin/himalaya* .
- name: Patch binary interpreter
if: ${{ matrix.target == 'linux' }}
run: |
nix-shell -p patchelf --command "sudo patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 himalaya"
- name: Prepare release archives
run: |
mkdir -p {man,completions}
nix run .#${{ matrix.target }} man ./man
nix run .#${{ matrix.target }} completion bash > ./completions/himalaya.bash
nix run .#${{ matrix.target }} completion elvish > ./completions/himalaya.elvish
nix run .#${{ matrix.target }} completion fish > ./completions/himalaya.fish
nix run .#${{ matrix.target }} completion powershell > ./completions/himalaya.powershell
nix run .#${{ matrix.target }} completion zsh > ./completions/himalaya.zsh
tar -czf himalaya.tgz himalaya* man completions
zip -r himalaya.zip himalaya* man completions
- name: Upload tarball release archive
- name: Upload tgz release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: himalaya.tgz
asset_name: himalaya-${{ matrix.target }}.tgz
asset_name: himalaya.${{ matrix.target }}.tgz
asset_content_type: application/gzip
- name: Upload zip release archive
uses: actions/upload-release-asset@v1
@ -87,74 +70,5 @@ jobs:
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: himalaya.zip
asset_name: himalaya-${{ matrix.target }}.zip
asset_name: himalaya.${{ matrix.target }}.zip
asset_content_type: application/zip
# TODO: remove me once nix build .#windows works
deploy-windows-release:
runs-on: windows-latest
needs: create-release
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
- name: Build release
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Copy binary
run: |
copy target/release/himalaya.exe .
- name: Prepare release archives
run: |
mkdir man
mkdir completions
./himalaya.exe man ./man
./himalaya.exe completion bash > ./completions/himalaya.bash
./himalaya.exe completion elvish > ./completions/himalaya.elvish
./himalaya.exe completion fish > ./completions/himalaya.fish
./himalaya.exe completion powershell > ./completions/himalaya.powershell
./himalaya.exe completion zsh > ./completions/himalaya.zsh
tar -czf himalaya.tgz himalaya.exe man completions
Compress-Archive -Path himalaya.exe,man,completions -DestinationPath himalaya.zip
- name: Upload tarball release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: himalaya.tgz
asset_name: himalaya-windows.tgz
asset_content_type: application/gzip
- name: Upload zip release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: himalaya.zip
asset_name: himalaya-windows.zip
asset_content_type: application/zip
publish-crates-io:
runs-on: ubuntu-latest
needs: create-release
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v24
with:
nix_path: nixpkgs=channel:nixos-23.11
extra_nix_config: |
experimental-features = nix-command flakes
- name: Publish library to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
nix develop -c cargo publish --no-verify --token ${CARGO_REGISTRY_TOKEN}

View file

@ -1,24 +0,0 @@
name: tests
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Nix
uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-23.11
extra_nix_config: |
experimental-features = nix-command flakes
- uses: cachix/cachix-action@v12
with:
name: soywod
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build then test
run: nix build

View file

@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.0.0-beta.4] - 2024-04-16
### Added
- Added systemd service in `assets/` folder.
@ -32,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed watch IMAP envelopes when folder was empty [#179].
- Prevented parsing of undefined config options [#188].
- Fixed `In-Reply-To` header being skipped from mailto URLs [#194].
- Fixed error page out of bounds when filtering envelopes returned an empty result [#195].
## [1.0.0-beta.3] - 2024-02-25
@ -821,3 +824,4 @@ Few major concepts changed:
[#184]: https://todo.sr.ht/~soywod/pimalaya/184
[#188]: https://todo.sr.ht/~soywod/pimalaya/188
[#194]: https://todo.sr.ht/~soywod/pimalaya/194
[#195]: https://todo.sr.ht/~soywod/pimalaya/195

8
Cargo.lock generated
View file

@ -1218,9 +1218,9 @@ dependencies = [
[[package]]
name = "email-lib"
version = "0.24.0"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28526bad9d46fcfb2c6385961aeb4b684546c965d18a12e5552ca4af7cf1f35e"
checksum = "20eca48c1ae74c6c7ec6ef9a6c2af935e3cc601c50fce1385c24bec5dd5e20e9"
dependencies = [
"advisory-lock",
"async-trait",
@ -3948,9 +3948,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.115"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd"
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
dependencies = [
"itoa",
"ryu",

View file

@ -45,7 +45,6 @@ pgp-commands = ["email-lib/pgp-commands", "mml-lib/pgp-commands", "pgp"]
pgp-gpg = ["email-lib/pgp-gpg", "mml-lib/pgp-gpg", "pgp"]
pgp-native = ["email-lib/pgp-native", "mml-lib/pgp-native", "pgp"]
[dependencies]
ariadne = "0.2"
async-trait = "0.1"
@ -56,7 +55,7 @@ color-eyre = "0.6.3"
console = "0.15.2"
dialoguer = "0.10.2"
dirs = "4"
email-lib = { version = "=0.24.0", default-features = false, features = ["derive"] }
email-lib = { version = "=0.24.1", default-features = false, features = ["derive"] }
email_address = "0.2.4"
erased-serde = "0.3"
indicatif = "0.17"

View file

@ -8,15 +8,15 @@
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1708842026,
"narHash": "sha256-1r+7l66CFPCjRDZEKq6r7aCpfjqhIkrF3ZTQyEFnkTs=",
"owner": "nix-community",
"lastModified": 1713081044,
"narHash": "sha256-ZwbJDrizU+nzU7wTgokYuu5yK71wLPmOLukiunm5B6Y=",
"owner": "soywod",
"repo": "fenix",
"rev": "b7fff64b5bc36b1662f8317632b11b15b3839b2a",
"rev": "af99e7e9c87389c0a5aaf953478664d7126c2b14",
"type": "github"
},
"original": {
"owner": "nix-community",
"owner": "soywod",
"repo": "fenix",
"type": "github"
}
@ -44,11 +44,11 @@
]
},
"locked": {
"lastModified": 1703887061,
"narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
@ -79,11 +79,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1708702655,
"narHash": "sha256-qxT5jSLhelfLhQ07+AUxSTm1VnVH+hQxDkQSZ/m/Smo=",
"lastModified": 1713145326,
"narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c5101e457206dd437330d283d6626944e28794b3",
"rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"type": "github"
},
"original": {
@ -105,11 +105,11 @@
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1708768292,
"narHash": "sha256-IBHMNEe3lspVdIzjpM2OVZiBFmFw1DKtdgVN5G41pRc=",
"lastModified": 1712818880,
"narHash": "sha256-VDxsvgj/bNypHq48tQWtc3VRbWvzlFjzKf9ZZIVO10Y=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "4a8d0f7f565b6df45da5522dd7366a4df3460cd7",
"rev": "657b33b0cb9bd49085202e91ad5b4676532c9140",
"type": "github"
},
"original": {

207
flake.nix
View file

@ -8,7 +8,7 @@
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
url = "github:soywod/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
@ -25,8 +25,114 @@
let
inherit (gitignore.lib) gitignoreSource;
staticRustFlags = [ "-Ctarget-feature=+crt-static" ];
# Map of map matching supported Nix build systems with Rust
# cross target systems.
crossBuildTargets = {
x86_64-linux = {
x86_64-linux = {
rustTarget = "x86_64-unknown-linux-musl";
override = { ... }: { };
};
arm64-linux = rec {
rustTarget = "aarch64-unknown-linux-musl";
override = { system, pkgs }:
let
inherit (mkPkgsCross system rustTarget) stdenv;
cc = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc"; in
rec {
TARGET_CC = cc;
CARGO_BUILD_RUSTFLAGS = staticRustFlags ++ [ "-Clinker=${cc}" ];
postInstall = mkPostInstall {
inherit pkgs;
bin = "${pkgs.qemu}/bin/qemu-aarch64 ./himalaya";
};
};
};
x86_64-windows = {
rustTarget = "x86_64-pc-windows-gnu";
override = { system, pkgs }:
let
inherit (pkgs) pkgsCross zip;
inherit (pkgsCross.mingwW64) stdenv windows;
cc = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
wine = pkgs.wine.override { wineBuild = "wine64"; };
postInstall = mkPostInstall {
inherit pkgs;
bin = "${wine}/bin/wine64 ./himalaya.exe";
};
in
{
depsBuildBuild = [ stdenv.cc windows.pthreads ];
TARGET_CC = cc;
CARGO_BUILD_RUSTFLAGS = staticRustFlags ++ [ "-Clinker=${cc}" ];
postInstall = ''
export WINEPREFIX="$(mktemp -d)"
${postInstall}
'';
};
};
};
x86_64-darwin = {
x86_64-macos = {
rustTarget = "x86_64-apple-darwin";
override = { pkgs, ... }:
let inherit (pkgs.darwin.apple_sdk.frameworks) AppKit Cocoa; in
{
buildInputs = [ Cocoa ];
NIX_LDFLAGS = "-F${AppKit}/Library/Frameworks -framework AppKit";
};
};
# FIXME: infinite recursion in stdenv?!
arm64-macos = {
rustTarget = "aarch64-apple-darwin";
override = { system, pkgs }:
let
# inherit (mkPkgsCross system "aarch64-darwin") stdenv;
inherit ((mkPkgsCross system "aarch64-darwin").pkgsStatic) stdenv darwin;
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa;
cc = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
in
rec {
buildInputs = [ Cocoa ];
NIX_LDFLAGS = "-F${AppKit}/Library/Frameworks -framework AppKit -F${Cocoa}/Library/Frameworks -framework Cocoa";
NIX_CFLAGS_COMPILE = "-F${AppKit}/Library/Frameworks -framework AppKit -F${Cocoa}/Library/Frameworks -framework Cocoa";
TARGET_CC = cc;
CARGO_BUILD_RUSTFLAGS = staticRustFlags ++ [ "-Clinker=${cc}" "-lframework=${Cocoa}/Library/Frameworks" ];
postInstall = mkPostInstall {
inherit pkgs;
bin = "${pkgs.qemu}/bin/qemu-aarch64 ./himalaya";
};
};
};
};
};
mkToolchain = import ./rust-toolchain.nix fenix;
mkPkgsCross = buildSystem: crossSystem: import nixpkgs {
system = buildSystem;
crossSystem.config = crossSystem;
};
mkPostInstall = { pkgs, bin ? "./himalaya" }: with pkgs; ''
cd $out/bin
mkdir -p {man,completions}
${bin} man ./man
${bin} completion bash > ./completions/himalaya.bash
${bin} completion elvish > ./completions/himalaya.elvish
${bin} completion fish > ./completions/himalaya.fish
${bin} completion powershell > ./completions/himalaya.powershell
${bin} completion zsh > ./completions/himalaya.zsh
tar -czf himalaya.tgz himalaya* man completions
${zip}/bin/zip -r himalaya.zip himalaya* man completions
'';
mkDevShells = buildPlatform:
let
pkgs = import nixpkgs { system = buildPlatform; };
@ -34,27 +140,21 @@
in
{
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
pkg-config
];
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [
# Nix
rnix-lsp
# rnix-lsp
nixpkgs-fmt
# Rust
rust-toolchain
cargo-watch
# OpenSSL
openssl.dev
# Notmuch
notmuch
# GPG
# Email env
gnupg
gpgme
msmtp
notmuch
];
};
};
@ -71,53 +171,31 @@
package' = {
name = "himalaya";
src = gitignoreSource ./.;
overrideMain = _: {
postInstall = ''
mkdir -p $out/share/applications/
cp assets/himalaya.desktop $out/share/applications/
'';
};
doCheck = true;
cargoTestOptions = opts: opts ++ [ "--lib" ];
} // pkgs.lib.optionalAttrs (!isNull targetPlatform) {
# overrideMain = _: {
# postInstall = ''
# mkdir -p $out/share/applications/
# cp assets/himalaya.desktop $out/share/applications/
# '';
# };
doCheck = false;
auditable = false;
strictDeps = true;
CARGO_BUILD_TARGET = targetPlatform;
CARGO_BUILD_RUSTFLAGS = staticRustFlags;
postInstall = mkPostInstall { inherit pkgs; };
} // package;
in
naersk'.buildPackage package';
mkPackages = buildPlatform:
mkPackages = system:
let
pkgs = import nixpkgs { system = buildPlatform; };
mkPackage' = mkPackage pkgs buildPlatform;
pkgs = import nixpkgs { inherit system; };
mkPackage' = target: package: mkPackage pkgs system package.rustTarget (package.override { inherit system pkgs; });
in
rec {
default = if pkgs.stdenv.isDarwin then macos else linux;
linux = mkPackage' null { };
linux-musl = mkPackage' "x86_64-unknown-linux-musl" (with pkgs.pkgsStatic; {
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
hardeningDisable = [ "all" ];
});
macos = mkPackage' null (with pkgs.darwin.apple_sdk.frameworks; {
# NOTE: needed to prevent error Undefined symbols
# "_OBJC_CLASS_$_NSImage" and
# "_LSCopyApplicationURLsForBundleIdentifier"
NIX_LDFLAGS = "-F${AppKit}/Library/Frameworks -framework AppKit";
buildInputs = [ Cocoa ];
});
# FIXME: bzlip: fatal error: windows.h: No such file or directory
# May be related to SQLite.
windows = mkPackage' "x86_64-pc-windows-gnu" {
strictDeps = true;
depsBuildBuild = with pkgs.pkgsCross.mingwW64; [
stdenv.cc
windows.pthreads
];
};
};
builtins.mapAttrs mkPackage' crossBuildTargets.${system};
mkApp = drv:
let exePath = drv.passthru.exePath or "/bin/himalaya";
in
let exePath = drv.passthru.exePath or "/bin/himalaya"; in
{
type = "app";
program = "${drv}${exePath}";
@ -126,29 +204,16 @@
mkApps = buildPlatform:
let
pkgs = import nixpkgs { system = buildPlatform; };
mkApp' = target: package: mkApp self.packages.${buildPlatform}.${target};
in
rec {
default = if pkgs.stdenv.isDarwin then macos else linux;
linux = mkApp self.packages.${buildPlatform}.linux;
linux-musl = mkApp self.packages.${buildPlatform}.linux-musl;
macos = mkApp self.packages.${buildPlatform}.macos;
windows =
let
wine = pkgs.wine.override { wineBuild = "wine64"; };
himalaya = self.packages.${buildPlatform}.windows;
app = pkgs.writeShellScriptBin "himalaya" ''
export WINEPREFIX="$(mktemp -d)"
${wine}/bin/wine64 ${himalaya}/bin/himalaya.exe $@
'';
in
mkApp app;
};
supportedSystems = [ "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems f;
builtins.mapAttrs mkApp' crossBuildTargets.${buildPlatform};
supportedSystems = builtins.attrNames crossBuildTargets;
mapSupportedSystem = nixpkgs.lib.genAttrs supportedSystems;
in
{
apps = forEachSupportedSystem mkApps;
packages = forEachSupportedSystem mkPackages;
devShells = forEachSupportedSystem mkDevShells;
apps = mapSupportedSystem mkApps;
packages = mapSupportedSystem mkPackages;
devShells = mapSupportedSystem mkDevShells;
};
}

View file

@ -11,32 +11,44 @@ DESTDIR="${DESTDIR:-}"
PREFIX="${PREFIX:-"$DESTDIR/usr/local"}"
RELEASES_URL="https://github.com/soywod/himalaya/releases"
binary=himalaya
system=$(uname -s | tr [:upper:] [:lower:])
machine=$(uname -m | tr [:upper:] [:lower:])
case $system in
msys*|mingw*|cygwin*|win*) system=windows; binary=himalaya.exe;;
linux|freebsd) system=linux; binary=himalaya;;
darwin) system=macos; binary=himalaya;;
*) die "Unsupported system: $system" ;;
msys*|mingw*|cygwin*|win*)
target=x86_64-windows
binary=himalaya.exe;;
linux|freebsd)
case $machine in
x86_64) target=x86_64-linux;;
arm64|aarch64) target=arm64-linux;;
*) die "Unsupported machine $machine for system $system";;
esac;;
darwin)
case $machine in
x86_64) target=x86_64-macos;;
arm64|aarch64) target=arm64-macos;;
*) die "Unsupported machine $machine for system $system";;
esac;;
*)
die "Unsupported system $system";;
esac
tmpdir=$(mktemp -d) || die "Failed to create tmpdir"
tmpdir=$(mktemp -d) || die "Cannot create temporary directory"
trap "rm -rf $tmpdir" EXIT
echo "Downloading latest $system release…"
curl -sLo "$tmpdir/himalaya.tar.gz" \
"$RELEASES_URL/latest/download/himalaya-$system.tar.gz"
curl -sLo "$tmpdir/himalaya.tgz" \
"$RELEASES_URL/latest/download/himalaya.$target.tgz"
echo "Installing binary…"
tar -xzf "$tmpdir/himalaya.tar.gz" -C "$tmpdir"
tar -xzf "$tmpdir/himalaya.tgz" -C "$tmpdir"
mkdir -p "$PREFIX/bin"
cp -f -- "$tmpdir/$binary" "$PREFIX/bin/$binary"
# See User Unit Search Path in `man systemd.unit(5)`
if [ "$system" = "linux" ] && [ "$PREFIX" = "/usr" ]; then
mkdir -p "$PREFIX/lib/systemd/user"
sed "s:%install_dir%:$PREFIX/bin:" "$tmpdir/assets/himalaya-watch@.service" \
> "$PREFIX/lib/systemd/user/himalaya-watch@.service"
fi
die "$("$PREFIX/bin/$binary" --version) installed!" 0

View file

@ -2,26 +2,23 @@ fenix:
let
file = ./rust-toolchain.toml;
sha256 = "e4mlaJehWBymYxJGgnbuCObVlqMlQSilZ8FljG9zPHY=";
sha256 = "+syqAd2kX8KVa8/U2gz3blIQTTsYYt3U63xBWaGOSc8=";
in
{
fromFile = { system }: fenix.packages.${system}.fromToolchainFile {
inherit file sha256;
};
fromTarget = { pkgs, buildPlatform, targetPlatform ? null }:
fromTarget = { pkgs, buildPlatform, targetPlatform }:
let
inherit ((pkgs.lib.importTOML file).toolchain) channel;
toolchain = fenix.packages.${buildPlatform};
name = (pkgs.lib.importTOML file).toolchain.channel;
fenixPackage = fenix.packages.${buildPlatform};
toolchain = fenixPackage.fromToolchainName { inherit name sha256; };
targetToolchain = fenixPackage.targets.${targetPlatform}.fromToolchainName { inherit name sha256; };
in
if
isNull targetPlatform
then
fenix.packages.${buildPlatform}.${channel}.toolchain
else
toolchain.combine [
toolchain.${channel}.rustc
toolchain.${channel}.cargo
toolchain.targets.${targetPlatform}.${channel}.rust-std
fenixPackage.combine [
toolchain.rustc
toolchain.cargo
targetToolchain.rust-std
];
}

View file

@ -1,4 +1,4 @@
[toolchain]
channel = "stable"
channel = "1.77.0"
profile = "default"
components = [ "rust-src", "rust-analyzer" ]