From 51ba814ac125cce8fda6b1a6e1e7c9d73fa93f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Mon, 25 Nov 2024 14:40:57 +0100 Subject: [PATCH] add custom emulator --- default.nix | 12 ++++++------ package.nix | 1 + systems.nix | 10 +--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/default.nix b/default.nix index 00f0bcd6..67277752 100644 --- a/default.nix +++ b/default.nix @@ -1,18 +1,18 @@ -{ target ? null +{ target , defaultFeatures ? true , features ? "" }: let systems = import ./systems.nix; - inherit (systems.${target}) rustTarget isStatic; + system = systems.${target}; - pkgs = import (fetchTarball "https://github.com/soywod/nixpkgs/archive/master.tar.gz") (if isNull target then { } else { + pkgs = import (fetchTarball "https://github.com/soywod/nixpkgs/archive/master.tar.gz") { crossSystem = { isStatic = true; config = target; }; - }); + }; inherit (pkgs) lib hostPlatform; @@ -22,7 +22,7 @@ let rustToolchain = mkToolchain.fromTarget { inherit lib; - targetSystem = rustTarget; + targetSystem = system.rustTarget; }; rustPlatform = pkgs.makeRustPlatform { @@ -32,7 +32,7 @@ let himalayaExe = let ext = lib.optionalString hostPlatform.isWindows ".exe"; - in "${hostPlatform.emulator pkgs.buildPackages} ./himalaya${ext}"; + in "${(system.emulator or hostPlatform.emulator) pkgs.buildPackages} ./himalaya${ext}"; himalaya = import ./package.nix { inherit lib hostPlatform rustPlatform; diff --git a/package.nix b/package.nix index 46630cbe..619ed100 100644 --- a/package.nix +++ b/package.nix @@ -37,6 +37,7 @@ rustPlatform.buildRustPackage rec { ++ lib.optional (installManPages || installShellCompletions) installShellFiles; buildInputs = [ ] + ++ lib.optionals hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [ Security ]) ++ lib.optional (builtins.elem "notmuch" buildFeatures) notmuch ++ lib.optional (builtins.elem "pgp-gpg" buildFeatures) gpgme; diff --git a/systems.nix b/systems.nix index a50cc552..ae93ee0f 100644 --- a/systems.nix +++ b/systems.nix @@ -1,46 +1,38 @@ { aarch64-apple-darwin = { rustTarget = "aarch64-apple-darwin"; - isStatic = true; }; aarch64-unknown-linux-musl = { rustTarget = "aarch64-unknown-linux-musl"; - isStatic = true; }; armv6l-unknown-linux-musleabihf = { rustTarget = "arm-unknown-linux-musleabihf"; - isStatic = true; }; armv7l-unknown-linux-musleabihf = { rustTarget = "armv7-unknown-linux-musleabihf"; - isStatic = true; }; i686-unknown-linux-musl = { rustTarget = "i686-unknown-linux-musl"; - isStatic = true; }; i686-w64-mingw32 = { rustTarget = "i686-pc-windows-gnu"; - isStatic = false; + emulator = pkgs: "${pkgs.wine}/bin/wine"; }; x86_64-apple-darwin = { rustTarget = "x86_64-apple-darwin"; - isStatic = true; }; x86_64-unknown-linux-musl = { rustTarget = "x86_64-unknown-linux-musl"; - isStatic = true; }; x86_64-w64-mingw32 = { rustTarget = "x86_64-pc-windows-gnu"; - isStatic = false; }; }