forked from msys2/msys2-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
92 lines (84 loc) · 3.49 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
description = "ARTIQ offline installer";
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11;
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
msys2-image = pkgs.stdenvNoCC.mkDerivation rec {
name = "msys2-image";
artiq-pkgs = import ./msys2_artiq_packages.nix { inherit pkgs; };
msys2-base = pkgs.fetchurl {
url = "https://github.com/msys2/msys2-installer/releases/download/2024-01-13/msys2-base-x86_64-20240113.tar.xz";
name = "base";
sha256 = "sha256-BEVqRKlW08C1+bbHVJGL86jD2HyFi+egyUyRcasTxYw=";
};
src = ./.;
buildInputs = [ pkgs.gnutar pkgs.zstd pkgs.pacman pkgs.fakeroot ];
phases = [ "installPhase" ];
installPhase = ''
mkdir $out
mkdir -p tmp/cache
tar -xvf ${msys2-base} --strip-components=1 -C $out/ msys64
printf "\n[artiq]\nSigLevel = Optional TrustAll\nServer = https://msys2.m-labs.hk/artiq-beta\n" >> $out/etc/pacman.conf
cat $src/pacman.conf | sed -e "s|/etc/pacman.d|$out/etc/pacman.d|g" -e "s|SigLevel = Required|SigLevel = Never|g" > tmp/pacman.conf
fakeroot pacman -Udd --noconfirm --cachedir tmp/cache --config tmp/pacman.conf --root $out ${pkgs.lib.concatStringsSep " " (map (p: "${p}") artiq-pkgs)}
'';
};
msys2-qt-ifw = pkgs.stdenvNoCC.mkDerivation rec {
name = "msys2-qt-ifw";
srcs = import ./msys2_qt_ifw_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)));
};
buildMsys2Installer = pkgs.stdenv.mkDerivation {
name = "msys2-installer";
buildInputs = with pkgs; [ curl pacman fakeroot p7zip wine64 ];
src = ./.;
phases = [ "buildPhase" "installPhase" ];
buildPhase = ''
export HOME=`mktemp -d`
cp $src/make-msys2-installer make-msys2-installer
cp -r $src/qt-ifw qt-ifw
chmod -R 700 qt-ifw
find qt-ifw \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|@DATE@|$(date +'%Y-%m-%d')|g" "{}" \;
find qt-ifw \( -name "package.xml" -or -name "config.xml" \) -exec sed -i "s|@VERSION@|$(date +'%Y%m%d')|g" "{}" \;
7z a -mx9 -md128m "qt-ifw/packages/com.msys2.root/data/msys64.7z" "${msys2-image}/"*
${pkgs.wineWowPackages.stable}/bin/wine64 ${msys2-qt-ifw}/mingw64/bin/binarycreator.exe \
-t "${msys2-qt-ifw}/mingw64/bin/installerbase.exe" \
-p "qt-ifw/packages" \
-c "qt-ifw/config/config.xml" \
--offline-only \
"msys2-x86_64.exe" \
-v
'';
installPhase = ''
mkdir -p $out
cp msys2-x86_64.exe $out/
mkdir -p $out/nix-support/
for i in $out/*.*; do
echo file binary-dist $i >> $out/nix-support/hydra-build-products
done
'';
};
in
{
inherit nixpkgs;
devShell.${system} = with pkgs; mkShell {
name = "dev-shell-msys2";
buildInputs = with pkgs; [
curl
pacman
fakeroot
p7zip
wine64
];
};
hydraJobs = {
msys2Installer = buildMsys2Installer;
};
};
}