diff --git a/flake.nix b/flake.nix index 00f6a1464..9574993b1 100644 --- a/flake.nix +++ b/flake.nix @@ -78,6 +78,7 @@ "--extra-lib-dirs=${stripDylib (ncurses-static)}/lib" ] ++ (if stdenv.hostPlatform.isDarwin then [ "--extra-lib-dirs=${stripDylib (libiconv.override { enableStatic = true; })}/lib" + "--extra-lib-dirs=${stripDylib (libcxxabi)}/lib" ] else []))) (haskell.lib.compose.enableCabalFlag "static") ]; @@ -97,22 +98,28 @@ in if pkgs.stdenv.isLinux then pkgs.runCommand "echidna-stripNixRefs" {} '' mkdir -p $out/bin - cp ${pkgs.haskell.lib.dontCheck echidna-static}/bin/echidna $out/bin/ + cp ${pkgsStatic.haskell.lib.dontCheck echidna-static}/bin/echidna $out/bin/ # fix TERMINFO path in ncurses ${perl} -i -pe 's#(${ncurses-static}/share/terminfo)#"/usr/share/terminfo" . "\x0" x (length($1) - 19)#e' $out/bin/echidna chmod 555 $out/bin/echidna '' else pkgs.runCommand "echidna-stripNixRefs" {} '' mkdir -p $out/bin - cp ${pkgs.haskell.lib.dontCheck echidna-static}/bin/echidna $out/bin/ + cp ${pkgsStatic.haskell.lib.dontCheck echidna-static}/bin/echidna $out/bin/ # get the list of dynamic libs from otool and tidy the output libs=$(${otool} -L $out/bin/echidna | tail -n +2 | sed 's/^[[:space:]]*//' | cut -d' ' -f1) # get the path for libcxx - cxx=$(echo "$libs" | ${grep} '^/nix/store/.*-libcxx') + cxx=$(echo "$libs" | ${grep} '^/nix/store/.*-libcxx-') # rewrite /nix/... library paths to point to /usr/lib chmod 777 $out/bin/echidna ${install_name_tool} -change "$cxx" /usr/lib/libc++.1.dylib $out/bin/echidna # fix TERMINFO path in ncurses ${perl} -i -pe 's#(${ncurses-static}/share/terminfo)#"/usr/share/terminfo" . "\x0" x (length($1) - 19)#e' $out/bin/echidna + # check that no nix deps remain + nixdeps=$(${otool} -L $out/bin/echidna | tail -n +2 | { ${grep} /nix/store -c || test $? = 1; }) + if [ ! "$nixdeps" = "0" ]; then + echo "Nix deps remain in redistributable binary!" + exit 255 + fi # re-sign binary CODESIGN_ALLOCATE=${codesign_allocate} ${codesign} -f -s - $out/bin/echidna chmod 555 $out/bin/echidna