Commit 4049a147 authored by Emily Trau's avatar Emily Trau Committed by dish
Browse files

minimal-bootstrap.patchelf-static: init at 0.18.0

parent eb620641
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -298,6 +298,12 @@ lib.makeScope
        gnumake = gnumake-musl;
      };

      patchelf-static = callPackage ./patchelf/static.nix {
        gcc = gcc-latest;
        gnumake = gnumake-musl;
        gnutar = gnutar-latest;
      };

      python = callPackage ./python {
        gcc = gcc-latest;
        gnumake = gnumake-musl;
@@ -395,6 +401,7 @@ lib.makeScope
        echo ${heirloom.tests.get-version}
        echo ${mes.compiler.tests.get-version}
        echo ${musl.tests.hello-world}
        echo ${patchelf-static.tests.get-version}
        echo ${python.tests.get-version}
        echo ${tinycc-mes.compiler.tests.chain}
        echo ${tinycc-musl.compiler.tests.hello-world}
+79 −0
Original line number Diff line number Diff line
{
  lib,
  buildPlatform,
  hostPlatform,
  fetchurl,
  bash,
  gcc,
  musl,
  binutils,
  gnumake,
  gnused,
  gnugrep,
  gawk,
  diffutils,
  findutils,
  gnutar,
  gzip,
}:
let
  pname = "patchelf-static";
  version = "0.18.0";

  src = fetchurl {
    url = "https://github.com/NixOS/patchelf/releases/download/${version}/patchelf-${version}.tar.gz";
    sha256 = "sha256-ZN4Q5Ma4uDedt+h/WAMPM26nR8BRXzgRMugQ2/hKhuc=";
  };
in
bash.runCommand "${pname}-${version}"
  {
    inherit pname version;

    nativeBuildInputs = [
      gcc
      musl
      binutils
      gnumake
      gnused
      gnugrep
      gawk
      diffutils
      findutils
      gnutar
      gzip
    ];

    passthru.tests.get-version =
      result:
      bash.runCommand "${pname}-get-version-${version}" { } ''
        ${result}/bin/patchelf --version
        mkdir $out
      '';

    meta = {
      description = "A small utility to modify the dynamic linker and RPATH of ELF executables";
      homepage = "https://github.com/NixOS/patchelf";
      license = lib.licenses.gpl3Plus;
      platforms = lib.platforms.unix;
      teams = [ lib.teams.minimal-bootstrap ];
    };
  }
  ''
    # Unpack
    tar xf ${src}
    cd patchelf-${version}

    # Configure
    bash ./configure \
      --prefix=$out \
      --build=${buildPlatform.config} \
      --host=${hostPlatform.config} \
      CC=musl-gcc \
      CXXFLAGS=-static

    # Build
    make -j $NIX_BUILD_CORES

    # Install
    make -j $NIX_BUILD_CORES install-strip
  ''