Clojurians
#dirac
<
2016-03-10
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

smw05:03:07

Anyone have an example of boot + dirac agent? (as opposed to lein)

darwin10:03:56

I believe @jaen is a boot user

jaen10:03:31

Yeah. @smw, what do you have problems with?

smw22:03:33

@jaen: I’m just looking for a bit of example code that runs the agent integrated with something like boot-cljs-repl?

smw22:03:41

I have something like

(deftask dev-cljs-repl
  "Run a restartable system in the Repl"
  []
  (comp
   (environ :env {:http-port "3300" :dev true})
   (watch :verbose true)
   (system :sys #'dev-system :auto true :files ["handler.clj"])
   (reload :port 55554)
   (cljs-repl :port 55555)
   (cljs)
   (speak)))

smw22:03:07

Dirac documentation suggests that you can’t use piggieback, as Dirac provides the same functionality.

smw22:03:35

boot-cljs-repl has

piggie-repl (partial repl :server true
                             :middleware ['cemerick.piggieback/wrap-cljs-repl])]

smw22:03:02

I guess I need something like boot-dirac-repl that does something similar, as I don’t see a way to override the middleware there.

smw22:03:12

I don’t mind trying to write such a thing, but I was hoping someone might have already done it.

darwin22:03:14

your understanding is correct, you just need to replace piggieback with dirac middleware

darwin22:03:26

unfortunately I don’t have personal experience with boot stack

smw22:03:03

Ok. I’ll try to spin out a boot-dirac-repl… or see if the boot people are ok with a PR adding dirac support. Thanks :simple_smile:

jaen22:03:28

So I don't really have anything more than:

(repl :server true
      :middleware '[dirac.nrepl.middleware/dirac-repl]
      :port 8230)
and
(defn start-dirac! []
  (require 'dirac.agent)
  (let [dirac-boot! (resolve 'dirac.agent/boot!)]
    (dirac-boot!)))
in build boot.

jaen22:03:41

And then I just call start-dirac! when I connect to boot REPL.

jaen22:03:43

And that's it.

smw22:03:32

Oh. Wow, that’s simple.

jaen22:03:36

Remember to remove boot-cljs-repl tho

jaen22:03:41

Otherwise it might clash.

smw22:03:52

If I read the cljs-repl code, it appears it’s doing some slightly complex stuff with weasel… I’m not sure I understand the impact. Do you know if I’m losing functionality by using your incredibly simple version? :simple_smile:

smw22:03:29

I guess not, because that’s part of webtools?

smw22:03:34

err, sorry,

smw22:03:41

I mean ‘part of dirac?'

jaen22:03:53

You loose some, you gain some. But dirac gives you equivalent functionality to boot-cljs-repl.

smw22:03:02

Roger that. Thanks so much for the help.

jaen22:03:02

Just inside the devtools.

jaen22:03:53

And if you don't remove boot-cljs-repl (both the task and related piggibeack/weasel/austin dependencies) you probably won't get dirac to work

jaen22:03:05

At least the deps clashed for me if I didn't remove them all.

jaen22:03:25

Otherwise this should Just Work™

jaen22:03:30

If it won't, let me know.

jaen22:03:21

Of course remember to have something equivalent to:

(defn install-devtools! []
  (devtools/set-pref! :install-sanity-hints true)
  (devtools/enable-feature! :dirac)
  (devtools/install!))
called in your client app.

smw22:03:19

Oh. I have that part, mostly? I don’t think I have enable-feature!...

smw22:03:36

no, I do...

smw22:03:46

missing the set-pref

darwin22:03:51

I think you should be able to run them side-by-side if you make sure that ports don’t clash

smw22:03:53

(devtools/enable-feature! :sanity-hints :dirac)
  (devtools/install!)

smw22:03:01

Is that equivalent?

darwin22:03:07

that’s equivalent

smw22:03:51

I’m so psyched about this. Thanks for this work! This really does seem like the holy grail.

smw22:03:15

(not sure what a holly grail is, but it’s probably too Christmasy)

darwin22:03:48

thanks, still needs more polish

darwin22:03:00

want to jump on it next week again

darwin22:03:53

I need good integration with IntelliJ

smw22:03:00

:simple_smile: Me too!

smw22:03:10

Cursive is so amazing.

darwin22:03:37

so you would connect via Cursive REPL and can let dirac “echo” commands you send into REPL from code editor

darwin22:03:44

you know what I mean?

smw22:03:05

Really wish it were open source, would love to try to add boot support. I’ve spent 3 days playing with boot, and it’s so much simpler than the equivalent lein config.

jaen22:03:17

@darwin: I couldn't get boot-cljs-repl and dirac working together in one project last I tried (quite recently) so not too sure it's possible.

smw22:03:21

It’ll output a project.clj with correct dependencies, etc.

smw22:03:36

So cursive’s lein support will ‘work'

darwin22:03:44

boot is amazing, just don’t have energy to convert my lein setups to boot yet

smw22:03:53

but it’s not quite the same level of elegant integration

jaen22:03:19

Well, just emitting a rudimentary project.clj works well for me.

jaen22:03:54

Except debugging (and it's hard for me to live without debugging), but not sure what's at fault here exactly.

smw22:03:57

Yeah, it’s working for me too. I need to put a watch trigger in intellij that generates the project.clj when build.boot changes.

darwin22:03:58

even project.clj support is not perfect for me, I use lein profiles heavily and clojure does not understand them

darwin22:03:04

I mean Cursive

darwin22:03:45

so maybe generating project.clj is a pretty flexible solution, because now I have to jump through hoops to satisfy both lein and Cursive

smw22:03:47

I tell you though, I’ve been building web ‘applications’ since the perl/cgi days, and between this and devcards, I’m finally starting to think it might actually be something fun.

jaen22:03:01

@smw: in IntelliJ? You can put that in a task like so - https://gist.github.com/jaen/17d555c45f067f080091 - and then just do:

(build-utilities/update-dependencies)
(build-utilities/lein-generate)
in the build pipeline.

jaen22:03:06

As a bonus

jaen22:03:17

This automatically updates dependencies without having to restart the REPL

jaen22:03:24

(modulo dependency clashes)

smw22:03:29

that’s brilliant!

jaen22:03:08

Yeah, it's pretty nice.

jaen22:03:31

At some point I would want to have everything run in a pod so I can' avoid even those dependency clashes

jaen22:03:45

But that's rare enough I didn't care to do that yet.

jaen22:03:18

But it's nice

jaen22:03:39

You don't set dependencies in build.boot but in resources/dependencies.edn and it Just Works™.

jaen22:03:42

Which is nice.

smw22:03:00

Yes, yes. That is really nice.

smw22:03:20

May I assume a liberal license on this? Or have you published it somewhere?

jaen22:03:01

Though I didn't think of giving any license on that to be honest.

jaen22:03:23

Feel free to use it, it's nothing groundbreaking, just a bit more nicely wrapped snippet from boot wiki.

smw22:03:31

Thank you :simple_smile:

kenzaburo23:03:19

@smw so did you get dirac working with boot?

smw23:03:49

This seems to work.

smw23:03:16

Though honestly I haven’t had much time to play with it, somehow I keep ending up on calls :disappointed:

kenzaburo23:03:12

and disable boot-cljs-repl... i'll give it a try. which boot task calls start-dirac! ?

smw23:03:00

None here, so I was doing it from the repl separately

smw23:03:23

my thought was to make a dirac-repl task

smw23:03:44

that does the same stuff my cljs-repl task does with dirac replaced

kenzaburo23:03:47

oh ok, make sense, i'll give it a try, thx!

smw23:03:08

If I get a chance to get that part working, I’ll paste a gist here