summaryrefslogtreecommitdiff
path: root/overlays/libdscp/default.nix
blob: 46b622e9475625f07afd907b445606d9f819ec15 (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
30
31
{ final, prev, ... }:
{
  libdscp = prev.stdenvNoCC.mkDerivation {
    pname = "libdscp";
    version = "0.0.0";

    src = ./src;

    nativeBuildInputs = with final; [ gcc musl.dev ];

    makeFlags = [ "PREFIX=$(out)" "CC=musl-gcc" ];
  };

  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 -- "$@"
    '';
  };
}