From 69e66b307a150e13d9eb5f251bd56e3f86ae3dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Tue, 26 Nov 2024 10:37:14 +0100 Subject: [PATCH] clean all --- .github/workflows/pre-release.yml | 51 ++++++++++++++++--------------- default.nix | 41 ++++++++++--------------- package.nix | 13 ++------ rust-toolchain.nix | 29 ++++++------------ 4 files changed, 53 insertions(+), 81 deletions(-) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index eef99576..c5c96df3 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -10,33 +10,34 @@ jobs: fail-fast: false matrix: include: - # - system: aarch64-macos - # target: aarch64-apple-darwin - # os: macos-14 - # - system: aarch64-linux - # target: aarch64-unknown-linux-musl - # os: ubuntu-latest - # - system: armv6l-linux - # target: armv6l-unknown-linux-musleabihf - # os: ubuntu-latest - # - system: armv7l-linux - # target: armv7l-unknown-linux-musleabihf - # os: ubuntu-latest - # - system: i686-linux - # target: i686-unknown-linux-musl - # os: ubuntu-latest - - system: i686-windows - target: i686-w64-mingw32 + - system: aarch64-macos-14 + target: aarch64-apple-darwin + os: macos-14 + - system: aarch64-linux + target: aarch64-unknown-linux-musl os: ubuntu-latest - # - system: x86_64-macos - # target: x86_64-apple-darwin - # os: macos-13 - # - system: x86_64-linux - # target: x86_64-unknown-linux-musl - # os: ubuntu-latest - # - system: x86_64-windows - # target: x86_64-w64-mingw32 + - system: armv6l-linux + target: armv6l-unknown-linux-musleabihf + os: ubuntu-latest + - system: armv7l-linux + target: armv7l-unknown-linux-musleabihf + os: ubuntu-latest + - system: i686-linux + target: i686-unknown-linux-musl + os: ubuntu-latest + # FIXME + # - system: i686-windows + # target: i686-w64-mingw32 # os: ubuntu-latest + - system: x86_64-macos-13 + target: x86_64-apple-darwin + os: macos-13 + - system: x86_64-linux + target: x86_64-unknown-linux-musl + os: ubuntu-latest + - system: x86_64-windows + target: x86_64-w64-mingw32 + os: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/default.nix b/default.nix index b1b2a4ba..82f70393 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,5 @@ { target ? null -, isStatic ? true +, isStatic ? false , defaultFeatures ? true , features ? "" }: @@ -17,28 +17,30 @@ let } ); - systems = import ./systems.nix; - system = if isNull target then null else systems.${target}; - inherit (pkgs) lib hostPlatform; - fenix = import (fetchTarball "https://github.com/soywod/fenix/archive/main.tar.gz") { }; - mkToolchain = import ./rust-toolchain.nix fenix; - - rustToolchain = mkToolchain.fromTarget { - inherit lib; - target = if isNull system then null else system.rustTarget; - }; - + rustTarget = if isNull target then null else hostPlatform.rust.rustcTarget; + rustToolchain = mkToolchain.fromTarget { inherit lib; target = rustTarget; }; rustPlatform = pkgs.makeRustPlatform { rustc = rustToolchain; cargo = rustToolchain; }; + # HACK: https://github.com/NixOS/nixpkgs/issues/177129 + empty-libgcc_eh = stdenv.mkDerivation { + pname = "empty-libgcc_eh"; + version = "0"; + dontUnpack = true; + installPhase = '' + mkdir -p "$out"/lib + "${lib.getExe' binutils "ar"}" r "$out"/lib/libgcc_eh.a + ''; + }; + himalayaExe = let ext = lib.optionalString hostPlatform.isWindows ".exe"; - in "${(system.emulator or hostPlatform.emulator) buildPackages} ./himalaya${ext}"; + in "${hostPlatform.emulator buildPackages} ./himalaya${ext}"; himalaya = import ./package.nix { inherit lib rustPlatform; @@ -55,24 +57,13 @@ let buildNoDefaultFeatures = !defaultFeatures; buildFeatures = lib.strings.splitString "," features; }; - - # HACK: https://github.com/NixOS/nixpkgs/issues/177129 - empty-libgcc_eh = stdenv.mkDerivation { - pname = "empty-libgcc_eh"; - version = "0"; - dontUnpack = true; - installPhase = '' - mkdir -p "$out"/lib - "${lib.getExe' binutils "ar"}" r "$out"/lib/libgcc_eh.a - ''; - }; in himalaya.overrideAttrs (drv: { version = "1.0.0"; propagatedBuildInputs = (drv.propagatedBuildInputs or [ ]) - ++ lib.optional false empty-libgcc_eh; + ++ lib.optional hostPlatform.isWindows empty-libgcc_eh; postInstall = (drv.postInstall or "") + lib.optionalString hostPlatform.isWindows '' export WINEPREFIX="$(${lib.getExe' mktemp "mktemp"} -d)" diff --git a/package.nix b/package.nix index 3fa8d109..4012d3b2 100644 --- a/package.nix +++ b/package.nix @@ -29,18 +29,10 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-YS8IamapvmdrOPptQh2Ef9Yold0IK1XIeGs0kDIQ5b8="; - # NIX_LDFLAGS = lib.optionals (stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isi686) [ - # "-L${windows.mcfgthreads}/lib" - # "-L${libunwind}/lib" - # # "-L${windows.mingwrt}/lib" - # #"-L${windows.w32api}/lib" - # "-lmcfgthread" - # "-lunwind" - # ]; - - # unit tests only doCheck = false; auditable = false; + + # unit tests only cargoTestFlags = [ "--lib" ]; nativeBuildInputs = [ pkg-config ] @@ -48,7 +40,6 @@ rustPlatform.buildRustPackage rec { buildInputs = [ ] ++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk - # ++ lib.optional (stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isi686) windows.mcfgthreads ++ lib.optional (builtins.elem "notmuch" buildFeatures) notmuch ++ lib.optional (builtins.elem "pgp-gpg" buildFeatures) gpgme; diff --git a/rust-toolchain.nix b/rust-toolchain.nix index 26ec6aa9..fa5aef93 100644 --- a/rust-toolchain.nix +++ b/rust-toolchain.nix @@ -5,31 +5,20 @@ let sha256 = "+syqAd2kX8KVa8/U2gz3blIQTTsYYt3U63xBWaGOSc8="; in -rec { - fromFile = { buildSystem }: fenix.packages.${buildSystem}.fromToolchainFile { - inherit file sha256; - }; - - toRustTarget = target: { - x86_64-w64-mingw32 = "x86_64-pc-windows-gnu"; - i686-w64-mingw32 = "i686-pc-windows-gnu"; - armv6l-unknown-linux-musleabihf = "arm-unknown-linux-musleabihf"; - armv7l-unknown-linux-musleabihf = "armv7-unknown-linux-musleabihf"; - }.${target} or target; - - crossRustStd = name: target: - let - rustTarget = toRustTarget target; - crossToolchain = fenix.targets.${rustTarget}.fromToolchainName { inherit name sha256; }; - in - crossToolchain.rust-std; +{ + # fromFile = { buildSystem }: fenix.packages.${buildSystem}.fromToolchainFile { + # inherit file sha256; + # }; fromTarget = { lib, target ? null }: let name = (lib.importTOML file).toolchain.channel; - toolchain = fenix.fromToolchainName { inherit name sha256; }; + specs = { inherit name sha256; }; + toolchain = fenix.fromToolchainName specs; + crossToolchain = fenix.targets.${target}.fromToolchainName specs; components = [ toolchain.rustc toolchain.cargo ] - ++ lib.optional (!isNull target) (crossRustStd name target); + ++ lib.optional (!isNull target) crossToolchain; in + fenix.combine components; }