diff options
Diffstat (limited to 'modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix')
-rw-r--r-- | modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix b/modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix index abcd9963d02f..4696a6f1af69 100644 --- a/modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix +++ b/modules/nixos-apple-silicon/apple-silicon-support/packages/linux-asahi/default.nix @@ -11,24 +11,41 @@ }: let - # parse <OPT> (y|m|n) style configuration as found in a patch's extraConfig + i = builtins.elemAt; + + # parse <OPT> [ymn]|foo style configuration as found in a patch's extraConfig # into a list of k, v tuples parseExtraConfig = config: let lines = builtins.filter (s: s != "") (lib.strings.splitString "\n" config); - parseLine = line: - let t = lib.strings.splitString " " line; - in assert (builtins.length t == 2); t; + parseLine = line: let + t = lib.strings.splitString " " line; + join = l: builtins.foldl' (a: b: "${a} ${b}") + (builtins.head l) (builtins.tail l); + v = if (builtins.length t) > 2 then join (builtins.tail t) else (i t 1); + in [ "CONFIG_${i t 0}" v ]; in map parseLine lines; - # parse CONFIG_<OPT>=(y|m|n) style configuration as found in a config file + # parse <OPT>=lib.kernel.(yes|module|no)|lib.kernel.freeform "foo" + # style configuration as found in a patch's extraStructuredConfig into + # a list of k, v tuples + parseExtraStructuredConfig = config: lib.attrsets.mapAttrsToList + (k: v: [ "CONFIG_${k}" (v.tristate or v.freeform) ] ) config; + + parsePatchConfig = { extraConfig ? "", extraStructuredConfig ? {}, ... }: + (parseExtraConfig extraConfig) ++ + (parseExtraStructuredConfig extraStructuredConfig); + + # parse CONFIG_<OPT>=[ymn]|"foo" style configuration as found in a config file # into a list of k, v tuples parseConfig = config: let - parseLine = builtins.match "(CONFIG_[[:upper:][:digit:]_]+)=(y|m|n)"; + parseLine = builtins.match ''(CONFIG_[[:upper:][:digit:]_]+)=(([ymn])|"([^"]*)")''; + # get either the [ymn] option or the "foo" option; whichever matched + t = l: let v = (i l 2); in [ (i l 0) (if v != null then v else (i l 3)) ]; lines = lib.strings.splitString "\n" config; - in builtins.filter (t: t != null) (map parseLine lines); + in map t (builtins.filter (l: l != null) (map parseLine lines)); origConfigfile = ./config; @@ -38,10 +55,13 @@ let origConfigText = builtins.readFile origConfigfile; # extraConfig from all patches in order - extraConfig = lib.fold (patch: ex: ex ++ - (parseExtraConfig (patch.extraConfig or ""))) [] _kernelPatches; + extraConfig = + lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [] _kernelPatches; # config file text for above - extraConfigText = (map (t: "CONFIG_${builtins.elemAt t 0}=${builtins.elemAt t 1}") extraConfig); + extraConfigText = let + text = k: v: if (v == "y") || (v == "m") || (v == "n") + then "${k}=${v}" else ''${k}="${v}"''; + in (map (t: text (i t 0) (i t 1)) extraConfig); # final config as a text file path configfile = if extraConfig == [] then origConfigfile else @@ -53,9 +73,9 @@ let ''; # final config as an attrset config = let - makePair = t: lib.nameValuePair (builtins.elemAt t 0) (builtins.elemAt t 1); + makePair = t: lib.nameValuePair (i t 0) (i t 1); configList = (parseConfig origConfigText) ++ extraConfig; - in builtins.listToAttrs (map makePair configList); + in builtins.listToAttrs (map makePair (lib.lists.reverseList configList)); # used to (ostensibly) keep compatibility for those running stable versions of nixos rustOlder = version: withRust && (lib.versionOlder rustc.version version); @@ -68,15 +88,16 @@ let (linuxKernel.manualConfig rec { inherit stdenv lib; - version = "6.4.0-asahi"; + version = "6.5.0-asahi"; modDirVersion = version; + extraMeta.branch = "6.5"; src = fetchFromGitHub { # tracking: https://github.com/AsahiLinux/PKGBUILDs/blob/main/linux-asahi/PKGBUILD owner = "AsahiLinux"; repo = "linux"; - rev = "asahi-6.4-10"; - hash = "sha256-PUuQcqcQy7digMb0VwO5AVpAC8cA2WsTR6xDhGtL/pY="; + rev = "asahi-6.5-15"; + hash = "sha256-Rruk/Nrw425XerZjgDJ4PJ3c63CCycch1qz7vFxHPCE="; }; kernelPatches = [ @@ -98,23 +119,9 @@ let { name = "default-pagesize-16k"; patch = ./default-pagesize-16k.patch; } - ] ++ lib.optionals (bindgenAtLeast "0.63.0") [ - { name = "rust-bindgen"; - patch = ./rust-bindgen-0.63-fix.patch; - } - ] ++ lib.optionals (bindgenAtLeast "0.65.0") [ - { name = "rust-bindgen"; - patch = ./rust-bindgen-0.65-fix.patch; - } - ] ++ lib.optionals (rustAtLeast "1.72.0") [ - { name = "rustc-1.72.0"; - patch = ./rustc-1.72.0-fix.patch; - } ] ++ _kernelPatches; inherit configfile config; - - extraMeta.branch = "6.4"; } // (args.argsOverride or {})).overrideAttrs (old: if withRust then { nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ rust-bindgen |