Fork me on GitHub
#babashka
<
2021-03-09
>
borkdude08:03:24

babashka v0.2.13: minor bugfix/enhancement release https://github.com/babashka/babashka/blob/master/CHANGELOG.md#v0213 Thanks @dstephens, @wilkerlucio, @kiraemclean, @tekacs and @eamonn.sullivan for contributing!

🎉 18
Eamonn Sullivan09:03:02

Here's a question: The (probably overly elaborate) https://github.com/eamonnsullivan/backup-scripts I wrote in babashka is working well, and I was thinking I would like to move it to some dedicated hardware. I was thinking of using a Raspberry Pi 4 with a couple of USB SSD disks attached, but am I right in thinking that babashka doesn't yet support that ARM processor? What would be a work-around? I should be able to compile the script into a normal uberjar, right?

Eamonn Sullivan09:03:45

Ah, so it looks like progress, but I should probably wait. Presumably I could just add a deps.edn to my project, specifying the dependencies in the usual way and compile it to a jar, right? The Raspberry supports running jars, as far as I know.

borkdude09:03:24

Yes, that is certainly possible. But as you can see in that thread, someone already made some ARM binaries available.

borkdude09:03:02

And you can possibly compile it yourself on ARM if you need a more updated one. How many GB of memory do you have on ARM?

Eamonn Sullivan09:03:36

I'm looking at the P4 with 8GB of RAM. Or, rather, I'm going to ask my kids for one for my birthday...

borkdude09:03:09

Yeah, 8GB should be ok for compiling bb yourself

Eamonn Sullivan09:03:14

(I have 5 kids, all in their 20s and 30s, so they can afford it...)

borkdude09:03:45

You need the 64bit one

borkdude09:03:59

Compilation takes around 15-20 minutes on a Raspberry

👌 3
Eamonn Sullivan09:03:03

Yes, I'm pretty sure the P4 (and the P3) are 64-bit CPUs.

Eamonn Sullivan09:03:38

So I gather cross-compiling isn't a thing...

borkdude09:03:51

4GB of memory is probably just a bit too low, so make sure: 64bit and 8gb, this will work. No, GraalVM doesn't support cross compilation

borkdude09:03:06

Some people also have tried qemu for cross compilation

Eamonn Sullivan09:03:52

:thumbsup: -- Another side project to add to the ever-growing list.

borkdude09:03:22

If there was a CI that exposed linux ARM 64 bit then I would distribute the binary from there

Eamonn Sullivan10:03:13

Yeah, AWS EC2 arm-64 instances exists, so technically something like CircleCI should be able to spin one up. I'll google around. I use CircleCI already on one my libs. It would be something to play with until I have an actual Pi to use.

onetom09:03:56

I remember seeing something like 2 shebang lines used in context of babashka, but i can't recall what was it for or where did i see it. For example, u can create self-contained shell scripts which pull their dependencies from the Nix package manager, if u start your script with a "double shebang", like this:

#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python34Packages.pygobject3 libnotify gobjectIntrospection gdk_pixbuf
I remember there was something similar for babashka:
#!/usr/bin/env bb
#! ... ???

borkdude09:03:53

#!/bin/sh

#_(
   "exec" "bb" "$0" hello "[email protected]"
   )
(prn *command-line-args*)
./script.clj 1 2 3
("hello" "1" "2" "3")

👍 3
Jakub Holý17:03:36

I've asked in #clojure but it is rather bb specific. I want to extract all calls to log/warn from cljc code, using bb (to make a dictionary of possible app errors for users). But edn/read does not handle reader conditionals. Tips? Use it anyway and register custom reader for #? that returns the content as a map {:clj.., :cljs...}? 🙏

borkdude17:03:30

@holyjak You can do this from babashka using https://github.com/babashka/pod-babashka-parcera This will give you the code including the whitespace, you can then select from this code and spit out some data. Other than that, #rewrite-clj is a really good library for this too, but doesn't work with babashka. If you want to do this using s-expressions directly, you can also use https://github.com/borkdude/edamame which accepts a :features option which you can set to #{:cljs} to only get cljs branches

borkdude17:03:48

You might also be able to do it using tools.reader directly

borkdude17:03:40

If you are going with the JVM I would recommend joining #rewrite-clj and use that tool

Jakub Holý17:03:07

Thanks a lot!!!

borkdude17:03:08

I suggested to @lee that we should maybe work on a rewrite-clj command line scripting tool for this purpose, I think that would be really neat

lread17:03:41

Sounds interesting to me! I’m going to try to get rewrite-clj v1 alpha out the door first, getting close!

🎉 3
borkdude17:03:56

@lee If you think that rewrite-clj nodes are serializable, then I think a pod can also work

borkdude17:03:32

can you e.g. store a rewrite-clj AST to a file and then read it back?

lread17:03:45

They aren’t easily yet, but we have an open issue on that.

borkdude17:03:24

I think it will also be a bit painful when it comes to zippers, so a separate scripting tool makes sense, I think

borkdude17:03:55

@holyjak I forgot about https://github.com/borkdude/grasp which is exactly made for this use case: find s-expressions that match a certain shape

❤️ 3
Jakub Holý18:03:01

Is it bb or Clj-only?

borkdude18:03:55

You can use it from the JVM or a standalone binary. I would start with the JVM

borkdude18:03:05

and if you need to run often, you can make a script

👍 3
borkdude18:03:03

it also has a binary

flowthing18:03:59

I had a feeling you had made a tool specifically for this purpose, but also couldn't remember it. 🙂 You need to make a new tool that can find a relevant Borkdude tool for your use case.

💯 12
😂 15