Skip to content

Instantly share code, notes, and snippets.

@rprospero
Created September 13, 2021 11:38
Show Gist options
  • Save rprospero/dd8e16bad9f842409c85e63ade31c355 to your computer and use it in GitHub Desktop.
Save rprospero/dd8e16bad9f842409c85e63ade31c355 to your computer and use it in GitHub Desktop.
Terrible Qt6 Derivation
{ version, sha256, patches ? [], patchFlags ? [] }:
let
pkgs = import <nixpkgs> {};
lib = pkgs.lib;
stdenv = pkgs.stdenv;
fetchurl = pkgs.fetchurl;
buildRootOnly = false;
pname = "icu4c";
baseAttrs = {
src = fetchurl {
url = "https://github.com/unicode-org/icu/releases/download/release-${lib.replaceChars [ "." ] [ "-" ] version}/icu4c-${lib.replaceChars [ "." ] [ "_" ] version}-src.tgz";
inherit sha256;
};
postUnpack = ''
sourceRoot=''${sourceRoot}/source
echo Source root reset to ''${sourceRoot}
'';
# https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
postPatch = if (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl") && lib.versionOlder version "62.1"
then "substituteInPlace i18n/digitlst.cpp --replace '<xlocale.h>' '<locale.h>'"
else null; # won't find locale_t on darwin
inherit patchFlags patches;
preConfigure = ''
sed -i -e "s|/bin/sh|${stdenv.shell}|" configure
# $(includedir) is different from $(prefix)/include due to multiple outputs
sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in
'' + lib.optionalString stdenv.isAarch32 ''
# From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch
sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux
'';
configureFlags = [ "--disable-debug" ]
++ lib.optional (stdenv.isFreeBSD || stdenv.isDarwin) "--enable-rpath";
enableParallelBuilding = true;
meta = with lib; {
description = "Unicode and globalization support library";
homepage = "http://site.icu-project.org/";
maintainers = with maintainers; [ raskin ];
platforms = platforms.all;
};
};
realAttrs = baseAttrs // {
name = pname + "-" + version;
outputs = [ "out" "dev" ];
outputBin = "dev";
# remove dependency on bootstrap-tools in early stdenv build
postInstall = lib.optionalString stdenv.isDarwin ''
sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc
'' + (let
replacements = [
{ from = "\${prefix}/include"; to = "${placeholder "dev"}/include"; } # --cppflags-searchpath
{ from = "\${pkglibdir}/Makefile.inc"; to = "${placeholder "dev"}/lib/icu/Makefile.inc"; } # --incfile
{ from = "\${pkglibdir}/pkgdata.inc"; to = "${placeholder "dev"}/lib/icu/pkgdata.inc"; } # --incpkgdatafile
];
in ''
substituteInPlace "$dev/bin/icu-config" \
${lib.concatMapStringsSep " " (r: "--replace '${r.from}' '${r.to}'") replacements}
'');
postFixup = ''moveToOutput lib/icu "$dev" '';
};
buildRootOnlyAttrs = baseAttrs // {
name = pname + "-build-root-" + version;
preConfigure = baseAttrs.preConfigure + ''
mkdir build
cd build
configureScript=../configure
'';
postBuild = ''
cd ..
mv build $out
echo "Doing build-root only, exiting now" >&2
exit 0
'';
};
attrs = if buildRootOnly
then buildRootOnlyAttrs
else realAttrs;
in
stdenv.mkDerivation attrs
{ pkgs ? import <nixpkgs> { } }:
let
aqt = pkgs.python3.pkgs.buildPythonPackage rec {
pname = "aqtinstall";
version = "1.2.4";
src = pkgs.python3.pkgs.fetchPypi {
inherit pname version;
sha256 = "fmaAYOSHrx5LVUoPlIw0p/0jMRVGSPE+teEVlNurz10=";
};
propagatedBuildInputs = [
pkgs.python3.pkgs.setuptools-scm
pkgs.python3.pkgs.texttable
pkgs.python3.pkgs.patch
pkgs.python3.pkgs.requests
semantic_version
pkgs.p7zip
];
pipInstallFlags = [ "--no-deps" ];
doCheck = false;
};
semantic_version = pkgs.python3.pkgs.buildPythonPackage rec {
pname = "semantic_version";
version = "2.8.5";
src = pkgs.python3.pkgs.fetchPypi {
inherit pname version;
sha256 = "0sst4FWHYpNGebmhBOguynr0SMn0l00fPuzP9lHfilQ=";
};
# propagatedBuildInputs =
# [ pkgs.python3.pkgs.setuptools-scm pkgs.python3.pkgs.semantic_verion ];
# pipInstallFlags = [ "--no-deps" ];
doCheck = false;
};
qtbase = pkgs.fetchurl {
url =
"https://mirrors.ukfast.co.uk/sites/qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_611/qt.qt6.611.gcc_64/6.1.1-0-202106031044qtbase-Linux-CentOS_8_3-GCC-Linux-CentOS_8_3-X86_64.7z";
sha256 = "fcE1ShAuAbKPihOG4OILnijM0mgAsa5l8V8V1bOYykM=";
};
qtsvg = pkgs.fetchurl {
url =
"https://mirrors.ukfast.co.uk/sites/qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_611/qt.qt6.611.gcc_64/6.1.1-0-202106031044qtsvg-Linux-CentOS_8_3-GCC-Linux-CentOS_8_3-X86_64.7z";
sha256 = "zO9CAMNN7k5k51V4JcrCZFbAag3sn2gmd0YoYvh+qng=";
};
in pkgs.stdenv.mkDerivation {
name = "qt6";
unpackPhase = ''
${pkgs.p7zip}/bin/7z x ${qtbase} -o$out
${pkgs.p7zip}/bin/7z x ${qtsvg} -o$out
'';
installPhase = ''
mkdir $out/lib
ln -s ${pkgs.libmysqlclient}/lib/mysql/libmysqlclient.so $out/lib/libmysqlclient.so.21
patchelf --set-rpath $out/lib $out/6.1.1/gcc_64/lib/libQt6Core.so.6.1.1
echo No Install
'';
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
autoPatchelfIgnoreMissingDeps = false;
buildInputs = [
pkgs.dbus
pkgs.libxkbcommon
pkgs.stdenv.cc.cc.lib
pkgs.gdk-pixbuf
pkgs.libdrm
(import ./icu.nix {
version = "56.1";
sha256 = "OmTpEFxzTc9jHAs+1gQEUxvObA9aZL/hpkAqTMIxSBY=";
})
pkgs.libgssglue
pkgs.mysql
pkgs.libmysqlclient.dev
pkgs.gtkd
pkgs.cups
pkgs.pango
pkgs.postgresql
pkgs.libGL
pkgs.libglvnd
pkgs.libglvnd.dev
pkgs.xorg.xcbutil
pkgs.xorg.xcbutilwm
pkgs.xorg.xcbutilkeysyms
pkgs.xorg.xcbutilimage
pkgs.xorg.xcbutilrenderutil
pkgs.unixODBC
];
}
@sikmir
Copy link

sikmir commented Sep 13, 2021

It looks like https://mirrors.ukfast.co.uk is not available. I can access it only via Tor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment