ps4nixos/kernel/kernel-aeolia-prebuilt.nix

67 lines
2.2 KiB
Nix
Raw Normal View History

{ lib, stdenvNoCC, runCommand, fetchurl, fetchFromGitHub, ... }:
let
src = fetchFromGitHub {
owner = "ps4boot";
repo = "ps4-linux";
rev = "refs/heads/aeolia";
hash = "sha256-urNDgnoGC76WYvzAlypCJ+w8IIsPcN2kQMzlYF/h+mo=";
};
bzImage = fetchurl {
url = "https://github.com/ps4boot/ps4-linux/releases/download/v1/bzImageAeolia";
hash = "sha256-0P02KJe8OCuliHjjkJqlPXQBHDuEGLUIp78lWa5hYdw=";
};
# parse the configfile into a nix attrset
# from https://github.com/NixOS/nixpkgs/blob/a253c2d94cbf75cfd0f7eea242d8385214332dda/pkgs/os-specific/linux/kernel/manual-config.nix#L11
parseConfig = configfile: import (runCommand "config.nix" {} ''
echo "{" > "$out"
while IFS='=' read key val; do
[ "x''${key#CONFIG_}" != "x$key" ] || continue
no_firstquote="''${val#\"}";
echo ' "'"$key"'" = "'"''${no_firstquote%\"}"'";' >> "$out"
done < "${configfile}"
echo "}" >> $out
'').outPath;
# make a hacky wrapper around the bzImage so it's
# compatible with the nixos module system
# kernelFn = { ... }:
# runCommand "kernel-aeolia-prebuilt" {
# version = "5.3.18";
# config = parseConfig "${src}/config";
# } ''
# mkdir $out
# cp ${bzImage} $out/bzImage
# '';
in
stdenvNoCC.mkDerivation {
name = "kernel-aeolia-prebuilt";
dontUnpack = true;
installPhase = ''
mkdir $out
cp ${bzImage} $out/bzImage
'';
passthru = {
version = "5.3.18";
# functions for checking config options
# from https://github.com/NixOS/nixpkgs/blob/a253c2d94cbf75cfd0f7eea242d8385214332dda/pkgs/os-specific/linux/kernel/manual-config.nix#L98
config = let
config = parseConfig "${src}/config";
attrName = attr: "CONFIG_" + attr;
in rec {
isSet = attr: builtins.hasAttr (attrName attr) config;
getValue = attr: if isSet attr then builtins.getAttr (attrName attr) config else null;
isYes = attr: (getValue attr) == "y";
isNo = attr: (getValue attr) == "n";
isModule = attr: (getValue attr) == "m";
isEnabled = attr: (isModule attr) || (isYes attr);
isDisabled = attr: (!(isSet attr)) || (isNo attr);
} // config;
};
}
# lib.makeOverridable kernelFn {}