limine icon indicating copy to clipboard operation
limine copied to clipboard

Onboard to nixpkgs

Open phip1611 opened this issue 1 year ago • 5 comments

Hi, cool project! It would be awesome to upstream this to nixpkgs! My company and I do a lot of low-level OS-related kernel development with the help of Nix. Having everything packaged in Nix enables us to create reproducible and productive development environments.

As this is my last day of work before my long vacation starts, I don't want to upstream this to nixpkgs today. I'm happy to work towards that goal when I'm back in March!

For now, I'd like to share my progress so that anyone else can continue working on this - if interested. Currently, I package it in Nix like that, but without the cross-compilation for riscv64 and aarch64:

# Builds limine with all available features.

{ gcc, gnumake, mtools, nasm, stdenv }:

let
  # It is recommended by limine to use the release tarballs instead the git repo.
  limineUrl = "https://github.com/limine-bootloader/limine/releases/download/v7.0.2/limine-7.0.2.tar.gz";
  limineSrc = builtins.fetchTarball {
    url = limineUrl;
    sha256 = "sha256:0h70hkzyxpavsa896mj8pqc4gr6hj0bb2d76prp0rsgy1syyy9kc";
  };
in
stdenv.mkDerivation {
  # TODO license meta data
  pname = "limine";
  version = "7.0.2";
  src = limineSrc;
  nativeBuildInputs = [ mtools gnumake gcc nasm ];
  doCheck = false;
  # TODO missing --enable-uefi-{aarch64,riscv64} cross compilation so far
  configurePhase = ''
    ./configure \
      --enable-bios-cd \
      --enable-bios-pc \
      --enable-bios-pxe \
      --enable-uefi-ia32 \
      --enable-uefi-x86-64 \
      --enable-uefi-cd
  '';
  buildPhase = ''
    make -j $(nproc)
  '';
  installPhase = ''
    mkdir -p $out/bin
    cp -R bin/. $out
    ln -s $out/limine $out/bin/limine
  '';
}

ping @blitz

phip1611 avatar Jan 31 '24 14:01 phip1611

This was already tried at NixOS/nixpkgs#194841, but it was never reviewed by the relevant maintainers

AshesOfEther avatar Jan 31 '24 15:01 AshesOfEther

Oh, good to know! Yeah, the throughput in nixpkgs on GitHub is incredible and maintainers are all overwhelmed.

My colleques and I know a few maintainers personally. I'm confident that we can do something about that issue.

phip1611 avatar Jan 31 '24 15:01 phip1611

That would be cool, I would love to see Limine in Nixpkgs!

AshesOfEther avatar Jan 31 '24 15:01 AshesOfEther

From what I've seen in https://github.com/NixOS/nixpkgs/pull/194841:

Maybe it would be good so split that up into two MRs:

  • just init the bootloader so that people can use the build artifacts (${pkgs.limine}/limine-bios-cd.bin etc)
  • make the bootloader usable by NixOS

phip1611 avatar Jan 31 '24 15:01 phip1611

Yes, splitting it into smaller individually useful PRs will make it easier to get it into nixpkgs. Adding it as a bootloader option and getting everything right is a lot of (review) work. For that it would be interesting to get at least a few people together that would maintain it. That being said, we can probably help direct some attention to those PRs.

blitz avatar Jan 31 '24 17:01 blitz

Hi, I'm back from vacation and ready to work on that issue now! @TobiasSN

phip1611 avatar Mar 18 '24 12:03 phip1611

Can you please provide some instructions for cross compilation? For example, if I'm on x86-64-linux and want to run

    ./configure \
      --enable-bios-cd \
      --enable-bios-pxe \
      --enable-bios \
      --enable-uefi-ia32 \
      --enable-uefi-x86-64 \
      --enable-uefi-aarch64 \
      --enable-uefi-cd \
      --enable-uefi-riscv64

I'm interested in the build environment for cross compilation for both, gcc and clang. I don't quite understand what's the idea here because it finds a lot of things..?

image

