Created
February 21, 2018 10:50
-
-
Save nico202/fde4a42f0852fc6bfaf37507a3d305aa to your computer and use it in GitHub Desktop.
julia packages -> nixpkgs
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
wd='julia-nix-workdir' | |
mkdir -p $wd | |
cd $wd | |
git clone --depth=1 [email protected]:JuliaLang/METADATA.jl.git | |
while read url; do | |
git clone --depth=1 $url | |
done < $(find ./METADATA.jl/ -name url -exec cat '{}' \; -exec echo \; |sort -u) |
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
# https://stackoverflow.com/questions/46364922/how-to-parse-multiline-string-in-julia | |
function parseall(str) | |
pos = start(str) | |
exs = [] | |
while !done(str, pos) | |
ex, pos = parse(str, pos) # returns next starting point as well as expr | |
ex.head == :toplevel ? append!(exs, ex.args) : push!(exs, ex) #see comments for info | |
end | |
if length(exs) == 0 | |
throw(ParseError("end of input")) | |
elseif length(exs) == 1 | |
return exs[1] | |
else | |
return Expr(:block, exs...) # convert the array of expressions | |
# back to a single expression | |
end | |
end | |
# Meta.show_sexpr(expr) | |
parseallfile(file) = parseall(readstring(file)) | |
findfunc(any, func::Symbol) = false | |
function findfunc(s::Symbol, func::Symbol) | |
if s == func | |
return true | |
end | |
false | |
end | |
function findfunc(expr::Expr, func::Symbol) | |
for exp in expr.args | |
if findfunc(exp, func) | |
println(expr.args[2]) # better to get aliases | |
end | |
end | |
false | |
end |
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
#example: parse_build.sh "/tmp/julia-nix-workdir/Gtk.jl/deps/build.jl" | |
julia -e "include(\"/tmp/parseall.jl\"); findfunc(parseallfile(\"$1\"),:library_dependency)" | |
#example result: | |
# glib gobject gtk gdk gdk_pixbuf gio | |
# This can be passed to `nix-locate` or something |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment