2022-03-22 18:03:25 +08:00
|
|
|
{ pkgs }:
|
|
|
|
let
|
|
|
|
msys2-env = pkgs.stdenvNoCC.mkDerivation rec {
|
|
|
|
name = "msys2-env";
|
|
|
|
srcs = import ./msys2_packages.nix { inherit pkgs; };
|
|
|
|
buildInputs = [ pkgs.gnutar pkgs.zstd ];
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
installPhase = (pkgs.lib.strings.concatStringsSep "\n" (["mkdir $out"] ++ (map (p: "tar xvf ${p} -C $out") srcs)));
|
|
|
|
};
|
2022-03-22 19:19:06 +08:00
|
|
|
silenceFontconfig = # silence flood of "Fontconfig error: Cannot load default config file: No such file: (null)"
|
|
|
|
''
|
|
|
|
export FONTCONFIG_PATH=$HOME/fonts
|
|
|
|
mkdir $FONTCONFIG_PATH
|
|
|
|
cat > $FONTCONFIG_PATH/fonts.conf << EOF
|
|
|
|
<fontconfig>
|
|
|
|
</fontconfig>
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
pyo3-mingw-config = pkgs.writeTextFile {
|
|
|
|
name = "pyo3-mingw-config";
|
|
|
|
text =
|
|
|
|
''
|
|
|
|
implementation=CPython
|
2022-08-05 17:27:07 +08:00
|
|
|
version=3.10
|
2022-03-22 19:19:06 +08:00
|
|
|
shared=true
|
|
|
|
abi3=false
|
2022-08-05 17:27:07 +08:00
|
|
|
lib_name=python3.10
|
2022-03-22 19:19:06 +08:00
|
|
|
lib_dir=${msys2-env}/mingw64/lib
|
|
|
|
pointer_width=64
|
|
|
|
build_flags=WITH_THREAD
|
|
|
|
suppress_build_script_link_lines=false
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in rec {
|
2022-03-22 18:03:25 +08:00
|
|
|
llvm-nac3 = pkgs.stdenvNoCC.mkDerivation rec {
|
2022-03-26 15:15:39 +08:00
|
|
|
pname = "llvm-nac3-msys2";
|
2022-07-02 19:04:19 +08:00
|
|
|
version = "14.0.6";
|
2022-03-22 18:03:25 +08:00
|
|
|
src-llvm = pkgs.fetchurl {
|
2022-03-26 15:15:39 +08:00
|
|
|
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-${version}.src.tar.xz";
|
2022-07-02 19:04:19 +08:00
|
|
|
sha256 = "sha256-BQki7KrKV4H99mMeqSvHFRg/IC+dLxUUcibwI0FPYZo=";
|
2022-03-22 18:03:25 +08:00
|
|
|
};
|
|
|
|
src-clang = pkgs.fetchurl {
|
2022-03-26 15:15:39 +08:00
|
|
|
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/clang-${version}.src.tar.xz";
|
2022-07-02 19:04:19 +08:00
|
|
|
sha256 = "sha256-K1hHtqYxGLnv5chVSDY8gf/glrZsOzZ16VPiY0KuQDE=";
|
2022-03-22 18:03:25 +08:00
|
|
|
};
|
|
|
|
buildInputs = [ pkgs.wineWowPackages.stable ];
|
|
|
|
phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ];
|
|
|
|
unpackPhase =
|
|
|
|
''
|
|
|
|
mkdir llvm
|
|
|
|
tar xf ${src-llvm} -C llvm --strip-components=1
|
2022-04-18 18:47:20 +08:00
|
|
|
mv llvm/Modules/* llvm/cmake/modules # work around https://github.com/llvm/llvm-project/issues/53281
|
2022-03-22 18:03:25 +08:00
|
|
|
mkdir clang
|
|
|
|
tar xf ${src-clang} -C clang --strip-components=1
|
|
|
|
cd llvm
|
2022-03-22 18:35:06 +08:00
|
|
|
# build of llvm-lto fails and -DLLVM_BUILD_TOOLS=OFF does not disable it reliably because cmake
|
|
|
|
rm -rf tools/lto
|
2022-03-22 18:03:25 +08:00
|
|
|
'';
|
|
|
|
patches = [ ../llvm/llvm-future-riscv-abi.diff ];
|
|
|
|
configurePhase =
|
|
|
|
''
|
|
|
|
export HOME=`mktemp -d`
|
|
|
|
export WINEDEBUG=-all
|
2022-03-22 19:38:32 +08:00
|
|
|
export WINEPATH=Z:${msys2-env}/mingw64/bin
|
2022-03-22 19:19:06 +08:00
|
|
|
${silenceFontconfig}
|
2022-03-22 18:03:25 +08:00
|
|
|
mkdir build
|
|
|
|
cd build
|
2022-04-18 18:47:20 +08:00
|
|
|
wine64 cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_THREADS=OFF -DLLVM_TARGETS_TO_BUILD=X86\;ARM\;RISCV -DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_ENABLE_FFI=OFF -DFFI_INCLUDE_DIR=fck-cmake -DFFI_LIBRARY_DIR=fck-cmake -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_INSTALL_PREFIX=Z:$out
|
2022-03-22 18:03:25 +08:00
|
|
|
'';
|
|
|
|
buildPhase =
|
|
|
|
''
|
2022-08-05 18:24:00 +08:00
|
|
|
wine64 ninja -j $NIX_BUILD_CORES
|
2022-03-22 18:03:25 +08:00
|
|
|
'';
|
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
wine64 ninja install
|
|
|
|
'';
|
2022-03-27 18:38:23 +08:00
|
|
|
dontFixup = true;
|
2022-03-22 18:03:25 +08:00
|
|
|
};
|
2022-03-22 19:19:06 +08:00
|
|
|
nac3artiq = pkgs.rustPlatform.buildRustPackage {
|
2022-03-26 15:15:39 +08:00
|
|
|
name = "nac3artiq-msys2";
|
2022-03-26 15:46:21 +08:00
|
|
|
src = ../../.;
|
2022-04-18 18:47:20 +08:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ../../Cargo.lock;
|
|
|
|
outputHashes = {
|
2022-07-02 19:04:19 +08:00
|
|
|
"inkwell-0.1.0" = "sha256-+ih3SO0n6YmZ/mcf+rLDwPAy/1MEZ/A+tI4pM1pUhvU=";
|
2022-04-18 18:47:20 +08:00
|
|
|
};
|
|
|
|
};
|
2022-04-04 14:24:47 +08:00
|
|
|
nativeBuildInputs = [ pkgs.wineWowPackages.stable ];
|
2022-03-22 19:19:06 +08:00
|
|
|
buildPhase =
|
|
|
|
''
|
|
|
|
export HOME=`mktemp -d`
|
|
|
|
export WINEDEBUG=-all
|
2022-03-22 19:40:40 +08:00
|
|
|
export WINEPATH=Z:${msys2-env}/mingw64/bin\;Z:${llvm-nac3}/bin
|
2022-03-22 19:19:06 +08:00
|
|
|
${silenceFontconfig}
|
|
|
|
export PYO3_CONFIG_FILE=Z:${pyo3-mingw-config}
|
|
|
|
wine64 cargo build --release -p nac3artiq
|
|
|
|
'';
|
2022-03-22 19:58:31 +08:00
|
|
|
installPhase =
|
|
|
|
''
|
2022-04-04 14:24:47 +08:00
|
|
|
mkdir $out $out/nix-support
|
|
|
|
cp target/release/nac3artiq.dll $out/nac3artiq.pyd
|
|
|
|
echo file binary-dist $out/nac3artiq.pyd >> $out/nix-support/hydra-build-products
|
2022-03-22 19:58:31 +08:00
|
|
|
'';
|
2022-03-23 09:53:45 +08:00
|
|
|
checkPhase =
|
|
|
|
''
|
|
|
|
wine64 cargo test --release
|
|
|
|
'';
|
2022-03-22 19:58:31 +08:00
|
|
|
dontFixup = true;
|
2022-03-22 19:19:06 +08:00
|
|
|
};
|
2022-04-04 14:24:47 +08:00
|
|
|
nac3artiq-pkg = pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "nac3artiq-msys2-pkg";
|
|
|
|
nativeBuildInputs = [ pkgs.pacman pkgs.fakeroot pkgs.libarchive pkgs.zstd ];
|
|
|
|
src = nac3artiq;
|
|
|
|
phases = [ "buildPhase" "installPhase" ];
|
|
|
|
buildPhase =
|
|
|
|
''
|
|
|
|
ln -s ${./PKGBUILD} PKGBUILD
|
|
|
|
ln -s $src/nac3artiq.pyd nac3artiq.pyd
|
2022-04-04 16:03:59 +08:00
|
|
|
makepkg --config ${./makepkg.conf} --nodeps
|
2022-04-04 14:24:47 +08:00
|
|
|
'';
|
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
mkdir $out $out/nix-support
|
|
|
|
cp *.pkg.tar.zst $out
|
2022-04-04 15:03:53 +08:00
|
|
|
echo file msys2 $out/*.pkg.tar.zst >> $out/nix-support/hydra-build-products
|
2022-04-04 14:24:47 +08:00
|
|
|
'';
|
|
|
|
};
|
2022-03-22 22:14:46 +08:00
|
|
|
wine-msys2 = pkgs.writeShellScriptBin "wine-msys2"
|
|
|
|
''
|
|
|
|
export WINEDEBUG=-all
|
|
|
|
export WINEPATH=Z:${msys2-env}/mingw64/bin\;Z:${llvm-nac3}/bin
|
2022-03-23 09:22:33 +08:00
|
|
|
export PYO3_CONFIG_FILE=Z:${pyo3-mingw-config}
|
|
|
|
exec ${pkgs.wineWowPackages.stable}/bin/wine64 cmd
|
2022-03-22 22:14:46 +08:00
|
|
|
'';
|
2022-04-05 10:06:36 +08:00
|
|
|
wine-msys2-build = pkgs.writeShellScriptBin "wine-msys2-build"
|
|
|
|
''
|
|
|
|
export HOME=`mktemp -d`
|
|
|
|
export WINEDEBUG=-all
|
|
|
|
export WINEPATH=Z:${msys2-env}/mingw64/bin
|
|
|
|
${silenceFontconfig}
|
|
|
|
exec ${pkgs.wineWowPackages.stable}/bin/wine64 $@
|
|
|
|
'';
|
2022-03-22 18:03:25 +08:00
|
|
|
}
|