2021-04-17 22:06:11 +00:00
|
|
|
{
|
2023-04-30 22:19:59 +00:00
|
|
|
description = "CLI to manage your emails.";
|
2021-04-17 22:06:11 +00:00
|
|
|
|
|
|
|
inputs = {
|
2023-04-30 22:19:59 +00:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.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";
|
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
|
|
|
};
|
|
|
|
|
2023-05-03 14:54:39 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils, 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 {
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
# Nix env
|
2022-05-28 12:36:32 +00:00
|
|
|
rnix-lsp
|
|
|
|
nixpkgs-fmt
|
|
|
|
|
|
|
|
# Rust env
|
2023-04-30 22:19:59 +00:00
|
|
|
rust-toolchain
|
2022-05-28 12:36:32 +00:00
|
|
|
|
2023-04-30 22:19:59 +00:00
|
|
|
# notmuch
|
2022-03-04 13:19:54 +00:00
|
|
|
notmuch
|
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; };
|
|
|
|
mkPackageWithTarget = mkPackage pkgs buildPlatform;
|
|
|
|
defaultPackage = mkPackage pkgs buildPlatform null { };
|
|
|
|
in
|
|
|
|
{
|
|
|
|
default = defaultPackage;
|
|
|
|
linux = defaultPackage;
|
|
|
|
macos = defaultPackage;
|
|
|
|
musl = mkPackageWithTarget "x86_64-unknown-linux-musl" (with pkgs.pkgsStatic; {
|
|
|
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
|
|
|
SQLITE3_STATIC = 1;
|
|
|
|
SQLITE3_LIB_DIR = "${sqlite.out}/lib";
|
|
|
|
hardeningDisable = [ "all" ];
|
|
|
|
});
|
|
|
|
# FIXME: package does not build, assembler messages: unknown
|
|
|
|
# pseudo-op…
|
|
|
|
windows = mkPackageWithTarget "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";
|
|
|
|
};
|
|
|
|
|
|
|
|
mkApps = buildPlatform: {
|
|
|
|
default = mkApp self.packages.${buildPlatform}.default;
|
|
|
|
linux = mkApp self.packages.${buildPlatform}.linux;
|
|
|
|
macos = mkApp self.packages.${buildPlatform}.macos;
|
|
|
|
musl = mkApp self.packages.${buildPlatform}.musl;
|
|
|
|
windows =
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { system = buildPlatform; };
|
|
|
|
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;
|
|
|
|
});
|
2021-04-17 22:06:11 +00:00
|
|
|
}
|