Re: nix develop

Tom Herbert <[email protected]> Thu, 23 Oct 2025 15:13:12 -0700
Newsgroups dev.linux.lists.xdp2
Message-ID <CALx6S372XnWpV_am0Vgk_hb0Uf8K95-kc4zMFUOyxePOONz97Q@mail.gmail.com>
On Wed, Oct 22, 2025 at 8:34=E2=80=AFAM Simon Leinen <[email protected]=
h> wrote:
>
> Dear Dave,
>
> > I had a bit of a misunderstanding / confusion about the "dev shell"
> > verse nix packages in general.  I've now done a major refactor and a
> > lot more testing.
>
> This works nicely, thanks a ton! I can now finally compile all the xdp2
> code cleanly.  I think it's a nice way to isolate the dependencies, and
> would be very happy to see it merged.

This is really impressive work! I've merged it, I think we'll want to
hone it over time and move it from "experimental", I would love it if
we can make the process super easy.

Thanks!
Tom

>
> Cheers,
> --
> Simon.
>
> > I also made some videos on how to install Nix
>
> > How to install Nix on Ubuntu
> > https://youtu.be/cb7BBZLhuUY
>
> > How to install Nix on Fedora
> > https://youtu.be/RvaTxMa4IiY
>
> > And I've made demo videos for both Ubuntu and Fedora.... and I'm really=
 glad I did because although the dev shell
> > was working on Ubuntu, when I tried Fedora it didn't work at first go a=
nd required some improvements to the
> > flake.nix.
>
> > ( Sorry, it's a bit long, but it does show the entire process. )
> > Ubuntu
> > https://drive.google.com/file/d/1o42vMoEJhdF9U4Ugp7ouWJskCeEPpdaa/view?=
usp=3Dsharing
>
> > Fedora
> > https://drive.google.com/file/d/18IYjBAErNF8VGRG5xMi_WWtlFLAm2xOn/view?=
usp=3Dsharing
>
> > Please note that although nix runs on Apples, the xdp2 repo needs libbp=
f, and currently the libbpf nix package is
> > only available for Linux.  I guess it would be nice to open up developm=
ent to Apples people, but for now they will
> > need to use a VM.
>
> > The instructions are:
> > ------------------------------ snip ------------------------------
> > sh <(curl --proto '=3Dhttps' --tlsv1.2 -L https://nixos.org/nix/install=
) --daemon       <--- install nix
> > git clone https://github.com/randomizedcoder/xdp2
> > cd xdp2
> > git checkout nix_development_new                                       =
                            <--- different branch
> > nix --extra-experimental-features 'nix-command flakes' develop .       =
              <--- this command will enable the
> > "flakes" feature
> > build-all                                                              =
                                                 <--- run helper
> > ------------------------------ snip ------------------------------
>
> > Or if you want to enable flakes, Simon's trick is a good option:
> > ------------------------------ snip ------------------------------
> > sh <(curl --proto '=3Dhttps' --tlsv1.2 -L https://nixos.org/nix/install=
) --daemon       <--- install nix
> > git clone https://github.com/randomizedcoder/xdp2
> > cd xdp2
> > git checkout nix_development_new                                       =
                            <--- different branch
> > test -d /etc/nix || sudo mkdir /etc/nix
> > echo 'experimental-features =3D nix-command flakes' | sudo tee -a /etc/=
nix/nix.conf           <--- nice!
> > nix develop
> > ------------------------------ snip ------------------------------
>
> > Hopefully this time it's correct! =F0=9F=98=89
>
> > On Thu, Oct 2, 2025 at 4:26=E2=80=AFAM Simon Leinen <simon.leinen@switc=
h.ch> wrote:
>
> >  Hi Dave,
>
> >  thanks a ton for your work on the Nix-based development environment fo=
r
> >  xdp2! This is a very promising avenue.  I had attempted to build the
> >  xdp2 repo (without Nix), but had some issues and too little time to lo=
ok
> >  into all of them.  I'd be happy to join forces and work on a Nix-based
> >  environment instead.
>
> >>> Simon (or anyone else) - I suspect if you have nix installed, you can
> >>>
> >>> git clone https://github.com/randomizedcoder/xdp2/
> >>> git branch nix_develop
> >>> nix develop
>
> >  Hi Tom,
>
> >> I tried it but got error:
>
> >> error: experimental Nix feature 'nix-command' is disabled; use
> >> '--extra-experimental-features nix-command' to override
>
> >  Try adding this line to /etc/nix/nix.conf:
>
> >  ------------------------------ snip ------------------------------
> >  experimental-features =3D nix-command flakes
> >  ------------------------------ snip ------------------------------
>
> >  My slightly modified instructions would be:
>
> >  ------------------------------ snip ------------------------------
> >  git clone https://github.com/randomizedcoder/xdp2
> >  cd xdp2
> >  git checkout nix_develop
> >  test -d /etc/nix || sudo mkdir /etc/nix
> >  echo 'experimental-features =3D nix-command flakes' | sudo tee -a /etc=
/nix/nix.conf
> >  nix develop
> >  ------------------------------ snip ------------------------------
>
> >  If this works (it does for me on an Ubuntu 24.04 VM with a basic Nix
> >  installation), you should be able to
>
> >    cd src
> >    make
>
> >  This gets relatively far for me, then bails with
>
> >    [...]
> >    lib
> >    make[2]: *** [Makefile:37: parsers/parser_big.p.c] Segmentation faul=
t (core dumped)
> >    make[2]: *** [Makefile:37: parsers/parser_simple_hash.p.c] Segmentat=
ion fault (core dumped)
>
> >  To be investigated...
>
> >  Cheers,
> >  --
> >  Simon.
>
> >>> And you should get dropped into a nix development shell with
> >>> #AllTheThings for xdp2
> >>>
> >>> Again, the branch is this. I definitely don't want to merge this
> >>> version, but I would be interested in feedback on it.
> >>> https://github.com/randomizedcoder/xdp2/tree/nix_develop
> >>>
> >>> Tom - would love to discuss this with you in realtime.  My afternoons
> >>> are better.
>
> >> Friday afternoon PDT?
>
> >> Tom
>
> >>>
> >>> --
> >>> Regards,
> >>> Dave Seddon
> >>> +1 415 857 5102
>
> > --
> > Regards,
> > Dave Seddon
> > +1 415 857 5102
>