mirror of
https://github.com/limine-bootloader/limine
synced 2025-02-12 15:14:24 +03:00
nix: Remove build.nix
The build method was full of workarounds, plus I do not really see the point in having this upstream given Limine is now downstream in nixpkgs. For everthing else the 'nix develop' environment suffices.
This commit is contained in:
parent
9f98cf150a
commit
39c30996fe
11
.github/workflows/check.yml
vendored
11
.github/workflows/check.yml
vendored
@ -30,15 +30,6 @@ jobs:
|
|||||||
- name: Build the bootloader (GNU, riscv64)
|
- name: Build the bootloader (GNU, riscv64)
|
||||||
run: ./bootstrap && ./configure TOOLCHAIN_FOR_TARGET=riscv64-linux-gnu --enable-werror --enable-uefi-riscv64 && make all && make maintainer-clean
|
run: ./bootstrap && ./configure TOOLCHAIN_FOR_TARGET=riscv64-linux-gnu --enable-werror --enable-uefi-riscv64 && make all && make maintainer-clean
|
||||||
|
|
||||||
build_nix:
|
|
||||||
name: Build with Nix
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: cachix/install-nix-action@v26
|
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
|
||||||
- run: nix build .#limine
|
|
||||||
|
|
||||||
build_nix_shell:
|
build_nix_shell:
|
||||||
name: Build with Nix shell toolchain
|
name: Build with Nix shell toolchain
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -46,4 +37,4 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: cachix/install-nix-action@v26
|
- uses: cachix/install-nix-action@v26
|
||||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
- run: nix develop --command bash -c "./bootstrap && ./configure --enable-all && make -j $(nproc)"
|
- run: nix develop --command bash -c "./bootstrap && ./configure --enable-all && make -j $(nproc)"
|
||||||
|
22
README.md
22
README.md
@ -87,10 +87,9 @@ Host utility binaries are provided for Windows.
|
|||||||
This repository provides [Nix](https://nixos.org/)-based tooling for a convenient
|
This repository provides [Nix](https://nixos.org/)-based tooling for a convenient
|
||||||
development environment and building Limine using Nix.
|
development environment and building Limine using Nix.
|
||||||
|
|
||||||
- `$ nix build .#\limine` (build with clang and `--enable-all`)
|
|
||||||
|
|
||||||
To use the regular build flow using a toolchain obtained by Nix, simply
|
To use the regular build flow using a toolchain obtained by Nix, simply
|
||||||
run `$ nix develop` to open a Nix shell. Then follow the guide below.
|
run `$ nix develop` to open a Nix shell. Then follow the guide below,
|
||||||
|
skipping the "Prerequisites" step.
|
||||||
|
|
||||||
### Regular build
|
### Regular build
|
||||||
|
|
||||||
@ -125,7 +124,7 @@ commands are supposed to be run inside the build directory.
|
|||||||
|
|
||||||
To build Limine, run:
|
To build Limine, run:
|
||||||
```bash
|
```bash
|
||||||
make -j $(nproc) # (or gmake where applicable)
|
make # (or gmake where applicable)
|
||||||
```
|
```
|
||||||
|
|
||||||
The generated bootloader files are going to be in `./bin`.
|
The generated bootloader files are going to be in `./bin`.
|
||||||
@ -144,21 +143,6 @@ make install # (or gmake where applicable)
|
|||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
### Consume via Nix
|
|
||||||
|
|
||||||
Limine is in `nixpkgs` (starting from `nixos-24.05`) as `pkgs.limine`
|
|
||||||
(recommended).
|
|
||||||
|
|
||||||
You can also consume this as Nix flake directly to get the freshest development
|
|
||||||
version:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{
|
|
||||||
inputs.limine.url = "github:limine-bootloader/limine/<branch>";
|
|
||||||
inputs.limine.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### UEFI
|
### UEFI
|
||||||
The `BOOT*.EFI` files are valid EFI applications that can be simply copied to
|
The `BOOT*.EFI` files are valid EFI applications that can be simply copied to
|
||||||
the `/EFI/BOOT` directory of a FAT formatted EFI system partition. These files can
|
the `/EFI/BOOT` directory of a FAT formatted EFI system partition. These files can
|
||||||
|
12
flake.lock
generated
12
flake.lock
generated
@ -22,11 +22,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712310679,
|
"lastModified": 1712588820,
|
||||||
"narHash": "sha256-XgC/a/giEeNkhme/AV1ToipoZ/IVm1MV2ntiK4Tm+pw=",
|
"narHash": "sha256-y31s5idk3jMJMAVE4Ud9AdI7HT3CgTAeMTJ0StqKN7Y=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "72da83d9515b43550436891f538ff41d68eecc7f",
|
"rev": "d272ca50d1f7424fbfcd1e6f1c9e01d92f6da167",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -38,11 +38,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-unstable": {
|
"nixpkgs-unstable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712388808,
|
"lastModified": 1712666087,
|
||||||
"narHash": "sha256-9ogU4c3vUmuMDoRlbQCeq3OKx0XJmgHcLZ4XywJNYWI=",
|
"narHash": "sha256-WwjUkWsjlU8iUImbivlYxNyMB1L5YVqE8QotQdL9jWc=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fe4295b9ecd88764c1abf6179e03b1a828ca0e9a",
|
"rev": "a76c4553d7e741e17f289224eda135423de0491d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
14
flake.nix
14
flake.nix
@ -21,14 +21,6 @@
|
|||||||
# will notice it soon enough.
|
# will notice it soon enough.
|
||||||
systems = nixpkgs.lib.systems.flakeExposed;
|
systems = nixpkgs.lib.systems.flakeExposed;
|
||||||
perSystem = { config, pkgs, ... }:
|
perSystem = { config, pkgs, ... }:
|
||||||
let
|
|
||||||
keep-directory-diff = pkgs.callPackage ./nix/keep-directory-diff.nix { };
|
|
||||||
limine = pkgs.callPackage ./nix/build.nix {
|
|
||||||
inherit keep-directory-diff;
|
|
||||||
# TODO: Remove once 24.05 (which has pkgs.limine) is released.
|
|
||||||
limine = nixpkgs-unstable.legacyPackages.${pkgs.system}.limine;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
devShells = {
|
devShells = {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
@ -66,12 +58,6 @@
|
|||||||
|
|
||||||
# `$ nix fmt`
|
# `$ nix fmt`
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
formatter = pkgs.nixpkgs-fmt;
|
||||||
|
|
||||||
# `$ nix build .#<attr>`
|
|
||||||
packages = {
|
|
||||||
inherit limine;
|
|
||||||
default = limine;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
122
nix/build.nix
122
nix/build.nix
@ -1,122 +0,0 @@
|
|||||||
# Building Limine with all features in Nix.
|
|
||||||
#
|
|
||||||
# Independent of the packing in nixpkgs, This is convenient for prototyping and
|
|
||||||
# local development.
|
|
||||||
#
|
|
||||||
# These derivations always builds Limine from the current src tree and not some
|
|
||||||
# stable release. Further, unlike the nixpkgs derivation, this derivation runs
|
|
||||||
# the ./bootstrap step which needs network access. Due to the nature of the
|
|
||||||
# self-hacked Git submodules download approach, packaging this project in Nix
|
|
||||||
# is especially complicated. The complicated multi-derivation approach below
|
|
||||||
# is the best I can get after multiple hours of trying. :).
|
|
||||||
|
|
||||||
{
|
|
||||||
# Helpers
|
|
||||||
fd
|
|
||||||
, keep-directory-diff
|
|
||||||
, limine # derivation from nixpkgs
|
|
||||||
, nix-gitignore
|
|
||||||
, stdenv
|
|
||||||
|
|
||||||
# Actual derivation dependencies.
|
|
||||||
, autoconf
|
|
||||||
, automake
|
|
||||||
, cacert
|
|
||||||
, git
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
|
||||||
# The actual current source but close to the repo state, i.e., no files from
|
|
||||||
# the bootstrap step.
|
|
||||||
currentRepoSrc = nix-gitignore.gitignoreSource [
|
|
||||||
# Additional git ignores:
|
|
||||||
"flake.nix"
|
|
||||||
"flake.lock"
|
|
||||||
"nix/"
|
|
||||||
] ../.;
|
|
||||||
|
|
||||||
# Contains the sources downloaded by the Git submodule-like initialation done
|
|
||||||
# in ./bootstrap.
|
|
||||||
#
|
|
||||||
# ALWAYS update the hash when one of the network dependencies in ./bootstrap
|
|
||||||
# changes.
|
|
||||||
# bootstrappedSrcHash = lib.fakeHash;
|
|
||||||
bootstrappedSrcHash = "sha256-uggy1cDftq0tPD777hS+rz2oBnP2Q2AQ9xHdM8QhBQQ=";
|
|
||||||
|
|
||||||
# The full accumulated source tree to build Limine from.
|
|
||||||
bootstrappedSrc = stdenv.mkDerivation {
|
|
||||||
pname = "limine-src-bootstrapped";
|
|
||||||
version = "0.0.0";
|
|
||||||
src = currentRepoSrc;
|
|
||||||
nativeBuildInputs = [
|
|
||||||
cacert
|
|
||||||
fd
|
|
||||||
git
|
|
||||||
keep-directory-diff
|
|
||||||
];
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
|
|
||||||
# `true` refers to the binary/bash-builtin to prevent any configuration
|
|
||||||
# steps apart from downloading sources.
|
|
||||||
AUTOMAKE=true AUTORECONF=true ./bootstrap
|
|
||||||
|
|
||||||
keep-directory-diff ${currentRepoSrc} .
|
|
||||||
|
|
||||||
# When cloning, Git automatically creates hooks. Unfortunately, in a Nix
|
|
||||||
# environment / on a NixOS system, this includes Nix store paths.
|
|
||||||
# However, me must prevent to have any Nix store path inside the final
|
|
||||||
# directory, as otherwise we get the error
|
|
||||||
# "illegal path references in fixed-output derivation"! Further, we must
|
|
||||||
# remove all git artifacts (.git dirs) as they affect the hash of the
|
|
||||||
# derivation in a non-deterministic way.
|
|
||||||
fd -u --type=d "^.git$" --min-depth=2 . --exec rm -rf {}
|
|
||||||
|
|
||||||
# This should report nothing. Otherwise, the Nix build will fail.
|
|
||||||
# grep -r /nix/store .
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
dontPatchShebangs = true;
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
mkdir $out
|
|
||||||
|
|
||||||
cp -r . $out
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
doCheck = false;
|
|
||||||
dontFixup = true;
|
|
||||||
# See "fixed output derivation".
|
|
||||||
outputHashAlgo = "sha256";
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
outputHash = bootstrappedSrcHash;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
# Reuse the build-derivation from nixpkgs but with the current repo source.
|
|
||||||
limine.overrideAttrs({
|
|
||||||
pname = "limine-dev";
|
|
||||||
version = "0.0.0";
|
|
||||||
src = bootstrappedSrc;
|
|
||||||
nativeBuildInputs = [ autoconf automake ] ++ limine.nativeBuildInputs;
|
|
||||||
preConfigure = ''
|
|
||||||
# The default input source of this derivation is what we aggregated
|
|
||||||
# from `./bootstrap`. As this derivation holds all files but we are only
|
|
||||||
# interested in the ones that are not in `currentRepoSrc`, we just
|
|
||||||
# override all.
|
|
||||||
#
|
|
||||||
# This way we can use the actual current repo sources but still use the
|
|
||||||
# populated sources from the ./bootstrap script.
|
|
||||||
#
|
|
||||||
# It's very complicated, I know. But that way we can make it work, at
|
|
||||||
# least.
|
|
||||||
cp -RTf ${currentRepoSrc} .
|
|
||||||
|
|
||||||
# Extracted from ./bootstrap. To see why, check the `bootstrapedSrc`
|
|
||||||
# derivation.
|
|
||||||
#
|
|
||||||
# TODO, we could also do this in ./bootstrap but add a special flag.
|
|
||||||
autoreconf -fvi -Wall
|
|
||||||
'';
|
|
||||||
})
|
|
@ -1,55 +0,0 @@
|
|||||||
{ ansi
|
|
||||||
, argc
|
|
||||||
, fd
|
|
||||||
, lib
|
|
||||||
, writeShellScriptBin
|
|
||||||
}:
|
|
||||||
|
|
||||||
writeShellScriptBin "keep-directory-diff" ''
|
|
||||||
# The following @-annotations belong to https://github.com/sigoden/argc
|
|
||||||
#
|
|
||||||
# @describe
|
|
||||||
# This script takes two directories. The first directory is the base source.
|
|
||||||
# The second is the base source plus potentially additional or modified
|
|
||||||
# sources. It removes all files from the second directory that are unchanged
|
|
||||||
# in the first directory. The use case is to get the actual difference that
|
|
||||||
# preparation scripts of a source tree cause, such as through downloading
|
|
||||||
# certain resources into the tree.
|
|
||||||
#
|
|
||||||
# Only file content is checked, not file attributes. Symlinks are ignored.
|
|
||||||
#
|
|
||||||
# @arg base! Base directory
|
|
||||||
# Path to source directory
|
|
||||||
# @arg target! Target directory
|
|
||||||
# Path to target directory. This directory is modified.
|
|
||||||
|
|
||||||
# Bash strict mode.
|
|
||||||
set -eou pipefail
|
|
||||||
|
|
||||||
export PATH="${lib.makeBinPath([
|
|
||||||
ansi
|
|
||||||
argc
|
|
||||||
fd
|
|
||||||
])
|
|
||||||
}:$PATH"
|
|
||||||
|
|
||||||
# Do the "argc" magic. Reference: https://github.com/sigoden/argc
|
|
||||||
eval "$(argc --argc-eval "$0" "$@")"
|
|
||||||
|
|
||||||
# Find directories and regular files, don't follow symlinks.
|
|
||||||
readarray -d "" BASE_FILES < <(cd "$argc_base" && fd --unrestricted --print0 --type file)
|
|
||||||
|
|
||||||
for FILE in "''${BASE_FILES[@]}"; do
|
|
||||||
# Check if the content of the file was changed.
|
|
||||||
TARGET_FILE=$(realpath "$argc_target/$FILE" --relative-to=$PWD)
|
|
||||||
FILE=$(realpath "$argc_base/$FILE" --relative-to=$PWD)
|
|
||||||
echo -e "base file : $(ansi bold)$FILE$(ansi reset)"
|
|
||||||
echo -e "target file: $(ansi bold)$TARGET_FILE$(ansi reset)"
|
|
||||||
if cmp -s "$FILE" "$TARGET_FILE"; then
|
|
||||||
echo -e "Removing $(ansi bold)$TARGET_FILE$(ansi reset) as it hasn't changed."
|
|
||||||
rm -f "$TARGET_FILE"
|
|
||||||
else
|
|
||||||
echo -e "Keeping $(ansi bold)$TARGET_FILE$(ansi reset) as it was modified"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
''
|
|
Loading…
x
Reference in New Issue
Block a user