forked from tiiuae/ghaf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor kernel devshell, add jetson orin kernel
Signed-off-by: Alexander Nikolaev <[email protected]>
- Loading branch information
1 parent
6894e0b
commit 4756f0f
Showing
5 changed files
with
69 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{inputs, ...}: { | ||
perSystem = { | ||
pkgs, | ||
self', | ||
system, | ||
... | ||
}: let | ||
mkKernelShell = { | ||
platform, | ||
linux, | ||
extraPackages ? [], | ||
shellHook ? "", | ||
}: | ||
pkgs.mkShell { | ||
name = "Kernel-${platform} devshell"; | ||
packages = with pkgs; | ||
[ | ||
ncurses | ||
pkg-config | ||
self'.packages.kernel-hardening-checker | ||
] | ||
++ extraPackages; | ||
|
||
inputsFrom = [linux]; | ||
|
||
shellHook = '' | ||
export src=${linux.src} | ||
if [ -d "$src" ]; then | ||
# Jetpack's kernel named "source-patched" or likewise, workaround it | ||
linuxDir=$(stripHash ${linux.src}) | ||
else | ||
linuxDir="linux-${linux.version}" | ||
fi | ||
if [ ! -d "$linuxDir" ]; then | ||
unpackPhase | ||
patchPhase | ||
fi | ||
cd "$linuxDir" | ||
# extra post-patching for NVidia | ||
${shellHook} | ||
export PS1="[ghaf-kernel-${platform}-devshell:\w]$ " | ||
''; | ||
# use "eval $checkPhase" - see https://discourse.nixos.org/t/nix-develop-and-checkphase/25707 | ||
checkPhase = "cp ../modules/host/ghaf_host_hardened_baseline-${platform} ./.config && make -j$(nproc)"; | ||
}; | ||
in { | ||
devShells.kernel-x86 = mkKernelShell { | ||
platform = "x86"; | ||
linux = pkgs.linux_latest; | ||
}; | ||
devShells.kernel-jetson-orin = mkKernelShell { | ||
platform = "jetson-orin"; | ||
linux = inputs.jetpack-nixos.legacyPackages.${system}.kernel; | ||
extraPackages = [pkgs.gawk]; | ||
shellHook = '' | ||
patchShebangs scripts/ | ||
''; | ||
}; | ||
}; | ||
} |