diff --git a/pkgs/os-specific/linux/criu/default.nix b/pkgs/os-specific/linux/criu/default.nix index 5475a565b09b..71bde6220a02 100644 --- a/pkgs/os-specific/linux/criu/default.nix +++ b/pkgs/os-specific/linux/criu/default.nix @@ -1,6 +1,8 @@ { stdenv, lib, fetchFromGitHub, fetchpatch, protobuf, protobufc, asciidoc, iptables , xmlto, docbook_xsl, libpaper, libnl, libcap, libnet, pkg-config, iproute2 -, which, python3, makeWrapper, docbook_xml_dtd_45, perl, nftables, libbsd }: +, which, python3, makeWrapper, docbook_xml_dtd_45, perl, nftables, libbsd +, buildPackages +}: stdenv.mkDerivation rec { pname = "criu"; @@ -22,9 +24,34 @@ stdenv.mkDerivation rec { ]; enableParallelBuilding = true; - nativeBuildInputs = [ pkg-config docbook_xsl which makeWrapper docbook_xml_dtd_45 python3 python3.pkgs.wrapPython perl ]; - buildInputs = [ protobuf asciidoc xmlto libpaper libnl libcap libnet nftables libbsd ]; - propagatedBuildInputs = [ protobufc ] ++ (with python3.pkgs; [ python python3.pkgs.protobuf ]); + depsBuildBuild = [ protobufc buildPackages.stdenv.cc ]; + nativeBuildInputs = [ + pkg-config + asciidoc + xmlto + libpaper + docbook_xsl + which + makeWrapper + docbook_xml_dtd_45 + python3 + python3.pkgs.wrapPython + perl + ]; + buildInputs = [ + protobuf + libnl + libcap + libnet + nftables + libbsd + ]; + propagatedBuildInputs = [ + protobufc + ] ++ (with python3.pkgs; [ + python + python3.pkgs.protobuf + ]); postPatch = '' substituteInPlace ./Documentation/Makefile \ @@ -34,7 +61,27 @@ stdenv.mkDerivation rec { ln -sf ${protobuf}/include/google/protobuf/descriptor.proto ./images/google/protobuf/descriptor.proto ''; - makeFlags = [ "PREFIX=$(out)" "ASCIIDOC=${asciidoc}/bin/asciidoc" "XMLTO=${xmlto}/bin/xmlto" ]; + makeFlags = let + # criu's Makefile infrastructure expects to be passed a target architecture + # which neither matches the config-tuple's first part, nor the + # targetPlatform.linuxArch attribute. Thus we take the latter and map it + # onto the expected string: + linuxArchMapping = { + "x86_64" = "x86"; + "arm" = "arm"; + "arm64" = "aarch64"; + "powerpc" = "ppc64"; + "s390" = "s390"; + "mips" = "mips"; + }; + in [ + "PREFIX=$(out)" + "ASCIIDOC=${buildPackages.asciidoc}/bin/asciidoc" + "XMLTO=${buildPackages.xmlto}/bin/xmlto" + ] ++ (lib.optionals (stdenv.buildPlatform != stdenv.targetPlatform) [ + "ARCH=${linuxArchMapping."${stdenv.targetPlatform.linuxArch}"}" + "CROSS_COMPILE=${stdenv.targetPlatform.config}-" + ]); outputs = [ "out" "dev" "man" ]; @@ -58,7 +105,7 @@ stdenv.mkDerivation rec { description = "Userspace checkpoint/restore for Linux"; homepage = "https://criu.org"; license = licenses.gpl2; - platforms = [ "x86_64-linux" "aarch64-linux" ]; + platforms = [ "x86_64-linux" "aarch64-linux" "armv7l-linux" ]; maintainers = [ maintainers.thoughtpolice ]; }; }