himalaya/flake.nix

152 lines
4.6 KiB
Nix
Raw Normal View History

{
description = "CLI to manage emails";
inputs = {
2024-01-01 15:22:30 +00:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
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";
};
2023-05-03 14:54:39 +00:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
2023-05-03 14:54:39 +00:00
outputs = { self, nixpkgs, flake-utils, gitignore, fenix, naersk, ... }:
let
inherit (gitignore.lib) gitignoreSource;
mkToolchain = import ./rust-toolchain.nix fenix;
mkDevShells = buildPlatform:
let
pkgs = import nixpkgs { system = buildPlatform; };
rust-toolchain = mkToolchain.fromFile { system = buildPlatform; };
in
{
default = pkgs.mkShell {
2024-01-01 15:22:30 +00:00
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
# Nix
rnix-lsp
nixpkgs-fmt
# Rust
rust-toolchain
2024-01-12 09:16:43 +00:00
cargo-watch
# OpenSSL
openssl.dev
# Notmuch
notmuch
2023-08-05 10:10:25 +00:00
# GPG
2023-08-28 07:04:13 +00:00
gnupg
2023-08-05 10:10:25 +00:00
gpgme
release v0.5.2 (#282) * doc: fix blur in list msg screenshots (#181) * fix a typo in mbox arg (#245) `targetted` to `targeted` 👌🏻 * make inbox, sent and drafts folder customizable (#246) * mbox: make inbox, sent and drafts folder customizable * msg: update send handler parameters order * vim: fix extracting message ids from list (#247) The current method doesn't work because the list uses a fancy line character (`│`) as the separator, not a regular pipe character (`|`). Matching for the first number in the line instead solves the problem and will continue to work regardless of what separator is used. * add new line after printing strings (#251) * init cargo workspace (#252) * init cargo workspaces * nix: fix assets path * doc: update rtp vim plugin * vim: add error message if loading vim plugin from vim/ * init sub crates (#253) * init sub crates * doc: update readme * doc: improve main readme * doc: add links, add missing crate task * doc: update emojis * update cargo lock * implement contact completion with completefunc (#250) This allows users to define a command for contact completion with `g:himalaya_complete_contact_cmd` and trigger it with `<C-x><C-u>` when writing an email. * fix clippy lints (#255) * revert cargo workspace feature * fix nix run (#274) * replace cargo2nix by naersk * add rust-analyzer and rustfmt to nix build inputs * remove wiki from git submodules, update changelog * fix missing range when fetch fails, add more logs (#276) * add missing fix in changelog * remove blank lines and spaces from plain parts (#280) * fix watch command (#271) * remove also tabs from text parts (#280) * pin native-tls minor version (#278) * improve msg sanitization (#280) * fix mbox vim plugin telescope preview (#249) * bump version v0.5.2 * update changelog Co-authored-by: Austin Traver <austintraver@gmail.com> Co-authored-by: Jason Cox <dev@jasoncarloscox.com> Co-authored-by: Gökmen Görgen <gkmngrgn@gmail.com> Co-authored-by: Ethiraric <ethiraric@gmail.com>
2022-02-02 01:21:35 +00:00
];
};
};
mkPackage = pkgs: buildPlatform: targetPlatform: package:
let
toolchain = mkToolchain.fromTarget {
inherit pkgs buildPlatform targetPlatform;
};
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" ];
} // 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;
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; {
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" {
strictDeps = true;
depsBuildBuild = with pkgs.pkgsCross.mingwW64; [
stdenv.cc
windows.pthreads
];
};
};
mkApp = drv: flake-utils.lib.mkApp {
inherit drv;
name = "himalaya";
};
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;
};
in
flake-utils.lib.eachDefaultSystem (system: {
devShells = mkDevShells system;
packages = mkPackages system;
apps = mkApps system;
});
}