Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working nix-shell - a bit convoluted but allows quick iteration. #2239

Merged
merged 1 commit into from
May 22, 2024

Conversation

alfreb
Copy link
Contributor

@alfreb alfreb commented May 19, 2024

I've been trying to make a nix shell that can take an IncludeOS package directly from a cmake install as input, to allow fast iteration on OS features, that link into a bootable, without having to rebuild the OS every time.

  • shell.nix is working to the point where cmake configure step finds the right versions of libcxx, libcxxabi, liunwind and musl, but compilation doesn't pick up the right clang by default. I hack it in by defining $CXX, but then it doesn't find libcxx, so c++ includes like <string> are unavailable.

  • shell_overlay.nix is a little simpler, where the idea was to expose the paths to the link time dependencies from pkgsIncludeOS. It has the same result - I get to the point where I think I can link, but I can't compile the bootable binary due to missing includes.

How can we make the nix shell use the same stdenv as nix-build?

Adds a nix shell for building an IncludeOS bootable, where IncludeOS is
provided as a local cmake installation, for rapid iteration.

1. Build IncludeOS locally, using the default.nix as a shell:
   1. $ nix-shell default.nix
   2. $ mkdir build_includeos && pushd build_includeos
   3. $ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/home/<you>/includeos_install
   4. $ make -j install
   5. $ popd
2. $ export INCLUDEOS_PACKAGE=/home/<you>/includeos_install
3. $ nix-shell --run 'make -j12 && $vmbuild hello_includeos.elf.bin $bootloader' && file build_example/hello_includeos.elf.bin.img

This should produce a bootable image. You can skip the --run and iterate on the
bootable in the nix shell.

This means there are two nix shells; one for developing the OS and one for the
bootable. This is dumb, but IncludeOS requires some older packages, like old GSL,
which is not a restriction the bootable should need to have. Stil, we should
probably harmonize the two.
@alfreb
Copy link
Contributor Author

alfreb commented May 20, 2024

Rebased. This works for me now - thanks @MagnusS for finding the right compiler! I've kept the old branch with the shell_overlay.nix and the attempts at moving the link time dependencies to the overlay in https://github.com/alfreb/IncludeOS/tree/nix-shell-overlay in case we want to revisit that idea. But this works and I think it can be merged, although the workflow is quite convoluted. Once you're in the two nix-shells development is pretty fast though, which was the objective.

@alfreb alfreb changed the title WIP nix-shell, clang not finding libcxx (do not merge) Working nix-shell - a bit convoluted but allows quick iteration. May 20, 2024
@MagnusS
Copy link
Member

MagnusS commented May 20, 2024

Perhaps we could use substituteInPlace to replace the paths we need in the make files directly. See the solo5 example in https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview-example. If we substitute the paths to point to the right location in cmake/os.cmake during postInstall we wouldn't have to specify them everywhere.

@MagnusS MagnusS merged commit c2ae8d9 into includeos:master May 22, 2024
alfreb pushed a commit to alfreb/IncludeOS that referenced this pull request Jun 3, 2024
Working nix-shell - a bit convoluted but allows quick iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants