nix-ld: init at 1.0.0 + nixos module
This commit is contained in:
parent
9c0dd18492
commit
a98ea7e6f8
|
@ -181,6 +181,7 @@
|
||||||
./programs/mtr.nix
|
./programs/mtr.nix
|
||||||
./programs/nano.nix
|
./programs/nano.nix
|
||||||
./programs/nbd.nix
|
./programs/nbd.nix
|
||||||
|
./programs/nix-ld.nix
|
||||||
./programs/neovim.nix
|
./programs/neovim.nix
|
||||||
./programs/nm-applet.nix
|
./programs/nm-applet.nix
|
||||||
./programs/npm.nix
|
./programs/npm.nix
|
||||||
|
|
12
nixos/modules/programs/nix-ld.nix
Normal file
12
nixos/modules/programs/nix-ld.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ pkgs, lib, config, ... }:
|
||||||
|
{
|
||||||
|
meta.maintainers = [ lib.maintainers.mic92 ];
|
||||||
|
options = {
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -355,6 +355,7 @@ in
|
||||||
nginx-sso = handleTest ./nginx-sso.nix {};
|
nginx-sso = handleTest ./nginx-sso.nix {};
|
||||||
nginx-variants = handleTest ./nginx-variants.nix {};
|
nginx-variants = handleTest ./nginx-variants.nix {};
|
||||||
nitter = handleTest ./nitter.nix {};
|
nitter = handleTest ./nitter.nix {};
|
||||||
|
nix-ld = handleTest ./nix-ld {};
|
||||||
nix-serve = handleTest ./nix-serve.nix {};
|
nix-serve = handleTest ./nix-serve.nix {};
|
||||||
nix-serve-ssh = handleTest ./nix-serve-ssh.nix {};
|
nix-serve-ssh = handleTest ./nix-serve-ssh.nix {};
|
||||||
nixops = handleTest ./nixops/default.nix {};
|
nixops = handleTest ./nixops/default.nix {};
|
||||||
|
|
20
nixos/tests/nix-ld.nix
Normal file
20
nixos/tests/nix-ld.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import ./make-test-python.nix ({ lib, pkgs, ...} :
|
||||||
|
{
|
||||||
|
name = "nix-ld";
|
||||||
|
nodes.machine = { pkgs, ... }: {
|
||||||
|
programs.nix-ld.enable = true;
|
||||||
|
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}
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
path = "${pkgs.stdenv.cc}/nix-support/dynamic-linker"
|
||||||
|
with open(path) as f:
|
||||||
|
real_ld = f.read().strip()
|
||||||
|
machine.succeed(f"NIX_LD={real_ld} hello")
|
||||||
|
'';
|
||||||
|
})
|
49
pkgs/os-specific/linux/nix-ld/default.nix
Normal file
49
pkgs/os-specific/linux/nix-ld/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ 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
|
|
@ -27767,6 +27767,8 @@ with pkgs;
|
||||||
|
|
||||||
nixos-shell = callPackage ../tools/virtualization/nixos-shell {};
|
nixos-shell = callPackage ../tools/virtualization/nixos-shell {};
|
||||||
|
|
||||||
|
nix-ld = callPackage ../os-specific/linux/nix-ld {};
|
||||||
|
|
||||||
noaa-apt = callPackage ../applications/radio/noaa-apt { };
|
noaa-apt = callPackage ../applications/radio/noaa-apt { };
|
||||||
|
|
||||||
node-problem-detector = callPackage ../applications/networking/cluster/node-problem-detector { };
|
node-problem-detector = callPackage ../applications/networking/cluster/node-problem-detector { };
|
||||||
|
|
Loading…
Reference in a new issue