depot/third_party/nixpkgs/pkgs/os-specific/linux/nix-ld/default.nix
Default email 8a45d4525b Project import generated by Copybara.
GitOrigin-RevId: 710fed5a2483f945b14f4a58af2cd3676b42d8c8
2022-03-30 11:31:56 +02:00

49 lines
1.3 KiB
Nix

{ stdenv, meson, ninja, lib, nixosTests, fetchFromGitHub }:
let
self = stdenv.mkDerivation {
name = "nix-ld";
src = fetchFromGitHub {
owner = "Mic92";
repo = "nix-ld";
rev = "1.0.0";
sha256 = "sha256-QYPg8wPpq7q5Xd1jW17Lh36iKFSsVkN/gWYoQRv2XoU=";
};
doCheck = true;
nativeBuildInputs = [ meson ninja ];
mesonFlags = [
"-Dnix-system=${stdenv.system}"
];
hardeningDisable = [
"stackprotector"
];
postInstall = ''
mkdir -p $out/nix-support
basename $(< ${stdenv.cc}/nix-support/dynamic-linker) > $out/nix-support/ld-name
'';
passthru.tests.nix-ld = nixosTests.nix-ld;
passthru.ldPath = let
libDir = if stdenv.system == "x86_64-linux" ||
stdenv.system == "mips64-linux" ||
stdenv.system == "powerpc64le-linux"
then
"/lib64"
else
"/lib";
ldName = lib.fileContents "${self}/nix-support/ld-name";
in "${libDir}/${ldName}";
meta = with lib; {
description = "Run unpatched dynamic binaries on NixOS";
homepage = "https://github.com/Mic92/nix-ld";
license = licenses.mit;
maintainers = with maintainers; [ mic92 ];
platforms = platforms.linux;
};
};
in self