diff options
author | Julian Stecklina <js@alien8.de> | 2024-03-30 19:46:42 +0100 |
---|---|---|
committer | Julian Stecklina <js@alien8.de> | 2024-03-31 00:15:13 +0100 |
commit | 9c864184b07fbd9dc4781404f7128e32e4c41ee0 (patch) | |
tree | ad016c6ddf989277a8e33029dcaac377f0e6ea39 | |
parent | 05fbd4f228a1bfd551e5b0825f02b53814b3504d (diff) |
Add tool for checking out Linux sources
-rw-r--r-- | flake.nix | 32 | ||||
-rw-r--r-- | tools.nix | 21 | ||||
-rw-r--r-- | tools/linux-checkout | 39 |
3 files changed, 86 insertions, 6 deletions
@@ -28,7 +28,11 @@ let pkgs = nixpkgs.legacyPackages."${system}"; - linuxCommonDependencies = with pkgs; [ + kernelDevTools = pkgs.callPackage ./tools.nix {}; + + linuxCommonDependencies = [ + kernelDevTools + ] ++ (with pkgs; [ gnumake perl bison @@ -49,13 +53,15 @@ kmod ubootTools - llvmPackages.bintools - llvmPackages.clang - llvmPackages.llvm - # For make menuconfig ncurses - ]; + + # For make gtags + global + + # For git send-email 🫠+ gitFull + ]); rust-analyzer = fenix.packages."${system}".rust-analyzer; @@ -86,6 +92,10 @@ devShells.linux_6_8 = pkgs.mkShell { packages = [ + pkgs.llvmPackages.bintools + pkgs.llvmPackages.llvm + pkgs.llvmPackages.clang + rustc_1_76 rust-bindgen_0_65_1 rust-analyzer @@ -99,6 +109,16 @@ # kernel will take care of itself. NIX_HARDENING_ENABLE = ""; }; + + devShells.linux_6_8_gcc = pkgs.mkShell { + packages = [ + pkgs.gcc + ] ++ linuxCommonDependencies; + + # Disable all automatically applied hardening. The Linux + # kernel will take care of itself. + NIX_HARDENING_ENABLE = ""; + }; } ); } diff --git a/tools.nix b/tools.nix new file mode 100644 index 0000000..5f90e27 --- /dev/null +++ b/tools.nix @@ -0,0 +1,21 @@ +{ stdenvNoCC }: +stdenvNoCC.mkDerivation { + name = "kernel-dev-tools"; + + src = ./tools; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + + for script in *; do + install -m0555 "$script" $out/bin/ + done + + runHook preInstall + ''; +} diff --git a/tools/linux-checkout b/tools/linux-checkout new file mode 100644 index 0000000..7069f07 --- /dev/null +++ b/tools/linux-checkout @@ -0,0 +1,39 @@ +#!/bin/sh + +set -eu + +if [ $# -ne 1 ]; then + echo "Usage: $0 output-directory" 1>&2 + echo + echo "Check out a Linux development tree and populates it with typical remotes." + exit 1 +fi + +OUTDIR=$1 + +if [ -e "$OUTDIR" ]; then + echo "$OUTDIR already exists. Bailing out." 1>&2 + exit 1 +fi + +mkdir -p "$OUTDIR" + +pushd "$OUTDIR" + +git init --initial-branch=torvalds + +git remote add torvalds https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git +git remote add stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git +git remote add rust-for-linux https://github.com/Rust-for-Linux/linux.git +git remote add kvm https://git.kernel.org/pub/scm/virt/kvm/kvm.git +# Add new remotes here. + +echo "Fetching all remotes. This will take a while." +git fetch --all + +git merge --ff-only torvalds/master + +# Reduces the size of the repo a lot. +git gc --aggressive --prune=now + +popd |