From e21e7c85b7637e622f21c57675bf1154fc8b1866 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 24 Apr 2024 10:19:57 +0200 Subject: [PATCH] Build s390x binaries using musl libc Building using musl until NixOS/nixpkgs#306473 is resolved. Refers to cri-o/cri-o#7911 Signed-off-by: Sascha Grunert --- nix/default-s390x.nix | 5 ++++- nix/derivation.nix | 15 +++++++-------- nix/nixpkgs.json | 10 +++++----- nix/overlay.nix | 19 ------------------- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/nix/default-s390x.nix b/nix/default-s390x.nix index dc80f086..3be20a05 100644 --- a/nix/default-s390x.nix +++ b/nix/default-s390x.nix @@ -1,6 +1,9 @@ (import ./nixpkgs.nix { crossSystem = { - config = "s390x-unknown-linux-gnu"; + # TODO: Switch back to glibc when + # https://github.com/NixOS/nixpkgs/issues/306473 + # is resolved. + config = "s390x-unknown-linux-musl"; }; overlays = [ (import ./overlay.nix) ]; }).callPackage ./derivation.nix diff --git a/nix/derivation.nix b/nix/derivation.nix index c857e711..5362f990 100644 --- a/nix/derivation.nix +++ b/nix/derivation.nix @@ -1,23 +1,22 @@ -{ pkgs }: +{ stdenv +, pkgs +}: with pkgs; stdenv.mkDerivation rec { name = "conmon"; src = ./..; - vendorSha256 = null; + vendorHash = null; doCheck = false; enableParallelBuilding = true; outputs = [ "out" ]; nativeBuildInputs = with buildPackages; [ - bash gitMinimal pkg-config - which ]; - buildInputs = [ - glib - glibc + buildInputs = lib.optionals (!stdenv.hostPlatform.isMusl) [ glibc.static + ] ++ [ + pkgsStatic.glib libseccomp - pcre2 ]; prePatch = '' export CFLAGS='-static -pthread' diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json index 93b5f999..c7ae2277 100644 --- a/nix/nixpkgs.json +++ b/nix/nixpkgs.json @@ -1,10 +1,10 @@ { "url": "https://github.com/nixos/nixpkgs", - "rev": "f4f097b65b336b1f4cdf947b7fbe076bd2a69126", - "date": "2024-02-28T11:07:01+01:00", - "path": "/nix/store/4blmmjaibdghqzk1wa8la3w9afvyldpq-nixpkgs", - "sha256": "0r1kbfbh3rbpl4w7rvyxyl3q6nchnmmd6bjwsqbz0gbsrsly7vbg", - "hash": "sha256-b+3jqc56PfAX1lwu02q1kFmDB/Xd73w4oXflAZdbM2Q=", + "rev": "17d58b30575bb965966d67e8ca1070f9a71cfb41", + "date": "2024-04-25T11:03:10+03:00", + "path": "/nix/store/01ql69ya47924icr0sm5vclrcl98ryr2-nixpkgs", + "sha256": "1szc653551qmd1iqk6lqcnamsr7bdd5qrfimi4r1ma199cblpd14", + "hash": "sha256-JLRLF0spqBoyiTW6jEtr62RdlWWYmoljaBWHUkYx7Os=", "fetchLFS": false, "fetchSubmodules": false, "deepClone": false, diff --git a/nix/overlay.nix b/nix/overlay.nix index 71349b72..212e0679 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -4,23 +4,4 @@ self: super: doCheck = false; dontDisableStatic = true; }); - pcre2 = super.pcre2.overrideAttrs (x: { - configureFlags = x.configureFlags ++ [ "--enable-static" ]; - }); - glib = super.glib.overrideAttrs (x: { - outputs = [ "bin" "out" "dev" ]; - mesonFlags = [ - "-Ddefault_library=static" - "-Ddevbindir=${placeholder ''dev''}/bin" - "-Dgtk_doc=false" - "-Dnls=disabled" - ]; - postInstall = '' - moveToOutput "share/glib-2.0" "$dev" - substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev" - sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|" - sed '1i#line 1 "${x.pname}-${x.version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \ - -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c - ''; - }); }