2021-04-17 22:06:11 +00:00
|
|
|
{
|
2023-12-31 10:05:08 +00:00
|
|
|
description = "CLI to manage emails";
|
2021-04-17 22:06:11 +00:00
|
|
|
|
|
|
|
inputs = {
|
2024-01-01 15:22:30 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
|
2023-04-30 22:19:59 +00:00
|
|
|
gitignore = {
|
|
|
|
url = "github:hercules-ci/gitignore.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
naersk = {
|
|
|
|
url = "github:nix-community/naersk";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2021-04-17 22:06:11 +00:00
|
|
|
};
|
2023-05-03 14:54:39 +00:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2021-04-17 22:06:11 +00:00
|
|
|
};
|
|
|
|
|
2024-03-07 17:40:35 +00:00
|
|
|
outputs = { self, nixpkgs, gitignore, fenix, naersk, ... }:
|
2023-04-30 22:19:59 +00:00
|
|
|
let
|
|
|
|
inherit (gitignore.lib) gitignoreSource;
|
2021-04-17 22:06:11 +00:00
|
|
|
|
2023-05-01 14:13:31 +00:00
|
|
|
mkToolchain = import ./rust-toolchain.nix fenix;
|
2021-04-17 22:06:11 +00:00
|
|
|
|
2023-04-30 22:19:59 +00:00
|
|
|
mkDevShells = buildPlatform:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = buildPlatform; };
|
2023-05-01 14:13:31 +00:00
|
|
|
rust-toolchain = mkToolchain.fromFile { system = buildPlatform; };
|
2023-04-30 22:19:59 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
default = pkgs.mkShell {
|
2024-01-01 15:22:30 +00:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
];
|
2023-04-30 22:19:59 +00:00
|
|
|
buildInputs = with pkgs; [
|
2023-12-31 10:05:08 +00:00
|
|
|
# Nix
|
2022-05-28 12:36:32 +00:00
|
|
|
rnix-lsp
|
|
|
|
nixpkgs-fmt
|
|
|
|
|
2023-12-31 10:05:08 +00:00
|
|
|
# Rust
|
2023-04-30 22:19:59 +00:00
|
|
|
rust-toolchain
|
2024-01-12 09:16:43 +00:00
|
|
|
cargo-watch
|
2022-05-28 12:36:32 +00:00
|
|
|
|
2024-01-09 08:28:45 +00:00
|
|
|
# OpenSSL
|
|
|
|
openssl.dev
|
|
|
|
|
2023-12-31 10:05:08 +00:00
|
|
|
# Notmuch
|
2022-03-04 13:19:54 +00:00
|
|
|
notmuch
|
2023-08-05 10:10:25 +00:00
|
|
|
|
2023-12-31 10:05:08 +00:00
|
|
|
# GPG
|
2023-08-28 07:04:13 +00:00
|
|
|
gnupg
|
2023-08-05 10:10:25 +00:00
|
|
|
gpgme
|
2022-02-02 01:21:35 +00:00
|
|
|
];
|
2021-04-17 22:06:11 +00:00
|
|
|
};
|
2023-04-30 22:19:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
mkPackage = pkgs: buildPlatform: targetPlatform: package:
|
|
|
|
let
|
2023-05-01 14:13:31 +00:00
|
|
|
toolchain = mkToolchain.fromTarget {
|
|
|
|
inherit pkgs buildPlatform targetPlatform;
|
|
|
|
};
|
2023-04-30 22:19:59 +00:00
|
|
|
naersk' = naersk.lib.${buildPlatform}.override {
|
|
|
|
cargo = toolchain;
|
|
|
|
rustc = toolchain;
|
|
|
|
};
|
|
|
|
package' = {
|
|
|
|
name = "himalaya";
|
|
|
|
src = gitignoreSource ./.;
|
|
|
|
overrideMain = _: {
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/applications/
|
|
|
|
cp assets/himalaya.desktop $out/share/applications/
|
|
|
|
'';
|
|
|
|
};
|
2023-04-30 22:44:59 +00:00
|
|
|
doCheck = true;
|
|
|
|
cargoTestOptions = opts: opts ++ [ "--lib" ];
|
2023-04-30 22:19:59 +00:00
|
|
|
} // pkgs.lib.optionalAttrs (!isNull targetPlatform) {
|
|
|
|
CARGO_BUILD_TARGET = targetPlatform;
|
|
|
|
} // package;
|
|
|
|
in
|
|
|
|
naersk'.buildPackage package';
|
|
|
|
|
|
|
|
mkPackages = buildPlatform:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = buildPlatform; };
|
2024-01-01 15:22:30 +00:00
|
|
|
mkPackage' = mkPackage pkgs buildPlatform;
|
2023-04-30 22:19:59 +00:00
|
|
|
in
|
2024-01-01 15:22:30 +00:00
|
|
|
rec {
|
|
|
|
default = if pkgs.stdenv.isDarwin then macos else linux;
|
|
|
|
linux = mkPackage' null { };
|
|
|
|
linux-musl = mkPackage' "x86_64-unknown-linux-musl" (with pkgs.pkgsStatic; {
|
2023-04-30 22:19:59 +00:00
|
|
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
|
|
|
hardeningDisable = [ "all" ];
|
|
|
|
});
|
2024-01-01 15:22:30 +00:00
|
|
|
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 ];
|
|
|
|
});
|
2023-08-28 07:04:13 +00:00
|
|
|
# FIXME: bzlip: fatal error: windows.h: No such file or directory
|
|
|
|
# May be related to SQLite.
|
2024-01-01 15:22:30 +00:00
|
|
|
windows = mkPackage' "x86_64-pc-windows-gnu" {
|
2023-04-30 22:19:59 +00:00
|
|
|
strictDeps = true;
|
|
|
|
depsBuildBuild = with pkgs.pkgsCross.mingwW64; [
|
|
|
|
stdenv.cc
|
|
|
|
windows.pthreads
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-03-07 17:40:35 +00:00
|
|
|
mkApp = drv:
|
|
|
|
let exePath = drv.passthru.exePath or "/bin/himalaya";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
type = "app";
|
|
|
|
program = "${drv}${exePath}";
|
|
|
|
};
|
2023-04-30 22:19:59 +00:00
|
|
|
|
2024-01-01 15:22:30 +00:00
|
|
|
mkApps = buildPlatform:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = buildPlatform; };
|
|
|
|
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;
|
|
|
|
};
|
2024-03-07 17:40:35 +00:00
|
|
|
supportedSystems = [ "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
|
|
|
|
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems f;
|
2023-04-30 22:19:59 +00:00
|
|
|
in
|
2024-03-07 17:40:35 +00:00
|
|
|
{
|
|
|
|
apps = forEachSupportedSystem mkApps;
|
|
|
|
packages = forEachSupportedSystem mkPackages;
|
|
|
|
devShells = forEachSupportedSystem mkDevShells;
|
|
|
|
};
|
2021-04-17 22:06:11 +00:00
|
|
|
}
|