babashka-sci-dev

2022-04-21T21:43:34.655589Z

@borkdude Heyo. Following up on the idea to read all nbb feature files from classpath. The remaining files to do this for would be a feature's deps.edn and shadow-cljs.edn. Given a user's selection of $NBB_FEATURES, how would we know that one of those files maps to a specific nbb feature?

2022-04-21T21:43:45.196859Z

One idea could be to namespace by directory e.g. nbb-features/%s/deps.edn. We could also namespace by file e.g. nbb_feature_%s_deps.edn but I don't know if clj handles deps.edn files with unconvential names

borkdude 2022-04-21T21:53:45.774819Z

The deps.edn should not matter since those deps would already be on the classpath. The idea is: being on the classpath, means you want to use that feature. The only thing that matters is the nbb_feature.edn file and that can be self-descriptive with some shadow config inside of it

🤔 1
borkdude 2022-04-21T21:54:20.841479Z

going to sleep now

👍 1
2022-04-21T22:02:54.859109Z

Having no $NBB_FEATURES means we'll have slightly different versions of https://github.com/babashka/nbb/blob/613902dadb8f4ecec384a6a74b1440f356f3f2a3/src/nbb/macros.clj#L25-L35 for bb and clj but that's ok. Is nbb_features.edn still a vector? Would the shadow-config just be :shadow-config {...} alongside the other keys in nbb_features.edn?

2022-04-21T22:09:59.206419Z

I can try this out tomorrow. Some other questions: • Would just the bb compile task be made available as a lib to downstream feature repos like nbb-logseq? • Where's the new file for the bb task lib? • What happens to the datascript and datascript-transit features that ship with nbb? I guess they get added as a dep using :deps/root? Would it be helpful to have a separate nbb-features repo that takes contributions liberally? Could be helpful to nbb users to have a set of features that are easy to drop in to a deps.edn

2022-04-22T13:53:05.221919Z

Mornin! Any opinions on the above? If not, I can give it a best effort and then tweak later if you have feedback

borkdude 2022-04-22T13:56:33.544609Z

I'm finally awake again, let me think right now and I'll come back

👍 1
borkdude 2022-04-22T14:19:30.864789Z

I think yes to most of the above.

borkdude 2022-04-22T14:20:06.043309Z

What we could also do is build the build of nbb as a nbb script ;)

borkdude 2022-04-22T14:20:30.310409Z

but this will be harder to deal with .jar files and such, so let's stay with bb

borkdude 2022-04-22T14:20:56.600639Z

> What happens to the datascript and datascript-transit features that ship with nbb? I think we could port that to the "new" approach

borkdude 2022-04-22T14:21:41.462759Z

Tests of datascript can be moved out to the features repo. I think that the feature repo can test its own feature in CI

borkdude 2022-04-22T14:22:11.172969Z

And the factored out build library should test at least one feature to test the concept

👍 1
borkdude 2022-04-22T14:22:45.424279Z

> Would it be helpful to have a separate nbb-features repo that takes contributions liberally? Yes, we could just move everything to there

borkdude 2022-04-22T14:23:11.412429Z

This could be a repo under babashka and I can make you a contributor there so you can push without my permission

borkdude 2022-04-22T14:23:30.556709Z

Any unanswered questions?

2022-04-22T14:25:33.036429Z

> What we could also do is build the build of nbb as a nbb script 😉 That would be cool some day > This could be a repo under babashka and I can make you a contributor there so you can push without my permission Cool Any preference on where the build library is? I was thinking script/nbb/build.clj

borkdude 2022-04-22T14:26:16.827029Z

Sure, but how do we "share" the build library?

borkdude 2022-04-22T14:27:18.415019Z

We could also put it in nbb/build/deps.edn , nbb/build/src/...

borkdude 2022-04-22T14:27:43.016389Z

and then use deps/root (externally) and local/root (within nbb) to get the lib

2022-04-22T14:28:20.962039Z

I thought it would just be a git dep. I'm guessing that would require modifying :paths in deps.edn which probably isn't desirable

2022-04-22T14:28:33.164629Z

separate root sounds good

borkdude 2022-04-22T14:29:57.123039Z

This sounds like it's going to be very extensible which is good!

2022-04-22T14:31:23.985179Z

Indeed! Excited to see how this goes

2022-04-22T19:04:27.077339Z

Any ideas on how the bb build task would pass its classpath containing feature deps to the clj command running shadow-cljs? I don't see another way than the current dynamic deps.edn approach - https://github.com/babashka/nbb/blob/c3ffa5352b7ab6870e8f909cde10d139bb863ee6/bb.edn#L19-L26

borkdude 2022-04-22T19:08:07.303719Z

@cldwalker That works. Another way would be to call (babashka.deps/add-deps ...) on the maps and then use the classpath that is in (babashka.classpath/get-classpath) . But I think your approach might be better

borkdude 2022-04-22T19:08:32.282939Z

Also faster

borkdude 2022-04-22T19:08:42.472089Z

since you're not calling the clojure CLI for each feature

borkdude 2022-04-22T19:09:18.289049Z

Another way could be to emit a deps.edn into a _fake_project folder and then add :local/root "_fake_project"

2022-04-22T19:12:25.319959Z

Hmm. One downside of the current dynamic deps.edn approach is that the dynamic :local/root has to be built from the path of nbb_features.edn. In other words, :local/root has to assume that 'src/nbb_features.edn' relates to :local/root being one directory up

2022-04-22T19:15:01.901709Z

For deps/add-deps to work I think the bb task would have to read from its bb.edn file

borkdude 2022-04-22T19:16:03.826439Z

you can start another bb instance in another directory

borkdude 2022-04-22T19:16:15.887009Z

with shell etc

2022-04-22T19:19:04.694769Z

Not sure a I understand. What would the command be? Does bb provide a path to the current bb.edn file or map it's using b/c I think that would work?

borkdude 2022-04-22T19:20:16.800499Z

Yes: (System/getProperty "babashka.config")

borkdude 2022-04-22T19:20:41.019329Z

what I mean is that you can start a new babashka in a new temporary directory

borkdude 2022-04-22T19:20:47.878929Z

and spit out a bb.edn in there

borkdude 2022-04-22T19:20:59.802749Z

but it remains a hack

2022-04-22T19:24:34.003509Z

K. I think feeding babashka.config to deps/add-depsworks with no obvious downsides. I could then pass the new classpath to shadow with clj -Scp (classpath/get-classpath)

borkdude 2022-04-22T19:25:41.334139Z

indeed

👍 1