diff --git a/nixos/modules/programs/nix-ld.nix b/nixos/modules/programs/nix-ld.nix
index 810a74ab50b7..89779cfef390 100644
--- a/nixos/modules/programs/nix-ld.nix
+++ b/nixos/modules/programs/nix-ld.nix
@@ -5,8 +5,6 @@
programs.nix-ld.enable = lib.mkEnableOption ''nix-ld, Documentation: '';
};
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 ];
};
}
diff --git a/nixos/tests/nix-ld.nix b/nixos/tests/nix-ld.nix
index 5c886182d969..ae5297ab87ea 100644
--- a/nixos/tests/nix-ld.nix
+++ b/nixos/tests/nix-ld.nix
@@ -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)
'')
];
};
diff --git a/pkgs/os-specific/linux/nix-ld/default.nix b/pkgs/os-specific/linux/nix-ld/default.nix
index dcab99cabfe4..9fcec3c5a133 100644
--- a/pkgs/os-specific/linux/nix-ld/default.nix
+++ b/pkgs/os-specific/linux/nix-ld/default.nix
@@ -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 <