summary refs log tree commit diff
path: root/pkgs/development/compilers/elm/packages/patch-binwrap.nix
blob: 30f54e6f5ac5a66cdc358378aa38d5d5bf17514f (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
24
25
26
27
28
29
30
{ writeScriptBin, stdenv, lib }:
let
  # Patching binwrap by NoOp script
  binwrap = writeScriptBin "binwrap" ''
    #! ${stdenv.shell}
    echo "binwrap called: Returning 0"
    return 0
  '';
  binwrap-install = writeScriptBin "binwrap-install" ''
    #! ${stdenv.shell}
    echo "binwrap-install called: Doing nothing"
  '';
in
targets:
pkg:
pkg.override {
  nativeBuildInputs = pkg.nativeBuildInputs ++ [ binwrap binwrap-install ];

  # Manually install targets
  # by symlinking binaries into `node_modules`
  postInstall = let
    binFile = module: lib.strings.removeSuffix ("-" + module.version) module.name;
  in ''
    ${lib.concatStrings (map (module: ''
        echo "linking ${binFile module}"
        ln -sf ${module}/bin/${binFile module} \
            node_modules/${binFile module}/bin/${binFile module}
    '') targets)}
  '';
}