<clever>
in this example, i'm not even using a Makefile because the program is a single-source thing
<mishac>
i see, thank you! let me try and build it and see if that works
<MichaelEden[m]>
mishac: are you asking about how to write a nix derivation or what commands to use in your makefile?
<mishac>
I am asking how to build < any c program > and then run it on beaglebone
<mishac>
what i tried was
<mishac>
creating a shell environment
<mishac>
with
<clever>
if you point nix-shell to an mkDerivation like above, $CC will be a cross-compiler
<mishac>
do you mean
<mishac>
I do something like
<MichaelEden[m]>
clever: i do this to get a cross shell `nix-shell --pure -A pkgsCross.armv7l-hf-multiplatform.hello channel:nixos-unstable` is there a better way?
<clever>
MichaelEden[m]: thats one simple way to do it
<mishac>
yeah
<clever>
mishac: that will fail because it lacks a name=
<mishac>
I tried with creating shell with that paramter
<mishac>
well
<mishac>
there is name
<mishac>
i am just putting a portion, which i think is relevant
<mishac>
when i enter shell and run $CC my_c_file -o test
<mishac>
it creates binary
<mishac>
but it does not run on beaglebone
<MichaelEden[m]>
what's the error?
<clever>
you must copy the things it depends on as well
<clever>
and thats why its better to use src= and nix-build
<mishac>
and i tried nix build as well
<clever>
then nix knows what it depends on, and can copy everything over
<clever>
use nix-copy-closure, not plain scp
<mishac>
i use
<mishac>
NSF to share folder
<mishac>
between beaglebone
<clever>
mishac: is /nix/store at /nix/store on both machines?
<mishac>
so there is no copying
<mishac>
no
<mishac>
beaglebone runs debian
<clever>
thats why it doesnt work
<mishac>
i set up NSF so that i can access my computer files from beaglebone
<clever>
nix hard-codes the paths to libraries into the binary, and those paths point to /nix/store/
<mishac>
yes
<clever>
you must mount the computers /nix/store to /nix/store on the beaglebone
<mishac>
\thats the problem
<mishac>
that is exacrlt the problem
<clever>
you can easily do that with nfs
<clever>
mount desktop:/nix/store /nix/store
<mishac>
what do yo mean: you must mount the computers /nix/store to /nix/store on the beaglebone
<mishac>
install nix on beaglebone
<clever>
`ls /nix/store/` must have the exact same output, on both the computer and beaglebone
<mishac>
but beaglebone does not have
<mishac>
nix store
<clever>
then mkdir it
<mishac>
just create mkdir
<mishac>
with the
<clever>
yes, `mkdir /nix/store/`
<clever>
then mount the desktops store to that
<mishac>
through nfs?
<clever>
yes
<mishac>
ohhh
<mishac>
that is
<mishac>
clever
<mishac>
i didnt think about that
<mishac>
i see that should fix the problem
<mishac>
however
<clever>
2 main problems with that
<clever>
#1, you cant run nix commands on the beaglebone (having 2 machines write to the store at once isnt safe)
<clever>
#2, the beaglebone now relies on the desktop to access those binaries, and wont work without the desktop
<mishac>
^
<mishac>
both are very important
<clever>
one minute
<mishac>
and i have scouring web on how to make it work
<mishac>
so that i get /lib/ld-linux-armhf.so.3 (0xb6f0f000)
<simpson>
Yeah, clever is only sketching how to get up and running immediately. In the longer run, you'll presumably want to use Nix on the Bone directly.
<clever>
you solve both, by just installing nix, and not using nfs
<clever>
then use nix-copy-closure, as i said at the begining
<clever>
so you can put that cross-compiled nix, into a tar, then unpack the tar on the beaglebone, and --load-db its registration file
<clever>
that will "install" nix onto the beaglebone
<clever>
then you can use normal nix-copy-closure to push future changes over
<mishac>
any way there I could just compile program on my machine and transfer through NFS and let it run beaglebone?
<clever>
you need nix on the beaglebone to do that
<mishac>
ohh
<clever>
or reverse the nfs mount, and use local?root and `nix copy`
<mishac>
install nix package manager
<clever>
and i just explained how to cross-compile nix, put it into a tar, and then install that tar
<mishac>
so the command above, it will cross compile specific package
<clever>
yeah
<mishac>
so in the future , i encounter more packages that are missing, i would have to do it for them as well
<mishac>
ok
ryantrinkle has quit [Ping timeout: 265 seconds]
<mishac>
let me try that do that
<MichaelEden[m]>
mishac: you can have nix list out all the dependencies and just rsync them to the target machine if you don't want nix installed on the beaglebone
<clever>
but that wont properly manage db.sqlite, and wont skip things the beaglebone already has, making the copies take longer
<clever>
you can also do similar if you use make-system-tarball.nix and just blindly unpack many tar's to the same root
<MichaelEden[m]>
clever: yea i'm assuming this board is disposable and db.sqlite doesn't need to be kept updated
<MichaelEden[m]>
also rsync will skip over things already on target right?
<clever>
but it will eventually run out of space, and you will need to GC
<clever>
MichaelEden[m]: depends on the rsync flags i believe, i dont use it much
<MichaelEden[m]>
oh true, i guess i would just blow away everyhing at that point, or tell rsync to delete things that aren't in the file list
<clever>
and it gets complicated as soon as you want 2 different exprs on the bone
<simpson>
At some point, working with Nix becomes easier than working against Nix.
<MichaelEden[m]>
yeah
<MichaelEden[m]>
i stick a usb drive in the bone and bind-mount. oh, I forgot to mention I have a statically linked ARMv7 nix if you need it mishac
<clever>
MichaelEden[m]: local?root= can help if your using usb drives, or flipping the nfs the other direction
v0|d has joined #nixos-aarch64
<clever>
if you remove the root disk from the beaglebone, and then mount it to /mnt on a desktop (or nfs mount the beaglebone to /mnt)
<clever>
then you can `nix copy --to local?root=/mnt /nix/store/whatever`
<clever>
and that will copy from /nix/store to /mnt/nix/store
<MichaelEden[m]>
oh neat
<clever>
then you dont need nix on the beaglebone (but you could use this to copy nix to it as well)
<MichaelEden[m]>
there's so many nix tricks i learn everyday
<{^_^}>
nixops#1189 (by cleverca22, 4 weeks ago, open): plan for supporting custom partition layouts and custom FS's on any backend
<mishac>
I see
<mishac>
thank you
<clever>
and nixops could do both steps, over a recovery console, to install the nixops config, and skip the 1st dummy generation
<mishac>
Clever, one question. When you said: if you remove the root disk from the beaglebone, and then mount it to /mnt on a desktop (or nfs mount the beaglebone to /mnt)
<mishac>
what do you mean remove root disk from the beaglebone
<clever>
mishac: is the root disk an sd card? usb stick? or flash soldered to the board?
<mishac>
flash soldered on board
<clever>
ah, then you cant remove it
<mishac>
yep
<clever>
your only choice (for that route) is to nfs mount beaglebone:/nix to /mnt/nix
<mishac>
I see
<clever>
then you can use the x86 nix to copy things into the beaglebone, and dont need nix on the bone immediately
<clever>
2019-09-17 18:17:20 < clever> then you can `nix copy --to local?root=/mnt /nix/store/whatever`
<mishac>
clever, last clarification "is to nfs mount beaglebone:/nix to /mnt/nix" can you parahrase
<clever>
configure an nfs server on the beaglebone, to export /nix
<clever>
and then run `mount -v beaglegone:/nix /mnt/nix` on any x86 machine with nix
<mishac>
and /nix is the
<clever>
the /nix can be a completely empty directory at this step
<mishac>
just a some directory that is exported by beaglebone
<mishac>
and use nix copy to transfer files
<clever>
it must appear at /nix on the beaglebone, for things to function correctly
<mishac>
?
<clever>
yeah
<mishac>
so no need to use copy clousure
<clever>
use `nix copy` instead, as i showed in the last example
<mishac>
yeah
<mishac>
great
<mishac>
and one last last question
<clever>
and since the nfs mount is going the other way, the beaglebone can survive on its own
<clever>
it just looses the ability to modify things in /nix/store/
<clever>
until you re-mount things, and have an x86 help out
<mishac>
i see
<mishac>
just thinking a bit ahead
<MichaelEden[m]>
If you're willing to have a NixOS image on your beaglebone you can use NixOps to do all the updating
<mishac>
Michael, that is something i will consider doing in the future
<mishac>
just need it for class
<MichaelEden[m]>
clever: the nfs method you described, does that update the sqlite database?
<mishac>
clever, thinking ahead, is it possible to write a build script (post install script) where this nix-copy command is executed automatically
<clever>
MichaelEden[m]: yeah, `nix copy --to local?root=/mnt` will maintain the sqlite db as it copies things
<clever>
mishac: its basically just `nix-build -A foo && nix copy --to local?root=/mnt ./result`
<mishac>
wonderful
<mishac>
thank you very much
<mishac>
!!
<MichaelEden[m]>
Cool stuff clever
<mishac>
i have enough info go from here
<mishac>
Clever, i just did what you described and run into problem with using
<mishac>
nix copy command
<mishac>
error: cannot add path '/nix/store/5lyvydxv0w4f2s1ba84pjlbpvqkgn1ni-linux-headers-4.19.16' because it lacks a valid signature
<mishac>
is it something beaglebone realated
<mishac>
or nixos related
<clever>
mishac: try running that command as root
<mishac>
same error
<clever>
mishac: try adding `--option require-sigs false` without root
zupo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mishac>
it copied something
<mishac>
but now when i examine /nix folder
<mishac>
on beaglebone
<mishac>
it has store var
<mishac>
and some packages
<mishac>
so if i understand correctly what the command it copied some of the nix-store information
<mishac>
to beaglebone
<mishac>
correct?
<mishac>
then the question is how can i access binaries?
<mishac>
that i compiled
zupo_ has joined #nixos-aarch64
<MichaelEden[m]>
If you `ls /nix/store` can you see anything with the name of your derivation?
<mishac>
hmm
<mishac>
this is weid, i think i did some things incorrectly
t184256 has left #nixos-aarch64 ["Error from remote client"]
t184256 has joined #nixos-aarch64
mishac has quit [Ping timeout: 260 seconds]
<DigitalKiwi>
t184256: do you know why i can't find the directory where the data is stored? it seems to not exist :|