diff --git a/flake.nix b/flake.nix index 5a21605988..98b8518874 100644 --- a/flake.nix +++ b/flake.nix @@ -8,8 +8,18 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; android.url = "github:tadfisher/android-nixpkgs"; }; - outputs = { self, nixpkgs, flake-utils, nix-filter, naersk, fenix, android }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { self + , nixpkgs + , flake-utils + , nix-filter + , naersk + , fenix + , android + , + }: + flake-utils.lib.eachDefaultSystem ( + system: let pkgs = nixpkgs.legacyPackages.${system}; inherit (pkgs.stdenv) isDarwin; @@ -173,15 +183,17 @@ # Use DWARF-2 instead of SJLJ for exception handling. winCC = pkgsWin32.buildPackages.wrapCC ( (pkgsWin32.buildPackages.gcc-unwrapped.override - ({ + { threadsCross = { model = "win32"; package = null; }; - })).overrideAttrs (oldAttr: { - configureFlags = oldAttr.configureFlags ++ [ - "--disable-sjlj-exceptions --with-dwarf2" - ]; + }).overrideAttrs (oldAttr: { + configureFlags = + oldAttr.configureFlags + ++ [ + "--disable-sjlj-exceptions --with-dwarf2" + ]; }) ); in @@ -232,7 +244,7 @@ rustc = toolchain; }; in - naersk-lib.buildPackage rec { + naersk-lib.buildPackage { pname = packageName; cargoBuildOptions = x: x ++ [ "--package" packageName ]; version = manifest.version; @@ -243,16 +255,6 @@ ]; auditable = false; # Avoid cargo-auditable failures. doCheck = false; # Disable test as it requires network access. - - CARGO_BUILD_TARGET = rustTarget; - TARGET_CC = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc"; - CARGO_BUILD_RUSTFLAGS = [ - "-C" - "linker=${TARGET_CC}" - ]; - - CC = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc"; - LD = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc"; }; androidAttrs = { @@ -325,33 +327,32 @@ { "deltachat-repl-${arch}" = mkCrossRustPackage arch "deltachat-repl"; "deltachat-rpc-server-${arch}" = rpc-server; - "deltachat-rpc-server-${arch}-wheel" = - pkgs.stdenv.mkDerivation { - pname = "deltachat-rpc-server-${arch}-wheel"; - version = manifest.version; - src = nix-filter.lib { - root = ./.; - include = [ - "scripts/wheel-rpc-server.py" - "deltachat-rpc-server/README.md" - "LICENSE" - "Cargo.toml" - ]; - }; - nativeBuildInputs = [ - pkgs.python3 - pkgs.python3Packages.wheel - ]; - buildInputs = [ - rpc-server + "deltachat-rpc-server-${arch}-wheel" = pkgs.stdenv.mkDerivation { + pname = "deltachat-rpc-server-${arch}-wheel"; + version = manifest.version; + src = nix-filter.lib { + root = ./.; + include = [ + "scripts/wheel-rpc-server.py" + "deltachat-rpc-server/README.md" + "LICENSE" + "Cargo.toml" ]; - buildPhase = '' - mkdir tmp - cp ${rpc-server}/bin/deltachat-rpc-server tmp/deltachat-rpc-server - python3 scripts/wheel-rpc-server.py ${arch} tmp/deltachat-rpc-server - ''; - installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; + nativeBuildInputs = [ + pkgs.python3 + pkgs.python3Packages.wheel + ]; + buildInputs = [ + rpc-server + ]; + buildPhase = '' + mkdir tmp + cp ${rpc-server}/bin/deltachat-rpc-server tmp/deltachat-rpc-server + python3 scripts/wheel-rpc-server.py ${arch} tmp/deltachat-rpc-server + ''; + installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; + }; }; in { @@ -363,6 +364,8 @@ mkRustPackages "x86_64-linux" // mkRustPackages "armv7l-linux" // mkRustPackages "armv6l-linux" // + mkRustPackages "x86_64-darwin" // + mkRustPackages "aarch64-darwin" // mkAndroidPackages "armeabi-v7a" // mkAndroidPackages "arm64-v8a" // mkAndroidPackages "x86" // @@ -373,188 +376,181 @@ deltachat-repl-win64 = mkWin64RustPackage "deltachat-repl"; deltachat-rpc-server-win64 = mkWin64RustPackage "deltachat-rpc-server"; - deltachat-rpc-server-win64-wheel = - pkgs.stdenv.mkDerivation { - pname = "deltachat-rpc-server-win64-wheel"; - version = manifest.version; - src = nix-filter.lib { - root = ./.; - include = [ - "scripts/wheel-rpc-server.py" - "deltachat-rpc-server/README.md" - "LICENSE" - "Cargo.toml" - ]; - }; - nativeBuildInputs = [ - pkgs.python3 - pkgs.python3Packages.wheel - ]; - buildInputs = [ - deltachat-rpc-server-win64 + deltachat-rpc-server-win64-wheel = pkgs.stdenv.mkDerivation { + pname = "deltachat-rpc-server-win64-wheel"; + version = manifest.version; + src = nix-filter.lib { + root = ./.; + include = [ + "scripts/wheel-rpc-server.py" + "deltachat-rpc-server/README.md" + "LICENSE" + "Cargo.toml" ]; - buildPhase = '' - mkdir tmp - cp ${deltachat-rpc-server-win64}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe - python3 scripts/wheel-rpc-server.py win64 tmp/deltachat-rpc-server.exe - ''; - installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; + nativeBuildInputs = [ + pkgs.python3 + pkgs.python3Packages.wheel + ]; + buildInputs = [ + deltachat-rpc-server-win64 + ]; + buildPhase = '' + mkdir tmp + cp ${deltachat-rpc-server-win64}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe + python3 scripts/wheel-rpc-server.py win64 tmp/deltachat-rpc-server.exe + ''; + installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; + }; deltachat-repl-win32 = mkWin32RustPackage "deltachat-repl"; deltachat-rpc-server-win32 = mkWin32RustPackage "deltachat-rpc-server"; - deltachat-rpc-server-win32-wheel = - pkgs.stdenv.mkDerivation { - pname = "deltachat-rpc-server-win32-wheel"; - version = manifest.version; - src = nix-filter.lib { - root = ./.; - include = [ - "scripts/wheel-rpc-server.py" - "deltachat-rpc-server/README.md" - "LICENSE" - "Cargo.toml" - ]; - }; - nativeBuildInputs = [ - pkgs.python3 - pkgs.python3Packages.wheel - ]; - buildInputs = [ - deltachat-rpc-server-win32 + deltachat-rpc-server-win32-wheel = pkgs.stdenv.mkDerivation { + pname = "deltachat-rpc-server-win32-wheel"; + version = manifest.version; + src = nix-filter.lib { + root = ./.; + include = [ + "scripts/wheel-rpc-server.py" + "deltachat-rpc-server/README.md" + "LICENSE" + "Cargo.toml" ]; - buildPhase = '' - mkdir tmp - cp ${deltachat-rpc-server-win32}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe - python3 scripts/wheel-rpc-server.py win32 tmp/deltachat-rpc-server.exe - ''; - installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; }; + nativeBuildInputs = [ + pkgs.python3 + pkgs.python3Packages.wheel + ]; + buildInputs = [ + deltachat-rpc-server-win32 + ]; + buildPhase = '' + mkdir tmp + cp ${deltachat-rpc-server-win32}/bin/deltachat-rpc-server.exe tmp/deltachat-rpc-server.exe + python3 scripts/wheel-rpc-server.py win32 tmp/deltachat-rpc-server.exe + ''; + installPhase = ''mkdir -p $out; cp -av deltachat_rpc_server-*.whl $out''; + }; # Run `nix build .#docs` to get C docs generated in `./result/`. - docs = - pkgs.stdenv.mkDerivation { - pname = "docs"; - version = manifest.version; - src = pkgs.lib.cleanSource ./.; - nativeBuildInputs = [ pkgs.doxygen ]; - buildPhase = ''scripts/run-doxygen.sh''; - installPhase = ''mkdir -p $out; cp -av deltachat-ffi/html deltachat-ffi/xml $out''; - }; + docs = pkgs.stdenv.mkDerivation { + pname = "docs"; + version = manifest.version; + src = pkgs.lib.cleanSource ./.; + nativeBuildInputs = [ pkgs.doxygen ]; + buildPhase = ''scripts/run-doxygen.sh''; + installPhase = ''mkdir -p $out; cp -av deltachat-ffi/html deltachat-ffi/xml $out''; + }; - libdeltachat = - pkgs.stdenv.mkDerivation { - pname = "libdeltachat"; - version = manifest.version; - src = rustSrc; - cargoDeps = pkgs.rustPlatform.importCargoLock cargoLock; + libdeltachat = pkgs.stdenv.mkDerivation { + pname = "libdeltachat"; + version = manifest.version; + src = rustSrc; + cargoDeps = pkgs.rustPlatform.importCargoLock cargoLock; - nativeBuildInputs = [ - pkgs.perl # Needed to build vendored OpenSSL. - pkgs.cmake - pkgs.rustPlatform.cargoSetupHook - pkgs.cargo - ]; - buildInputs = pkgs.lib.optionals isDarwin [ - pkgs.darwin.apple_sdk.frameworks.CoreFoundation - pkgs.darwin.apple_sdk.frameworks.Security - pkgs.darwin.apple_sdk.frameworks.SystemConfiguration - pkgs.libiconv - ]; + nativeBuildInputs = [ + pkgs.perl # Needed to build vendored OpenSSL. + pkgs.cmake + pkgs.rustPlatform.cargoSetupHook + pkgs.cargo + ]; + buildInputs = pkgs.lib.optionals isDarwin [ + pkgs.darwin.apple_sdk.frameworks.CoreFoundation + pkgs.darwin.apple_sdk.frameworks.Security + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration + pkgs.libiconv + ]; - postInstall = '' - substituteInPlace $out/include/deltachat.h \ - --replace __FILE__ '"${placeholder "out"}/include/deltachat.h"' - ''; - }; + postInstall = '' + substituteInPlace $out/include/deltachat.h \ + --replace __FILE__ '"${placeholder "out"}/include/deltachat.h"' + ''; + }; # Source package for deltachat-rpc-server. # Fake package that downloads Linux version, # needed to install deltachat-rpc-server on Android with `pip`. - deltachat-rpc-server-source = - pkgs.stdenv.mkDerivation { - pname = "deltachat-rpc-server-source"; - version = manifest.version; - src = pkgs.lib.cleanSource ./.; - nativeBuildInputs = [ - pkgs.python3 - pkgs.python3Packages.wheel - ]; - buildPhase = ''python3 scripts/wheel-rpc-server.py source deltachat-rpc-server-${manifest.version}.tar.gz''; - installPhase = ''mkdir -p $out; cp -av deltachat-rpc-server-${manifest.version}.tar.gz $out''; - }; + deltachat-rpc-server-source = pkgs.stdenv.mkDerivation { + pname = "deltachat-rpc-server-source"; + version = manifest.version; + src = pkgs.lib.cleanSource ./.; + nativeBuildInputs = [ + pkgs.python3 + pkgs.python3Packages.wheel + ]; + buildPhase = ''python3 scripts/wheel-rpc-server.py source deltachat-rpc-server-${manifest.version}.tar.gz''; + installPhase = ''mkdir -p $out; cp -av deltachat-rpc-server-${manifest.version}.tar.gz $out''; + }; - deltachat-rpc-client = - pkgs.python3Packages.buildPythonPackage { - pname = "deltachat-rpc-client"; - version = manifest.version; - src = pkgs.lib.cleanSource ./deltachat-rpc-client; - format = "pyproject"; - propagatedBuildInputs = [ - pkgs.python3Packages.setuptools - pkgs.python3Packages.imap-tools - ]; - }; + deltachat-rpc-client = pkgs.python3Packages.buildPythonPackage { + pname = "deltachat-rpc-client"; + version = manifest.version; + src = pkgs.lib.cleanSource ./deltachat-rpc-client; + format = "pyproject"; + propagatedBuildInputs = [ + pkgs.python3Packages.setuptools + pkgs.python3Packages.imap-tools + ]; + }; - deltachat-python = - pkgs.python3Packages.buildPythonPackage { - pname = "deltachat-python"; - version = manifest.version; - src = pkgs.lib.cleanSource ./python; - format = "pyproject"; - buildInputs = [ - libdeltachat - ]; - nativeBuildInputs = [ - pkgs.pkg-config - ]; - propagatedBuildInputs = [ - pkgs.python3Packages.setuptools - pkgs.python3Packages.pkgconfig - pkgs.python3Packages.cffi - pkgs.python3Packages.imap-tools - pkgs.python3Packages.pluggy - pkgs.python3Packages.requests - ]; - }; - python-docs = - pkgs.stdenv.mkDerivation { - pname = "docs"; - version = manifest.version; - src = pkgs.lib.cleanSource ./.; - buildInputs = [ - deltachat-python - deltachat-rpc-client - pkgs.python3Packages.breathe - pkgs.python3Packages.sphinx_rtd_theme - ]; - nativeBuildInputs = [ pkgs.sphinx ]; - buildPhase = ''sphinx-build -b html -a python/doc/ dist/html''; - installPhase = ''mkdir -p $out; cp -av dist/html $out''; - }; + deltachat-python = pkgs.python3Packages.buildPythonPackage { + pname = "deltachat-python"; + version = manifest.version; + src = pkgs.lib.cleanSource ./python; + format = "pyproject"; + buildInputs = [ + libdeltachat + ]; + nativeBuildInputs = [ + pkgs.pkg-config + ]; + propagatedBuildInputs = [ + pkgs.python3Packages.setuptools + pkgs.python3Packages.pkgconfig + pkgs.python3Packages.cffi + pkgs.python3Packages.imap-tools + pkgs.python3Packages.pluggy + pkgs.python3Packages.requests + ]; + }; + python-docs = pkgs.stdenv.mkDerivation { + pname = "docs"; + version = manifest.version; + src = pkgs.lib.cleanSource ./.; + buildInputs = [ + deltachat-python + deltachat-rpc-client + pkgs.python3Packages.breathe + pkgs.python3Packages.sphinx_rtd_theme + ]; + nativeBuildInputs = [ pkgs.sphinx ]; + buildPhase = ''sphinx-build -b html -a python/doc/ dist/html''; + installPhase = ''mkdir -p $out; cp -av dist/html $out''; + }; }; - devShells.default = let - pkgs = import nixpkgs { - system = system; - overlays = [ fenix.overlays.default ]; + devShells.default = + let + pkgs = import nixpkgs { + system = system; + overlays = [ fenix.overlays.default ]; + }; + in + pkgs.mkShell { + buildInputs = with pkgs; [ + (fenix.packages.${system}.complete.withComponents [ + "cargo" + "clippy" + "rust-src" + "rustc" + "rustfmt" + ]) + cargo-deny + rust-analyzer-nightly + cargo-nextest + perl # needed to build vendored OpenSSL + git-cliff + ]; }; - in pkgs.mkShell { - - buildInputs = with pkgs; [ - (fenix.packages.${system}.complete.withComponents [ - "cargo" - "clippy" - "rust-src" - "rustc" - "rustfmt" - ]) - cargo-deny - rust-analyzer-nightly - cargo-nextest - perl # needed to build vendored OpenSSL - git-cliff - ]; - }; } ); }