Gitlab Pages - Neuron

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

TheMatten

I'm trying to setup automatic building of neuron web on Gitlab, though approach taken in github template seems to use Github API for receiving neuron binary, which requires token for access - is there some "public" way of receiving "neuron bundle"?

TheMatten

https://github.com/srid/neuron/issues/292

I would like download linux bundles of neuron in CI outside of Github (https://funprog.zulipchat.com/#narrow/stream/231929-Neuron/topic/Gitlab.20Pages/near/204132793), but Github API seems to requi...
Sridhar Ratnakumar

Responded. @TheMatten as a quick workaround meanwhile I suppose you can just commit the bundle executable to your repo, and update it once in a while.

TheMatten

Merged - @Sridhar Ratnakumar thanks!

TheMatten

Hmm, I'm having some problems with input and output directories to neuron:
First, neuron rib doesn't seem to like relative paths in -o - it doesn't seem to output anything at all when given one, even though it lists built files as usually
Second, while trying to build page on GitLab, it fails to find directory given through -d even though I literally list it's content before running neuron

Not sure whether I'm missing something or whether this is a bug

A template to get started with neuron (modified from https://github.com/srid/neuron-template)
Sridhar Ratnakumar

@TheMatten What's the full neuron CLI ?

Sridhar Ratnakumar

-d should appear before any subcommand. I can't find the CLI you used from the link above.

TheMatten

See commit on the right side - I use it that way

Sridhar Ratnakumar

@TheMatten Try set -x so it spits out the actual command.

Your gitlab yml has:

./neuron -d $CI_PROJECT_DIR rib -o $CI_PROJECT_DIR/public

I can't tell what those env vars contain (or if they are empty)

Sridhar Ratnakumar

And yea, you need absolute path. That's the limitation of using nix-bundle

Sridhar Ratnakumar

Second, while trying to build page on GitLab, it fails to find directory given through -d even though I literally list it's content before running neuron

Ah, I missed this

Sridhar Ratnakumar

something to do with nix-bundle not playing well with mounted directories? i see you are using docker

Sridhar Ratnakumar

can you do away with not using docker? the bundle should run on linux 64-bit

Sridhar Ratnakumar

potential workaround if you can't find a good fix: cp -r $CI_PROJECT_DIR proj; neuron -d $(pwd)/proj rib ...

TheMatten

@Sridhar Ratnakumar I'm not sure whether I can use non-Docker configuration on hosted CI - is there some specific reason why nix-bundle shouldn't play well with it?

TheMatten

BTW, $CI_PROJECT_DIR points to working directory of cloned repo

Sridhar Ratnakumar

no idea; something to do with chroot? https://github.com/matthewbauer/nix-bundle/issues/56

Hi, I would like to package a Nix app (seth) to a non-NixOs docker image (i.e alpine) with nix-bundle.sh. Here's my Dockerfile: FROM nixos/nix as buildSeth RUN adduser -D sethservice &&...
TheMatten

Hmm, maybe
I've tried running alpine:latest image locally (Arch Linux host) and I'm getting this, even after doing what it says and checking that setting:

~ # ./neuron -d . rib -o output
Run the following to enable unprivileged namespace use:
sudo bash -c "sysctl -w kernel.unprivileged_userns_clone=1 ; echo kernel.unprivileged_userns_clone=1 > /etc/sysctl.d/nix-user-chroot.conf"
Sridhar Ratnakumar

If nothing works, then you might as well nix-env -i ... it directly (after having done 'cachix use srid'). Should take no more than 2mins.

Sridhar Ratnakumar

Or, we push docker image in neuron CI (see docker.nix in neuron repo)

TheMatten
> nix-build docker.nix --show-trace
error: while evaluating the attribute 'buildCommand' of the derivation 'docker-image-neuron.tar.gz' at /nix/store/km5w6fszy4bcs9q13mr3biabirshrrgw-nixpkgs-20.09pre226024.873e114cf49/nixpkgs/pkgs/build-support/trivial-builders.nix:7:7:
while evaluating the attribute 'contents' of the derivation 'docker-layer-neuron' at /nix/store/km5w6fszy4bcs9q13mr3biabirshrrgw-nixpkgs-20.09pre226024.873e114cf49/nixpkgs/pkgs/build-support/trivial-builders.nix:7:7:
cannot coerce a function to a string, at /nix/store/km5w6fszy4bcs9q13mr3biabirshrrgw-nixpkgs-20.09pre226024.873e114cf49/nixpkgs/pkgs/build-support/trivial-builders.nix:7:7
Sridhar Ratnakumar

would be nice to have CI automatically build and push this to https://hub.docker.com/r/sridca/neuron

Sridhar Ratnakumar

I jush did a one-off push to the hub

Sridhar Ratnakumar

docker hub says image size is "80.75 MB" which is curious

Sridhar Ratnakumar

Not bad at all ... 80mb download on mac, and it just works

Sridhar Ratnakumar
docker run --rm -i -p 8080:8080 -v ~/zettelkasten:/zettelkasten sridca/neuron:test neuron rib -ws 0.0.0.0:8080
Sridhar Ratnakumar

Sridhar Ratnakumar said:

would be nice to have CI automatically build and push this to https://hub.docker.com/r/sridca/neuron

https://github.com/srid/neuron/issues/146

CI should automatically publish the docker image from the project root's docker.nix. In effect, run these commands in CI: docker load -i $(nix-build docker.nix) docker login ... docker push sri...
TheMatten

I ended up making custom docker image with bash_5 and coreutils, but it works now perfectly!

Sridhar Ratnakumar

Nice. How long does it take for the CI to run?

TheMatten

Haha, it's actually around 25 seconds, so I didn't even have to change the number in FAQ :big_smile:

TheMatten

I think GitLab Pages template should now be ready for use: https://gitlab.com/thematten/neuron-template

A template to get started with neuron (modified from https://github.com/srid/neuron-template)
TheMatten

I've created PR to include it in docs in case you're interested

Links to modified version of neuron-template that works with GitLab Pages.
TheMatten

another PR to make (possibly automated) custom docker.nix builds easier
bash_5 and coreutils seem to add some size, maybe they could be replaced with something like busybox?

This makes it more convenient to build custom images (possibly with shell included) using --arg flags in nix-build. investigate possibility of lowering shell footprint