liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e29d009b2fc478314d9315a6844336f92e64f658
parent a7e54c087ca73479d8473a508210a1f8907946a5
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 25 Sep 2022 22:02:45 +0100

make kernel builder callPackage'able

Diffstat:
Mdefault.nix | 4+++-
Akernel/default.nix | 43+++++++++++++++++++++++++++++++++++++++++++
Rmake-vmlinux.nix -> kernel/vmlinux.nix | 0
Dmake-kernel.nix | 29-----------------------------
4 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/default.nix b/default.nix @@ -16,7 +16,9 @@ let ; }; squashfs = (import ./make-image.nix) nixpkgs finalConfig; - kernel = (import ./make-kernel.nix) nixpkgs finalConfig.kernel.config; + kernel = nixpkgs.pkgs.callPackage ./kernel { + inherit (finalConfig.kernel) config; + }; in { outputs = { inherit squashfs kernel; diff --git a/kernel/default.nix b/kernel/default.nix @@ -0,0 +1,43 @@ +{ + callPackage +, buildPackages +, stdenvNoCC +, fetchFromGitHub + +, config +}: +let + source = fetchFromGitHub { + owner = "torvalds"; + repo = "linux"; + rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19 + hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4="; + }; + + # The kernel is huge and takes a long time just to + # download and unpack. This derivation creates + # a source tree in a suitable shape to build from - + # today it just patches some scripts but as we add + # support for boards/SoCs we expect the scope of + # "pre-treatment" to grow + + tree = stdenvNoCC.mkDerivation { + name = "spindled-kernel-tree"; + src = source; + phases = [ "unpackPhase" "patchScripts" "installPhase" ]; + patchScripts = '' + patchShebangs scripts/ + # substituteInPlace Makefile --replace /bin/pwd ${buildPackages.pkgs.coreutils}/bin/pwd + ''; + installPhase = '' + mkdir -p $out + cp -a . $out + ''; + }; +in +{ + vmlinux = callPackage ./vmlinux.nix { + inherit tree; + inherit config; + }; +} diff --git a/make-vmlinux.nix b/kernel/vmlinux.nix diff --git a/make-kernel.nix b/make-kernel.nix @@ -1,29 +0,0 @@ -pkgs: config: -let - inherit (pkgs) callPackage buildPackages stdenvNoCC fetchFromGitHub; - source = fetchFromGitHub { - owner = "torvalds"; - repo = "linux"; - rev = "3d7cb6b04c3f3115719235cc6866b10326de34cd"; # v5.19 - hash = "sha256-OVsIRScAnrPleW1vbczRAj5L/SGGht2+GnvZJClMUu4="; - }; - tree = stdenvNoCC.mkDerivation { - name = "spindled-kernel-tree"; - src = source; - phases = [ "unpackPhase" "patchScripts" "installPhase" ]; - patchScripts = '' - patchShebangs scripts/ - # substituteInPlace Makefile --replace /bin/pwd ${buildPackages.pkgs.coreutils}/bin/pwd - ''; - installPhase = '' - mkdir -p $out - cp -a . $out - ''; - }; -in -{ - vmlinux = callPackage ./make-vmlinux.nix { - inherit tree; - inherit config; - }; -}