summary refs log tree commit diff
path: root/pkgs/build-support/libredirect/default.nix
blob: 0c24dbeb2070fffd8366baeabc942223a489a56b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ stdenv }:

stdenv.mkDerivation {
  name = "libredirect-0";

  unpackPhase = "cp ${./libredirect.c} libredirect.c";

  buildPhase = ''
    $CC -Wall -std=c99 -O3 -shared libredirect.c -o libredirect.so -fPIC -ldl
  '';

  installPhase = "mkdir -p $out/lib; cp libredirect.so $out/lib";

  meta = {
    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
    description = "An LD_PRELOAD library to intercept and rewrite the paths in glibc calls";
    longDescription = ''
      libredirect is an LD_PRELOAD library to intercept and rewrite the paths in
      glibc calls based on the value of $NIX_REDIRECTS, a colon-separated list
      of path prefixes to be rewritten, e.g. "/src=/dst:/usr/=/nix/store/".
    '';
  };
}