Background: I want (because I think it is the right thing to do) to let the limine derivation always build everything. Otherwise, this would limit other cross-compilation toolchains that want to build a bootable image for another platform using pkgs.limine.

ping @TobiasSN

phip1611 avatar Mar 18 '24 16:03 phip1611

Hi, If you have an LLVM/Clang toolchain installed, with targets enabled for all supported Limine ports, Limine will build all of its ports accordingly (can also use --enable-all).

If you want to use GCC, then you'll have to provide 3 or 4 different GCC/binutils toolchains for x86-64/i686, aarch64, and riscv64. This may involve configuring multiple times to specify toolchain components manually with the *_FOR_TARGET configure variables as described in ./configure --help.

mintsuki avatar Mar 18 '24 21:03 mintsuki

I created a draft MR in nixpkgs. The only blocking thing right now is that:

  • one of you has to tell me whether the provided meta information are fine (license)
  • you have to tell me whom I should add as maintainer (next to me)
  • if you have any other general concerns or so

https://github.com/NixOS/nixpkgs/pull/298048

Once we're all set, me colleques and I know people who we can ping to get it merged :)

phip1611 avatar Mar 22 '24 13:03 phip1611

one of you has to tell me whether the provided meta information are fine (license)

I would say it's fine, though keep in mind that several submodules used by Limine use different licenses (all more or less BSD-2-Clause compatible), namely (in SPDX identifier form):

  • 0BSD (used by: freestanding-toolchain, freestanding-headers)
  • Apache-2.0-with-LLVM-exceptions (used by cc-runtime)
  • BSD-3-Clause (used in part by limine-efi, alongside BSD-2-Clause)
  • Zlib (used by tinf)
  • Unlicense or MIT (used by stb)

you have to tell me whom I should add as maintainer (next to me)

If that is necessary I'd propose @48cf or alternatively myself as possible candidates.

if you have any other general concerns or so

I wouldn't say so, beyond what was already raised in #340

mintsuki avatar Mar 22 '24 14:03 mintsuki

I added @48cf in a dedicated commit, see https://github.com/NixOS/nixpkgs/pull/298048

phip1611 avatar Mar 25 '24 11:03 phip1611

I added @48cf in a dedicated commit, see NixOS/nixpkgs#298048

Could you please update my information in the maintainer-list.nix file? My github username is now, well, @48cf and for the email I'd rather use [email protected]

48cf avatar Mar 25 '24 12:03 48cf

I just copied the information from https://github.com/NixOS/nixpkgs/pull/194841/commits/b2c893d76838be094612a8710dc4ed1692bd9b6c - sorry!

phip1611 avatar Mar 25 '24 12:03 phip1611

whoops, apparently these @users.noreply.github.com email are not usable... can leave that as is then - i hope it's not too much trouble! (just decided to test that and it turns out it is in fact noreply 😅)

48cf avatar Mar 25 '24 12:03 48cf

Got it. Please check the latest version?

phip1611 avatar Mar 25 '24 12:03 phip1611

yeah that looks alright, thanks!

48cf avatar Mar 25 '24 12:03 48cf

Closed. Everything done!

phip1611 avatar Apr 06 '24 20:04 phip1611

General remark. I think, some upstream bots should automatically update Limine in nixpkgs, once a new Github release is created in this repo. We can keep an eye on it.

phip1611 avatar Apr 07 '24 11:04 phip1611

nice work guys, so what is the next move to add limine to nixpkgs as an option?

side note phip1611 you are man of culture for being persistent and patient

RoadRoller01 avatar Apr 30 '24 21:04 RoadRoller01

nice work guys, so what is the next move to add limine to nixpkgs as an option?

Thanks! I guess you refer to using Limine as optional bootloader for NixOS.

So, at my company, generally speaking we have interest in Limine. That's why we worked on upstreaming it in our work time at the first place. However, at the moment, we can't justify spending many hours on it with little company benefit. At least I am unsure what the required effort for this is. @astro might have better insights.

I do not have the capacity to work on this in my free time in the next months, unfortunately.

phip1611 avatar May 01 '24 10:05 phip1611