artiq-extrapkg/msys2/default.nix

84 lines
2.5 KiB
Nix
Raw Permalink Normal View History

2022-10-24 18:06:21 +08:00
{ pkgs }:
let
msys2-env = pkgs.stdenvNoCC.mkDerivation rec {
name = "msys2-env";
2022-10-24 18:52:11 +08:00
srcs = import ./msys2_packages.nix { inherit pkgs; };
2022-10-24 18:06:21 +08:00
buildInputs = [ pkgs.gnutar pkgs.zstd ];
phases = [ "installPhase" ];
installPhase = (pkgs.lib.strings.concatStringsSep "\n" (["mkdir $out"] ++ (map (p: "tar xvf ${p} -C $out") srcs)));
};
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
'';
2023-04-24 16:25:50 +08:00
wine-msys2 = pkgs.writeShellScriptBin "wine-msys2"
''
export WINEDEBUG=-all
export WINEPATH=Z:${msys2-env}/clang64/bin
2023-04-24 16:25:50 +08:00
exec ${pkgs.wineWowPackages.stable}/bin/wine64 cmd
'';
2022-10-24 18:06:21 +08:00
wine-msys2-build = pkgs.writeShellScriptBin "wine-msys2-build"
''
export HOME=`mktemp -d`
export WINEDEBUG=-all
export WINEPATH=Z:${msys2-env}/clang64/bin
2022-10-24 18:06:21 +08:00
${silenceFontconfig}
exec ${pkgs.wineWowPackages.stable}/bin/wine64 $@
'';
in {
2023-04-24 16:25:50 +08:00
inherit wine-msys2;
2022-12-28 18:57:22 +08:00
makeMsys2Package = { name, version, src, depends, prepare ? "" }: pkgs.stdenvNoCC.mkDerivation {
2022-10-24 18:06:21 +08:00
pname = "${name}-msys2-pkg";
inherit version;
nativeBuildInputs = [
pkgs.pacman pkgs.fakeroot pkgs.libarchive pkgs.zstd pkgs.file
wine-msys2-build
];
inherit src;
phases = [ "buildPhase" "installPhase" ];
buildPhase =
''
export DRV_VERSION=${version}
${prepare}
2022-10-24 19:18:06 +08:00
cat > PKGBUILD << HEREDOC
pkgbase="mingw-w64-clang-${name}"
pkgname="mingw-w64-clang-x86_64-${name}"
2022-10-24 19:18:06 +08:00
pkgrel=1
depends=(
${pkgs.lib.concatStringsSep "\n" (map (depend: "\"${depend}\"") depends)}
)
source PKGBUILD.common
HEREDOC
2022-10-24 18:06:21 +08:00
ln -s ${./PKGBUILD.common} PKGBUILD.common
ln -s $src source
tar cfh source.tar source
rm source
makepkg --config ${./makepkg.conf} --nodeps
'';
installPhase =
''
mkdir $out $out/nix-support
cp *.pkg.tar.zst $out
echo file msys2 $out/*.pkg.tar.zst >> $out/nix-support/hydra-build-products
'';
};
makeMsys2Repos = constituents: pkgs.stdenvNoCC.mkDerivation {
name = "msys2-repos";
nativeBuildInputs = [ pkgs.pacman ];
phases = [ "buildPhase" ];
buildPhase =
''
mkdir $out
cd $out
${pkgs.lib.concatStringsSep "\n"
(map (constituent: "ln -s ${constituent}/*.pkg.tar.zst .") constituents)}
repo-add artiq.db.tar.gz *.pkg.tar.zst
'';
};
}