Experimenting with building a Go binary #71
Replies: 1 comment 5 replies
-
This warms my heart to receive this message. Thank you for trying out this little experiment! 💜
I'm so very glad to hear that! That's exactly the sort of experience I'm hoping to provide.
Yup, this looks about right for an unsandboxed build. My goal with #30 is to have a hermetic C and Go compiler (and bash + standard Unix utilities) that can be dropped in without the user having to install anything. And I really ought to write some docs. Tracking mostly in #7. It's very encouraging to hear you were able to figure this out even without that! Bravo.
Yes, having the builder be a shell script is pretty common in Nix land. Each
bash is performing the expansion. Hypothetically, as long as you have a builder that writes the output to the
Things like |
Beta Was this translation helpful? Give feedback.
-
Hello,
I saw your project some time ago on HN and it looked interesting, thank your for making it ! I have no experience with Nix but I like the idea, however I never tried it because of the Nix language so the fact that you're using Lua is great in my opinion.
Anyway, I started experimenting with writing a derivation to build a go binary from a local module, just for fun.
I have this right now after a lot of trial and error:
This works but I have some questions:
First, is it expected to write a shell script that does the actual call to
go build
? At first I usedbuilder = "/usr/bin/go"
and expected to be able to put my files at the right place somehow, but looking at bootstrap.lua it seems like shell scripts are the way to go.I'm also confused how and where
$in
and$out
get replaced, because it seems like I have to use a shell to get their value: for example I triedcommand = "build -o $out $in"
with the go builder above and the command gets the raw strings$out
and$in
, not their values.Second, I had to explicitly set
GOCACHE
because$HOME
is not accessible, which makes sense, but I'm wondering if there is (or will be) a way to have a cache for go builds across multiple invocations ofzb build
?Beta Was this translation helpful? Give feedback.
All reactions