init (podpierdolenie)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
From 0fcdbacd8b06c24f5761a0cf9cb0c43cad05c19b Mon Sep 17 00:00:00 2001
|
||||
From: Thomas Watson <twatson52@icloud.com>
|
||||
Date: Mon, 26 Feb 2024 19:51:12 -0600
|
||||
Subject: [PATCH] fs/fcntl: accept more values as F_DUPFD_CLOEXEC args
|
||||
|
||||
libwebrtc doesn't pass anything as the arg to this function so the
|
||||
minimum fd ends up as random garbage. If it's bigger than the maximum
|
||||
fd, which is likely, then the duplication fails, and libwebrtc breaks.
|
||||
|
||||
The previous patch (081abc5fa701738699705a6c0a41c824df77cb37) rejects
|
||||
args >= 1024 (the default soft max fd) and instead subtitutes a minimum
|
||||
fd of 0 to allow such requests to succeed.
|
||||
|
||||
However, gnulib's test suite can pass the following values and expects
|
||||
them to fail; this patch prevents those from succeeding:
|
||||
* -1 (hard-coded)
|
||||
* 1024 (`ulimit -n` value by default)
|
||||
* 1048576 (`ulimit -n` value in Nix build sandbox)
|
||||
|
||||
Hopefully the garbage values libwebrtc passes do not match very often.
|
||||
---
|
||||
fs/fcntl.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/fs/fcntl.c b/fs/fcntl.c
|
||||
index f18f87419445..65a6861476ec 100644
|
||||
--- a/fs/fcntl.c
|
||||
+++ b/fs/fcntl.c
|
||||
@@ -326,7 +326,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
|
||||
err = f_dupfd(argi, filp, 0);
|
||||
break;
|
||||
case F_DUPFD_CLOEXEC:
|
||||
- if (arg >= 1024)
|
||||
+ if ((arg > 1024) && (argi != 1048576) && (argi != -1))
|
||||
argi = 0; /* Lol libwebrtc */
|
||||
err = f_dupfd(argi, filp, O_CLOEXEC);
|
||||
break;
|
||||
--
|
||||
2.43.0
|
||||
|
||||
7849
modules/apple-silicon-support/packages/linux-asahi/config
Normal file
7849
modules/apple-silicon-support/packages/linux-asahi/config
Normal file
File diff suppressed because it is too large
Load Diff
165
modules/apple-silicon-support/packages/linux-asahi/default.nix
Normal file
165
modules/apple-silicon-support/packages/linux-asahi/default.nix
Normal file
@@ -0,0 +1,165 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
callPackage,
|
||||
writeShellScriptBin,
|
||||
writeText,
|
||||
linuxPackagesFor,
|
||||
withRust ? false,
|
||||
_kernelPatches ? [],
|
||||
}: let
|
||||
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;
|
||||
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 <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:]_]+)=(([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
|
||||
map t (builtins.filter (l: l != null) (map parseLine lines));
|
||||
|
||||
origConfigfile = ./config;
|
||||
|
||||
linux-asahi-pkg = {
|
||||
stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
linuxKernel,
|
||||
rustPlatform,
|
||||
rustc,
|
||||
rustfmt,
|
||||
rust-bindgen,
|
||||
...
|
||||
} @ args: let
|
||||
origConfigText = builtins.readFile origConfigfile;
|
||||
|
||||
# extraConfig from all patches in order
|
||||
extraConfig =
|
||||
lib.fold (patch: ex: ex ++ (parsePatchConfig patch)) [] _kernelPatches;
|
||||
# config file text for above
|
||||
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
|
||||
writeText "config" ''
|
||||
${origConfigText}
|
||||
|
||||
# Patches
|
||||
${lib.strings.concatStringsSep "\n" extraConfigText}
|
||||
'';
|
||||
# final config as an attrset
|
||||
configAttrs = let
|
||||
makePair = t: lib.nameValuePair (i t 0) (i t 1);
|
||||
configList = (parseConfig origConfigText) ++ extraConfig;
|
||||
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);
|
||||
bindgenOlder = version: withRust && (lib.versionOlder rust-bindgen.unwrapped.version version);
|
||||
|
||||
# used to fix issues when nixpkgs gets ahead of the kernel
|
||||
rustAtLeast = version: withRust && (lib.versionAtLeast rustc.version version);
|
||||
bindgenAtLeast = version: withRust && (lib.versionAtLeast rust-bindgen.unwrapped.version version);
|
||||
in
|
||||
(linuxKernel.manualConfig rec {
|
||||
inherit stdenv lib;
|
||||
|
||||
version = "6.9.12-asahi";
|
||||
modDirVersion = version;
|
||||
extraMeta.branch = "6.9";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
# tracking: https://github.com/AsahiLinux/linux/tree/asahi-wip (w/ fedora verification)
|
||||
owner = "AsahiLinux";
|
||||
repo = "linux";
|
||||
rev = "asahi-6.9.12-1";
|
||||
hash = "sha256-LCMrG+RVONK/eIvygRExaVvY/ATV3IfvSsFbVsHVu48=";
|
||||
};
|
||||
|
||||
kernelPatches =
|
||||
[
|
||||
{
|
||||
name = "coreutils-fix";
|
||||
patch = ./0001-fs-fcntl-accept-more-values-as-F_DUPFD_CLOEXEC-args.patch;
|
||||
}
|
||||
]
|
||||
++ _kernelPatches;
|
||||
|
||||
inherit configfile;
|
||||
# hide Rust support from the nixpkgs infra to avoid it re-adding the rust packages.
|
||||
# we can't use it until it's in stable and until we've evaluated the cross-compilation impact.
|
||||
config = configAttrs // {"CONFIG_RUST" = "n";};
|
||||
}
|
||||
// (args.argsOverride or {}))
|
||||
.overrideAttrs (old:
|
||||
if withRust
|
||||
then {
|
||||
nativeBuildInputs =
|
||||
(old.nativeBuildInputs or [])
|
||||
++ [
|
||||
rust-bindgen
|
||||
rustfmt
|
||||
rustc
|
||||
];
|
||||
RUST_LIB_SRC = rustPlatform.rustLibSrc;
|
||||
}
|
||||
else {});
|
||||
|
||||
linux-asahi = callPackage linux-asahi-pkg {};
|
||||
in
|
||||
lib.recurseIntoAttrs (linuxPackagesFor linux-asahi)
|
||||
Reference in New Issue
Block a user