Last active
June 26, 2022 13:08
-
-
Save risicle/b51e58f77e9ef2a78e4eda5dc778813e to your computer and use it in GitHub Desktop.
src-inspector.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib, stdenv, unzip, toInspect }: | |
builtins.mapAttrs ( | |
name: value: let | |
res = builtins.tryEval value.src or null; | |
in if (builtins.match "" name) != null && res.success && res.value != null then (stdenv.mkDerivation { | |
inherit name; | |
src = res.value; | |
sourceRoot = "."; | |
preUnpack = '' | |
if [ "''${src: -4:4}" = '.whl' ] ; then | |
oldSrc="$src" | |
src="$(mktemp -d)/src.zip" | |
ln -s "$oldSrc" "$src" | |
fi | |
''; | |
nativeBuildInputs = [ unzip ]; | |
dontPatch = true; | |
dontConfigure = true; | |
dontBuild = true; | |
dontFixup = true; | |
installPhase = '' | |
find . \ | |
-type f \ | |
-size +0c \ | |
'(' \ | |
-name '*.jar' \ | |
-o \ | |
-exec sed -e '1b p ; Q1 ; :p ; /^\x7fELF/Q0 ; /^[\xce\xcf]\xfa\xed\xfe/Q0 ; /^MZ/Q0 ; Q1' '{}' ';' | |
')' \ | |
-print > $out || true | |
''; | |
}) else null | |
) toInspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment