Skip to content

Commit

Permalink
build(nix): fix darwin x86_64 build
Browse files Browse the repository at this point in the history
Also re-format nix codes with nixfmt-rfc-style.

Refs: #538
  • Loading branch information
soywod committed Jan 11, 2025
1 parent 9d773e9 commit 0f6217e
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 56 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Since logs are sent to `stderr`, warnings can be easily discarded by prepending commands with `RUST_LOG=off` or by appending commands with `2>/dev/null`.

- Changed `message.send.save-copy` default to `true` when omitted. [#536]
- Changed `message.send.save-copy` default to `true`. [#536]

- Changed default downloads directory. [core#1]

### Fixed

- Fixed permissions issues when using `install.sh`. [#515]

- Fixed de/serialization issues of backends' `none` variant. [#523]

- Fixed list envelopes out of bound error when empty result. [#535]
- Fixed macOS x86_64 builds. [#538]

## [1.0.0] - 2024-12-09

Expand Down Expand Up @@ -965,6 +964,7 @@ Few major concepts changed:
[#523]: https://github.com/pimalaya/himalaya/issues/523
[#535]: https://github.com/pimalaya/himalaya/issues/535
[#536]: https://github.com/pimalaya/himalaya/issues/536
[#538]: https://github.com/pimalaya/himalaya/issues/538

[core#1]: https://github.com/pimalaya/core/issues/1
[core#10]: https://github.com/pimalaya/core/issues/10
43 changes: 28 additions & 15 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
{ pimalaya ? import (fetchTarball "https://github.com/pimalaya/nix/archive/master.tar.gz")
, ...
} @args:
{
pimalaya ? import (fetchTarball "https://github.com/pimalaya/nix/archive/master.tar.gz"),
...
}@args:

pimalaya.mkDefault ({
src = ./.;
version = "1.0.0";
mkPackage = ({ lib, pkgs, rustPlatform, defaultFeatures, features }: pkgs.callPackage ./package.nix {
inherit lib rustPlatform;
apple-sdk = if pkgs.hostPlatform.isx86_64 then pkgs.apple-sdk_13 else pkgs.apple-sdk_14;
installShellCompletions = false;
installManPages = false;
buildNoDefaultFeatures = !defaultFeatures;
buildFeatures = lib.splitString "," features;
});
} // removeAttrs args [ "pimalaya" ])
pimalaya.mkDefault (
{
src = ./.;
version = "1.0.0";
mkPackage = (
{
lib,
pkgs,
rustPlatform,
defaultFeatures,
features,
}:
pkgs.callPackage ./package.nix {
inherit lib rustPlatform;
apple-sdk = pkgs.apple-sdk;
installShellCompletions = false;
installManPages = false;
buildNoDefaultFeatures = !defaultFeatures;
buildFeatures = lib.splitString "," features;
}
);
}
// removeAttrs args [ "pimalaya" ]
)
78 changes: 45 additions & 33 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# TODO: move this to nixpkgs
# This file aims to be a replacement for the nixpkgs derivation.

{ lib
, pkg-config
, rustPlatform
, fetchFromGitHub
, stdenv
, apple-sdk
, installShellFiles
, installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, notmuch
, gpgme
, buildNoDefaultFeatures ? false
, buildFeatures ? [ ]
{
lib,
pkg-config,
rustPlatform,
fetchFromGitHub,
stdenv,
apple-sdk,
installShellFiles,
installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
notmuch,
gpgme,
buildNoDefaultFeatures ? false,
buildFeatures ? [ ],
}:

let
Expand All @@ -35,10 +36,12 @@ rustPlatform.buildRustPackage rec {
rev = "v${version}";
};

nativeBuildInputs = [ pkg-config ]
++ lib.optional (installManPages || installShellCompletions) installShellFiles;
nativeBuildInputs = [
pkg-config
] ++ lib.optional (installManPages || installShellCompletions) installShellFiles;

buildInputs = [ ]
buildInputs =
[ ]
++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk
++ lib.optional (builtins.elem "notmuch" buildFeatures) notmuch
++ lib.optional (builtins.elem "pgp-gpg" buildFeatures) gpgme;
Expand All @@ -49,29 +52,38 @@ rustPlatform.buildRustPackage rec {
# unit tests only
cargoTestFlags = [ "--lib" ];

postInstall = ''
mkdir -p $out/share/{applications,completions,man}
cp assets/himalaya.desktop "$out"/share/applications/
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
"$out"/bin/himalaya man "$out"/share/man
'' + lib.optionalString installManPages ''
installManPage "$out"/share/man/*
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
"$out"/bin/himalaya completion bash > "$out"/share/completions/himalaya.bash
"$out"/bin/himalaya completion elvish > "$out"/share/completions/himalaya.elvish
"$out"/bin/himalaya completion fish > "$out"/share/completions/himalaya.fish
"$out"/bin/himalaya completion powershell > "$out"/share/completions/himalaya.powershell
"$out"/bin/himalaya completion zsh > "$out"/share/completions/himalaya.zsh
'' + lib.optionalString installShellCompletions ''
installShellCompletion "$out"/share/completions/himalaya.{bash,fish,zsh}
'';
postInstall =
''
mkdir -p $out/share/{applications,completions,man}
cp assets/himalaya.desktop "$out"/share/applications/
''
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
"$out"/bin/himalaya man "$out"/share/man
''
+ lib.optionalString installManPages ''
installManPage "$out"/share/man/*
''
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
"$out"/bin/himalaya completion bash > "$out"/share/completions/himalaya.bash
"$out"/bin/himalaya completion elvish > "$out"/share/completions/himalaya.elvish
"$out"/bin/himalaya completion fish > "$out"/share/completions/himalaya.fish
"$out"/bin/himalaya completion powershell > "$out"/share/completions/himalaya.powershell
"$out"/bin/himalaya completion zsh > "$out"/share/completions/himalaya.zsh
''
+ lib.optionalString installShellCompletions ''
installShellCompletion "$out"/share/completions/himalaya.{bash,fish,zsh}
'';

meta = rec {
description = "CLI to manage emails";
mainProgram = "himalaya";
homepage = "https://github.com/pimalaya/himalaya";
changelog = "${homepage}/blob/v${version}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ soywod toastal yanganto ];
maintainers = with lib.maintainers; [
soywod
toastal
yanganto
];
};
}
10 changes: 5 additions & 5 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pimalaya ? import (fetchTarball "https://github.com/pimalaya/nix/archive/master.tar.gz")
, ...
} @args:
{
pimalaya ? import (fetchTarball "https://github.com/pimalaya/nix/archive/master.tar.gz"),
...
}@args:

pimalaya.mkShell ({ rustToolchainFile = ./rust-toolchain.toml; }
// removeAttrs args [ "pimalaya" ])
pimalaya.mkShell ({ rustToolchainFile = ./rust-toolchain.toml; } // removeAttrs args [ "pimalaya" ])

0 comments on commit 0f6217e

Please sign in to comment.