nix-ld: 1.0.0 -> 1.0.2

This commit is contained in:
Jörg Thalheim 2022-05-14 17:02:37 +02:00
parent 267e232035
commit d5099630b1
No known key found for this signature in database
3 changed files with 55 additions and 50 deletions

View file

@ -5,8 +5,6 @@
programs.nix-ld.enable = lib.mkEnableOption ''nix-ld, Documentation: <link xlink:href="https://github.com/Mic92/nix-ld"/>'';
};
config = lib.mkIf config.programs.nix-ld.enable {
systemd.tmpfiles.rules = [
"L+ ${pkgs.nix-ld.ldPath} - - - - ${pkgs.nix-ld}/libexec/nix-ld"
];
systemd.tmpfiles.packages = [ pkgs.nix-ld ];
};
}

View file

@ -6,7 +6,7 @@ import ./make-test-python.nix ({ lib, pkgs, ...} :
environment.systemPackages = [
(pkgs.runCommand "patched-hello" {} ''
install -D -m755 ${pkgs.hello}/bin/hello $out/bin/hello
patchelf $out/bin/hello --set-interpreter ${pkgs.nix-ld.ldPath}
patchelf $out/bin/hello --set-interpreter $(cat ${pkgs.nix-ld}/nix-support/ldpath)
'')
];
};

View file

@ -1,49 +1,56 @@
{ stdenv, meson, ninja, lib, nixosTests, fetchFromGitHub }:
{ lib
, stdenv
, fetchFromGitHub
, meson
, ninja
, nixosTests
}:
let
self = stdenv.mkDerivation {
name = "nix-ld";
src = fetchFromGitHub {
owner = "Mic92";
repo = "nix-ld";
rev = "1.0.0";
sha256 = "sha256-QYPg8wPpq7q5Xd1jW17Lh36iKFSsVkN/gWYoQRv2XoU=";
};
libDir = if builtins.elem stdenv.system [ "x86_64-linux" "mips64-linux" "powerpc64le-linux" ]
then "/lib64"
else "/lib";
in
stdenv.mkDerivation rec {
pname = "nix-ld";
version = "1.0.2";
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;
};
src = fetchFromGitHub {
owner = "mic92";
repo = "nix-ld";
rev = version;
sha256 = "sha256-DlWU5i/MykqWgB9vstYbECy3e+XagXWCxi+XDJNey0s=";
};
in self
doCheck = true;
nativeBuildInputs = [ meson ninja ];
mesonFlags = [
"-Dnix-system=${stdenv.system}"
];
hardeningDisable = [
"stackprotector"
];
postInstall = ''
mkdir -p $out/nix-support
ldpath=${libDir}/$(basename $(< ${stdenv.cc}/nix-support/dynamic-linker))
echo "$ldpath" > $out/nix-support/ldpath
mkdir -p $out/lib/tmpfiles.d/
cat > $out/lib/tmpfiles.d/nix-ld.conf <<EOF
L+ $ldpath - - - - $out/libexec/nix-ld
EOF
'';
passthru.tests.nix-ld = nixosTests.nix-ld;
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.unix;
};
}