summaryrefslogtreecommitdiff
path: root/overlays/libdscp/default.nix
blob: 9e82f20ec3faa38097d65f0a72f161720c140625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{ final, prev, ... }:
{
  libdscp = prev.stdenv.mkDerivation {
    pname = "libdscp";
    version = "0.0.0";

    src = ./src;

    makeFlags = [ "PREFIX=$(out)" ];
  };

  dscp = prev.writeShellApplication {
    name = "dscp";

    text = ''
      export LD_PRELOAD
      LD_PRELOAD=''${LD_PRELOAD:+':'$LD_PRELOAD':'}
      if [[ $LD_PRELOAD != *':'''${final.libdscp}/lib/libdscp.so''':'* ]]; then
          LD_PRELOAD='${final.libdscp}/lib/libdscp.so'$LD_PRELOAD
      fi
      LD_PRELOAD=''${LD_PRELOAD#':'}
      LD_PRELOAD=''${LD_PRELOAD%':'}

      : "''${DSCP:=0}"

      exec -- "$@"
    '';
  };
}