Compare commits
No commits in common. "622a13f84259bf70629742aad193ee2edc18c8c1" and "37e0b534ab4d64c3de7d20829ed55f1c9321f1a7" have entirely different histories.
622a13f842
...
37e0b534ab
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
**/*.bak
|
|
@ -7,8 +7,6 @@
|
|||||||
{
|
{
|
||||||
# Bootloader.
|
# Bootloader.
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
|
||||||
nix.settings.extra-experimental-features = [ "nix-command" "flakes" ];
|
|
||||||
|
|
||||||
# Enable networking
|
# Enable networking
|
||||||
networking.networkmanager.enable = true;
|
networking.networkmanager.enable = true;
|
||||||
@ -37,12 +35,10 @@
|
|||||||
|
|
||||||
# Enable the X11 windowing system.
|
# Enable the X11 windowing system.
|
||||||
services.xserver = {
|
services.xserver = {
|
||||||
enable = true;
|
|
||||||
xkb = {
|
|
||||||
layout = "us";
|
layout = "us";
|
||||||
variant = "";
|
enable = true;
|
||||||
options = "caps_lock:esc";
|
xkbVariant = "";
|
||||||
};
|
xkbOptions = "caps_lock:esc";
|
||||||
videoDrivers = [
|
videoDrivers = [
|
||||||
# "displaylink" # broken
|
# "displaylink" # broken
|
||||||
"modesetting"
|
"modesetting"
|
||||||
|
105
flake.lock
105
flake.lock
@ -1,127 +1,46 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"apple-silicon": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-compat": "flake-compat",
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"rust-overlay": "rust-overlay"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1709186902,
|
|
||||||
"narHash": "sha256-0gMwtZDBSJEG23R/84XRLJNydRCwOYAg6ola2bYqSv8=",
|
|
||||||
"owner": "tpwrules",
|
|
||||||
"repo": "nixos-apple-silicon",
|
|
||||||
"rev": "9ccf1cb93bdaa96294598bef8a7ffaa72226b0fb",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "tpwrules",
|
|
||||||
"repo": "nixos-apple-silicon",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-compat": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1688025799,
|
|
||||||
"narHash": "sha256-ktpB4dRtnksm9F5WawoIkEneh1nrEvuxb5lJFt1iOyw=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "flake-compat",
|
|
||||||
"rev": "8bf105319d44f6b9f0d764efa4fdef9f1cc9ba1c",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "flake-compat",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"home-manager": {
|
"home-manager": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1709204054,
|
"lastModified": 1706981411,
|
||||||
"narHash": "sha256-U1idK0JHs1XOfSI1APYuXi4AEADf+B+ZU4Wifc0pBHk=",
|
"narHash": "sha256-cLbLPTL1CDmETVh4p0nQtvoF+FSEjsnJTFpTxhXywhQ=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "2f3367769a93b226c467551315e9e270c3f78b15",
|
"rev": "652fda4ca6dafeb090943422c34ae9145787af37",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
|
"ref": "release-23.11",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1708984720,
|
"lastModified": 1701282334,
|
||||||
"narHash": "sha256-gJctErLbXx4QZBBbGp78PxtOOzsDaQ+yw1ylNQBuSUY=",
|
"narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
|
"rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"ref": "23.11",
|
||||||
"rev": "13aff9b34cc32e59d35c62ac9356e4a41198a538",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1708118438,
|
|
||||||
"narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1709237383,
|
|
||||||
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"apple-silicon": "apple-silicon",
|
|
||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-overlay": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1686795910,
|
|
||||||
"narHash": "sha256-jDa40qRZ0GRQtP9EMZdf+uCbvzuLnJglTUI2JoHfWDc=",
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"rev": "5c2b97c0a9bc5217fc3dfb1555aae0fb756d99f9",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "oxalica",
|
|
||||||
"repo": "rust-overlay",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
14
flake.nix
14
flake.nix
@ -1,14 +1,10 @@
|
|||||||
{
|
{
|
||||||
description = "NixOS configuration with Home Manager";
|
description = "NixOS configuration with Home Manager";
|
||||||
inputs = {
|
inputs = {
|
||||||
# nixpkgs.url = "github:nixos/nixpkgs/23.11";
|
nixpkgs.url = "github:nixos/nixpkgs/23.11";
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
||||||
apple-silicon = {
|
|
||||||
url = "github:tpwrules/nixos-apple-silicon";
|
|
||||||
};
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
url = "github:nix-community/home-manager"; #/release-23.11";
|
url = "github:nix-community/home-manager/release-23.11";
|
||||||
# inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = inputs@{ nixpkgs, home-manager, ... }: {
|
outputs = inputs@{ nixpkgs, home-manager, ... }: {
|
||||||
@ -16,15 +12,15 @@
|
|||||||
galvatron = nixpkgs.lib.nixosSystem {
|
galvatron = nixpkgs.lib.nixosSystem {
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
modules = [
|
modules = [
|
||||||
|
# ./galvatron/configuration.nix {
|
||||||
./configuration.nix {
|
./configuration.nix {
|
||||||
hardware.asahi.peripheralFirmwareDirectory = ./galvatron/firmware;
|
hardware.asahi.peripheralFirmwareDirectory = ./galvatron/firmware;
|
||||||
hardware.asahi.useExperimentalGPUDriver = true;
|
|
||||||
boot.loader.efi.canTouchEfiVariables = false;
|
boot.loader.efi.canTouchEfiVariables = false;
|
||||||
networking.hostName = "galvatron";
|
networking.hostName = "galvatron";
|
||||||
sound.enable = false;
|
sound.enable = false;
|
||||||
}
|
}
|
||||||
./galvatron/hardware-configuration.nix
|
./galvatron/hardware-configuration.nix
|
||||||
inputs.apple-silicon.nixosModules.apple-silicon-support
|
./galvatron/apple-silicon-support
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
{
|
{
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
|
7
galvatron/apple-silicon-support/default.nix
Normal file
7
galvatron/apple-silicon-support/default.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./modules/default.nix
|
||||||
|
];
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
let
|
||||||
|
pkgs' = config.hardware.asahi.pkgs;
|
||||||
|
|
||||||
|
bootM1n1 = pkgs'.m1n1.override {
|
||||||
|
isRelease = true;
|
||||||
|
withTools = false;
|
||||||
|
customLogo = config.boot.m1n1CustomLogo;
|
||||||
|
};
|
||||||
|
|
||||||
|
bootUBoot = pkgs'.uboot-asahi.override {
|
||||||
|
m1n1 = bootM1n1;
|
||||||
|
};
|
||||||
|
|
||||||
|
bootFiles = {
|
||||||
|
"m1n1/boot.bin" = pkgs.runCommand "boot.bin" {} ''
|
||||||
|
cat ${bootM1n1}/build/m1n1.bin > $out
|
||||||
|
cat ${config.boot.kernelPackages.kernel}/dtbs/apple/*.dtb >> $out
|
||||||
|
cat ${bootUBoot}/u-boot-nodtb.bin.gz >> $out
|
||||||
|
if [ -n "${config.boot.m1n1ExtraOptions}" ]; then
|
||||||
|
echo '${config.boot.m1n1ExtraOptions}' >> $out
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
config = {
|
||||||
|
# install m1n1 with the boot loader
|
||||||
|
boot.loader.grub.extraFiles = bootFiles;
|
||||||
|
boot.loader.systemd-boot.extraFiles = bootFiles;
|
||||||
|
|
||||||
|
# ensure the installer has m1n1 in the image
|
||||||
|
system.extraDependencies = lib.mkForce [ bootM1n1 bootUBoot ];
|
||||||
|
system.build.m1n1 = bootFiles."m1n1/boot.bin";
|
||||||
|
};
|
||||||
|
|
||||||
|
options.boot = {
|
||||||
|
m1n1ExtraOptions = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Append extra options to the m1n1 boot binary. Might be useful for fixing
|
||||||
|
display problems on Mac minis.
|
||||||
|
https://github.com/AsahiLinux/m1n1/issues/159
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
m1n1CustomLogo = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Custom logo to build into m1n1. The path must point to a 256x256 PNG.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
62
galvatron/apple-silicon-support/modules/default.nix
Normal file
62
galvatron/apple-silicon-support/modules/default.nix
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./kernel
|
||||||
|
./mesa
|
||||||
|
./peripheral-firmware
|
||||||
|
./boot-m1n1
|
||||||
|
./sound
|
||||||
|
];
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
cfg = config.hardware.asahi;
|
||||||
|
in {
|
||||||
|
nixpkgs.overlays = lib.mkBefore [ cfg.overlay ];
|
||||||
|
|
||||||
|
hardware.asahi.pkgs =
|
||||||
|
if cfg.pkgsSystem != "aarch64-linux"
|
||||||
|
then
|
||||||
|
import (pkgs.path) {
|
||||||
|
crossSystem.system = "aarch64-linux";
|
||||||
|
localSystem.system = cfg.pkgsSystem;
|
||||||
|
overlays = [ cfg.overlay ];
|
||||||
|
}
|
||||||
|
else pkgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
options.hardware.asahi = {
|
||||||
|
pkgsSystem = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "aarch64-linux";
|
||||||
|
description = ''
|
||||||
|
System architecture that should be used to build the major Asahi
|
||||||
|
packages, if not the default aarch64-linux. This allows installing from
|
||||||
|
a cross-built ISO without rebuilding them during installation.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
pkgs = lib.mkOption {
|
||||||
|
type = lib.types.raw;
|
||||||
|
description = ''
|
||||||
|
Package set used to build the major Asahi packages. Defaults to the
|
||||||
|
ambient set if not cross-built, otherwise re-imports the ambient set
|
||||||
|
with the system defined by `hardware.asahi.pkgsSystem`.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
overlay = lib.mkOption {
|
||||||
|
type = lib.mkOptionType {
|
||||||
|
name = "nixpkgs-overlay";
|
||||||
|
description = "nixpkgs overlay";
|
||||||
|
check = lib.isFunction;
|
||||||
|
merge = lib.mergeOneOption;
|
||||||
|
};
|
||||||
|
default = import ../packages/overlay.nix;
|
||||||
|
defaultText = "overlay provided with the module";
|
||||||
|
description = ''
|
||||||
|
The nixpkgs overlay for asahi packages.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
107
galvatron/apple-silicon-support/modules/kernel/default.nix
Normal file
107
galvatron/apple-silicon-support/modules/kernel/default.nix
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# the Asahi Linux kernel and options that must go along with it
|
||||||
|
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
boot.kernelPackages = let
|
||||||
|
pkgs' = config.hardware.asahi.pkgs;
|
||||||
|
in
|
||||||
|
pkgs'.linux-asahi.override {
|
||||||
|
_kernelPatches = config.boot.kernelPatches;
|
||||||
|
_4KBuild = config.hardware.asahi.use4KPages;
|
||||||
|
withRust = config.hardware.asahi.withRust;
|
||||||
|
};
|
||||||
|
|
||||||
|
# we definitely want to use CONFIG_ENERGY_MODEL, and
|
||||||
|
# schedutil is a prerequisite for using it
|
||||||
|
# source: https://www.kernel.org/doc/html/latest/scheduler/sched-energy.html
|
||||||
|
powerManagement.cpuFreqGovernor = lib.mkOverride 800 "schedutil";
|
||||||
|
|
||||||
|
boot.initrd.includeDefaultModules = false;
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
# list of initrd modules stolen from
|
||||||
|
# https://github.com/AsahiLinux/asahi-scripts/blob/f461f080a1d2575ae4b82879b5624360db3cff8c/initcpio/install/asahi
|
||||||
|
"apple-mailbox"
|
||||||
|
"nvme_apple"
|
||||||
|
"pinctrl-apple-gpio"
|
||||||
|
"macsmc"
|
||||||
|
"macsmc-rtkit"
|
||||||
|
"i2c-apple"
|
||||||
|
"tps6598x"
|
||||||
|
"apple-dart"
|
||||||
|
"dwc3"
|
||||||
|
"dwc3-of-simple"
|
||||||
|
"xhci-pci"
|
||||||
|
"pcie-apple"
|
||||||
|
"gpio_macsmc"
|
||||||
|
"phy-apple-atc"
|
||||||
|
"nvmem_apple_efuses"
|
||||||
|
"spi-apple"
|
||||||
|
"spi-hid-apple"
|
||||||
|
"spi-hid-apple-of"
|
||||||
|
"rtc-macsmc"
|
||||||
|
"simple-mfd-spmi"
|
||||||
|
"spmi-apple-controller"
|
||||||
|
"nvmem_spmi_mfd"
|
||||||
|
"apple-dockchannel"
|
||||||
|
"dockchannel-hid"
|
||||||
|
"apple-rtkit-helper"
|
||||||
|
|
||||||
|
# additional stuff necessary to boot off USB for the installer
|
||||||
|
# and if the initrd (i.e. stage 1) goes wrong
|
||||||
|
"usb-storage"
|
||||||
|
"xhci-plat-hcd"
|
||||||
|
"usbhid"
|
||||||
|
"hid_generic"
|
||||||
|
];
|
||||||
|
|
||||||
|
boot.kernelParams = [
|
||||||
|
"earlycon"
|
||||||
|
"console=ttySAC0,115200n8"
|
||||||
|
"console=tty0"
|
||||||
|
"boot.shell_on_fail"
|
||||||
|
# Apple's SSDs are slow (~dozens of ms) at processing flush requests which
|
||||||
|
# slows down programs that make a lot of fsync calls. This parameter sets
|
||||||
|
# a delay in ms before actually flushing so that such requests can be
|
||||||
|
# coalesced. Be warned that increasing this parameter above zero (default
|
||||||
|
# is 1000) has the potential, though admittedly unlikely, risk of
|
||||||
|
# UNBOUNDED data corruption in case of power loss!!!! Don't even think
|
||||||
|
# about it on desktops!!
|
||||||
|
"nvme_apple.flush_interval=0"
|
||||||
|
];
|
||||||
|
|
||||||
|
# U-Boot does not support EFI variables
|
||||||
|
boot.loader.efi.canTouchEfiVariables = lib.mkForce false;
|
||||||
|
|
||||||
|
# U-Boot does not support switching console mode
|
||||||
|
boot.loader.systemd-boot.consoleMode = "0";
|
||||||
|
|
||||||
|
# GRUB has to be installed as removable if the user chooses to use it
|
||||||
|
boot.loader.grub = lib.mkDefault {
|
||||||
|
efiSupport = true;
|
||||||
|
efiInstallAsRemovable = true;
|
||||||
|
device = "nodev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./edge.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
options.hardware.asahi.use4KPages = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Build the Asahi Linux kernel with 4K pages to improve compatibility in
|
||||||
|
some cases at the cost of performance in others.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
options.hardware.asahi.withRust = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Build the Asahi Linux kernel with Rust support.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
45
galvatron/apple-silicon-support/modules/kernel/edge.nix
Normal file
45
galvatron/apple-silicon-support/modules/kernel/edge.nix
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# the Asahi Linux edge config and options that must go along with it
|
||||||
|
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
config = lib.mkIf config.hardware.asahi.addEdgeKernelConfig {
|
||||||
|
boot.kernelPatches = [
|
||||||
|
{
|
||||||
|
name = "edge-config";
|
||||||
|
patch = null;
|
||||||
|
# derived from
|
||||||
|
# https://github.com/AsahiLinux/PKGBUILDs/blob/main/linux-asahi/config.edge
|
||||||
|
extraConfig = ''
|
||||||
|
DRM_APPLE m
|
||||||
|
DRM_VGEM n
|
||||||
|
DRM_SCHED y
|
||||||
|
DRM_GEM_SHMEM_HELPER y
|
||||||
|
DRM_ASAHI m
|
||||||
|
SUSPEND y
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
# required for proper DRM setup even without GPU driver
|
||||||
|
services.xserver.config = ''
|
||||||
|
Section "OutputClass"
|
||||||
|
Identifier "appledrm"
|
||||||
|
MatchDriver "apple"
|
||||||
|
Driver "modesetting"
|
||||||
|
Option "PrimaryGPU" "true"
|
||||||
|
EndSection
|
||||||
|
'';
|
||||||
|
|
||||||
|
# required for edge drivers
|
||||||
|
hardware.asahi.withRust = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
options.hardware.asahi.addEdgeKernelConfig = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Build the Asahi Linux kernel with additional experimental "edge"
|
||||||
|
configuration options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
62
galvatron/apple-silicon-support/modules/mesa/default.nix
Normal file
62
galvatron/apple-silicon-support/modules/mesa/default.nix
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
config = let
|
||||||
|
isMode = mode: (config.hardware.asahi.useExperimentalGPUDriver
|
||||||
|
&& config.hardware.asahi.experimentalGPUInstallMode == mode);
|
||||||
|
in lib.mkMerge [
|
||||||
|
(lib.mkIf config.hardware.asahi.useExperimentalGPUDriver {
|
||||||
|
|
||||||
|
# install the drivers
|
||||||
|
hardware.opengl.package = config.hardware.asahi.pkgs.mesa-asahi-edge.drivers;
|
||||||
|
|
||||||
|
# required for GPU kernel driver
|
||||||
|
hardware.asahi.addEdgeKernelConfig = true;
|
||||||
|
})
|
||||||
|
(lib.mkIf (isMode "replace") {
|
||||||
|
# replace the Mesa linked into system packages with the Asahi version
|
||||||
|
# without rebuilding them to avoid rebuilding the world.
|
||||||
|
system.replaceRuntimeDependencies = [
|
||||||
|
{ original = pkgs.mesa;
|
||||||
|
replacement = config.hardware.asahi.pkgs.mesa-asahi-edge;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
})
|
||||||
|
(lib.mkIf (isMode "overlay") {
|
||||||
|
# replace the Mesa used in Nixpkgs with the Asahi version using an overlay,
|
||||||
|
# which requires rebuilding the world but ensures it is done faithfully
|
||||||
|
# (and in a way compatible with pure evaluation)
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
mesa = final.mesa-asahi-edge;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
options.hardware.asahi.useExperimentalGPUDriver = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Use the experimental Asahi Mesa GPU driver.
|
||||||
|
|
||||||
|
Do not report issues using this driver under NixOS to the Asahi project.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
options.hardware.asahi.experimentalGPUInstallMode = lib.mkOption {
|
||||||
|
type = lib.types.enum [ "driver" "replace" "overlay" ];
|
||||||
|
default = "replace";
|
||||||
|
description = ''
|
||||||
|
Mode to use to install the experimental GPU driver into the system.
|
||||||
|
|
||||||
|
driver: install only as a driver, do not replace system Mesa.
|
||||||
|
Causes issues with certain programs like Plasma Wayland.
|
||||||
|
|
||||||
|
replace (default): use replaceRuntimeDependencies to replace system Mesa with Asahi Mesa.
|
||||||
|
Does not work in pure evaluation context (i.e. in flakes by default).
|
||||||
|
|
||||||
|
overlay: overlay system Mesa with Asahi Mesa
|
||||||
|
Requires rebuilding the world.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
assertions = lib.mkIf config.hardware.asahi.extractPeripheralFirmware [
|
||||||
|
{ assertion = config.hardware.asahi.peripheralFirmwareDirectory != null;
|
||||||
|
message = ''
|
||||||
|
Asahi peripheral firmware extraction is enabled but the firmware
|
||||||
|
location appears incorrect.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
hardware.firmware = let
|
||||||
|
pkgs' = config.hardware.asahi.pkgs;
|
||||||
|
in
|
||||||
|
lib.mkIf ((config.hardware.asahi.peripheralFirmwareDirectory != null)
|
||||||
|
&& config.hardware.asahi.extractPeripheralFirmware) [
|
||||||
|
(pkgs.stdenv.mkDerivation {
|
||||||
|
name = "asahi-peripheral-firmware";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkgs'.asahi-fwextract pkgs.cpio ];
|
||||||
|
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir extracted
|
||||||
|
asahi-fwextract ${config.hardware.asahi.peripheralFirmwareDirectory} extracted
|
||||||
|
|
||||||
|
mkdir -p $out/lib/firmware
|
||||||
|
cat extracted/firmware.cpio | cpio -id --quiet --no-absolute-filenames
|
||||||
|
mv vendorfw/* $out/lib/firmware
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
options.hardware.asahi = {
|
||||||
|
extractPeripheralFirmware = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Automatically extract the non-free non-redistributable peripheral
|
||||||
|
firmware necessary for features like Wi-Fi.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
peripheralFirmwareDirectory = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
|
||||||
|
default = lib.findFirst (path: builtins.pathExists (path + "/all_firmware.tar.gz")) null
|
||||||
|
[
|
||||||
|
# path when the system is operating normally
|
||||||
|
/boot/asahi
|
||||||
|
# path when the system is mounted in the installer
|
||||||
|
/mnt/boot/asahi
|
||||||
|
];
|
||||||
|
|
||||||
|
description = ''
|
||||||
|
Path to the directory containing the non-free non-redistributable
|
||||||
|
peripheral firmware necessary for features like Wi-Fi. Ordinarily, this
|
||||||
|
will automatically point to the appropriate location on the ESP. Flake
|
||||||
|
users and those interested in maximum purity will want to copy those
|
||||||
|
files elsewhere and specify this manually.
|
||||||
|
|
||||||
|
Currently, this consists of the files `all-firmware.tar.gz` and
|
||||||
|
`kernelcache*`. The official Asahi Linux installer places these files
|
||||||
|
in the `asahi` directory of the EFI system partition when creating it.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
69
galvatron/apple-silicon-support/modules/sound/default.nix
Normal file
69
galvatron/apple-silicon-support/modules/sound/default.nix
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
# disable pulseaudio as the Asahi sound infrastructure can't use it.
|
||||||
|
# if we disable it only if setupAsahiSound is enabled, then infinite
|
||||||
|
# recursion results as pulseaudio enables config.sound by default.
|
||||||
|
{ config.hardware.pulseaudio.enable = false; }
|
||||||
|
];
|
||||||
|
|
||||||
|
options.hardware.asahi = {
|
||||||
|
setupAsahiSound = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = config.sound.enable;
|
||||||
|
description = ''
|
||||||
|
Set up the Asahi DSP components so that the speakers and headphone jack
|
||||||
|
work properly and safely.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = let
|
||||||
|
asahi-audio = pkgs.asahi-audio; # the asahi-audio we use
|
||||||
|
|
||||||
|
lsp-plugins = pkgs.lsp-plugins; # the lsp-plugins we use
|
||||||
|
|
||||||
|
lsp-plugins-is-patched = (lsp-plugins.overrideAttrs (old: {
|
||||||
|
passthru = (old.passthru or {}) // {
|
||||||
|
lsp-plugins-is-patched = builtins.elem "58c3f985f009c84347fa91236f164a9e47aafa93.patch"
|
||||||
|
(builtins.map (p: p.name) (old.patches or []));
|
||||||
|
};
|
||||||
|
})).lsp-plugins-is-patched;
|
||||||
|
|
||||||
|
lsp-plugins-is-safe = (pkgs.lib.versionAtLeast lsp-plugins.version "1.2.14") || lsp-plugins-is-patched;
|
||||||
|
in lib.mkIf config.hardware.asahi.setupAsahiSound {
|
||||||
|
# enable pipewire to run real-time and avoid audible glitches
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
# set up pipewire with the supported capabilities (instead of pulseaudio)
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
alsa.enable = true;
|
||||||
|
wireplumber.enable = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# enable speakersafetyd to protect speakers
|
||||||
|
systemd.packages = lib.mkAssert lsp-plugins-is-safe
|
||||||
|
"lsp-plugins is unpatched/outdated and speakers cannot be safely enabled"
|
||||||
|
[ pkgs.speakersafetyd ];
|
||||||
|
services.udev.packages = [ pkgs.speakersafetyd ];
|
||||||
|
|
||||||
|
# set up enivronment so that asahi-audio and UCM configs are used
|
||||||
|
environment.etc = builtins.listToAttrs (builtins.map
|
||||||
|
(f: { name = f; value = { source = "${asahi-audio}/share/${f}"; }; })
|
||||||
|
asahi-audio.providedConfigFiles);
|
||||||
|
environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2";
|
||||||
|
|
||||||
|
# set up pipewire and wireplumber to use asahi-audio configs and plugins
|
||||||
|
systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2;
|
||||||
|
systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2;
|
||||||
|
systemd.user.services.pipewire.environment.LV2_PATH = let
|
||||||
|
lv2Plugins = [ lsp-plugins pkgs.bankstown-lv2 ];
|
||||||
|
in lib.makeSearchPath "lib/lv2" lv2Plugins;
|
||||||
|
systemd.user.services.wireplumber.environment.LV2_PATH = let
|
||||||
|
lv2Plugins = [ lsp-plugins pkgs.bankstown-lv2 ];
|
||||||
|
in lib.makeSearchPath "lib/lv2" lv2Plugins;
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
{ lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
, alsa-ucm-conf }:
|
||||||
|
|
||||||
|
(alsa-ucm-conf.overrideAttrs (oldAttrs: rec {
|
||||||
|
version = "5";
|
||||||
|
|
||||||
|
src_asahi = fetchFromGitHub {
|
||||||
|
# tracking: https://src.fedoraproject.org/rpms/alsa-ucm-asahi
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "alsa-ucm-conf-asahi";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-daUNz5oUrPfSMO0Tqq/WbtiLHMOtPeQQlI+juGrhTxw=";
|
||||||
|
};
|
||||||
|
|
||||||
|
postInstall = oldAttrs.postInstall or "" + ''
|
||||||
|
cp -r ${src_asahi}/ucm2 $out/share/alsa
|
||||||
|
'';
|
||||||
|
}))
|
@ -0,0 +1,51 @@
|
|||||||
|
{ stdenv
|
||||||
|
, lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "asahi-audio";
|
||||||
|
# tracking: https://src.fedoraproject.org/rpms/asahi-audio
|
||||||
|
# note: ensure that the providedConfigFiles list below is current!
|
||||||
|
version = "1.6";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "asahi-audio";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-NxTQD742U2FUZNmw7RHuOruMuTRLtAh1HDlMV9EzQkg=";
|
||||||
|
};
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
export PREFIX=$out
|
||||||
|
|
||||||
|
readarray -t configs < <(\
|
||||||
|
find . \
|
||||||
|
-name '*.conf' -or \
|
||||||
|
-name '*.json' -or \
|
||||||
|
-name '*.lua'
|
||||||
|
)
|
||||||
|
|
||||||
|
substituteInPlace "''${configs[@]}" --replace \
|
||||||
|
"/usr/share/asahi-audio" \
|
||||||
|
"$out/asahi-audio"
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
# no need to link the asahi-audio dir globally
|
||||||
|
mv $out/share/asahi-audio $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
# list of config files installed in $out/share/ and destined for
|
||||||
|
# /etc/, from the `install -pm0644 conf/` lines in the Makefile. note
|
||||||
|
# that the contents of asahi-audio/ stay in $out/ and the config files
|
||||||
|
# are modified to point to them.
|
||||||
|
passthru.providedConfigFiles = [
|
||||||
|
"wireplumber/wireplumber.conf.d/99-asahi.conf"
|
||||||
|
"wireplumber/policy.lua.d/85-asahi-policy.lua"
|
||||||
|
"wireplumber/main.lua.d/85-asahi.lua"
|
||||||
|
"wireplumber/scripts/policy-asahi.lua"
|
||||||
|
"pipewire/pipewire.conf.d/99-asahi.conf"
|
||||||
|
"pipewire/pipewire-pulse.conf.d/99-asahi.conf"
|
||||||
|
];
|
||||||
|
}
|
32
galvatron/apple-silicon-support/packages/asahi-fwextract/default.nix
Executable file
32
galvatron/apple-silicon-support/packages/asahi-fwextract/default.nix
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
{ lib
|
||||||
|
, python3
|
||||||
|
, fetchFromGitHub
|
||||||
|
, gzip
|
||||||
|
, gnutar
|
||||||
|
, lzfse
|
||||||
|
}:
|
||||||
|
|
||||||
|
python3.pkgs.buildPythonApplication rec {
|
||||||
|
pname = "asahi-fwextract";
|
||||||
|
version = "0.6.9";
|
||||||
|
|
||||||
|
# tracking version: https://github.com/AsahiLinux/PKGBUILDs/blob/main/asahi-fwextract/PKGBUILD
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "asahi-installer";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-MkNi4EBgT4gfev/yWqYyw5HZxewj6XTfb8na+eI2iVo=";
|
||||||
|
};
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace asahi_firmware/img4.py \
|
||||||
|
--replace 'liblzfse.so' '${lzfse}/lib/liblzfse.so'
|
||||||
|
substituteInPlace asahi_firmware/update.py \
|
||||||
|
--replace '"tar"' '"${gnutar}/bin/tar"' \
|
||||||
|
--replace '"xf"' '"-x", "-I", "${gzip}/bin/gzip", "-f"'
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ python3.pkgs.setuptools ];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
{ lib
|
||||||
|
, lv2
|
||||||
|
, pkg-config
|
||||||
|
, rustPlatform
|
||||||
|
, fetchFromGitHub
|
||||||
|
, fetchpatch
|
||||||
|
}:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "bankstown-lv2";
|
||||||
|
# tracking: https://src.fedoraproject.org/rpms/rust-bankstown-lv2
|
||||||
|
version = "1.0.3";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "chadmed";
|
||||||
|
repo = "bankstown";
|
||||||
|
rev = version;
|
||||||
|
hash = "sha256-dPgQuwwY1FEsH65vYClTtV/c+0cB5uq8QYszeHPdIQA=";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoSha256 = "sha256-HIW4mJ1VQSzOIksmJ2d4FQjTfU2Zk6xva1mYUk6MQCI=";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
export LIBDIR=$out/lib
|
||||||
|
mkdir -p $LIBDIR
|
||||||
|
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
lv2
|
||||||
|
];
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
7839
galvatron/apple-silicon-support/packages/linux-asahi/config
Normal file
7839
galvatron/apple-silicon-support/packages/linux-asahi/config
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
|
||||||
|
index a1eb6572ecd2..b94fbd9b3d70 100644
|
||||||
|
--- a/arch/arm64/Kconfig
|
||||||
|
+++ b/arch/arm64/Kconfig
|
||||||
|
@@ -1036,7 +1036,7 @@ endmenu
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Page size"
|
||||||
|
- default ARM64_4K_PAGES
|
||||||
|
+ default ARM64_16K_PAGES
|
||||||
|
help
|
||||||
|
Page size (translation granule) configuration.
|
||||||
|
|
160
galvatron/apple-silicon-support/packages/linux-asahi/default.nix
Normal file
160
galvatron/apple-silicon-support/packages/linux-asahi/default.nix
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
{ lib
|
||||||
|
, pkgs
|
||||||
|
, callPackage
|
||||||
|
, writeShellScriptBin
|
||||||
|
, writeText
|
||||||
|
, removeReferencesTo
|
||||||
|
, linuxPackagesFor
|
||||||
|
, _4KBuild ? false
|
||||||
|
, 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
|
||||||
|
config = 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.6.0-asahi";
|
||||||
|
modDirVersion = version;
|
||||||
|
extraMeta.branch = "6.6";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
# tracking: https://github.com/AsahiLinux/linux/tree/asahi-wip (w/ fedora verification)
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "linux";
|
||||||
|
rev = "asahi-6.6-14";
|
||||||
|
hash = "sha256-+ydX2XXIbcVfq27WC68EPP8n3bf+WD5fDG7FBq3QJi4=";
|
||||||
|
};
|
||||||
|
|
||||||
|
kernelPatches = [
|
||||||
|
# speaker enablement; we assert on the relevant lsp-plugins patch
|
||||||
|
# before installing speakersafetyd to let the speakers work
|
||||||
|
{ name = "speakers-1";
|
||||||
|
patch = fetchpatch {
|
||||||
|
url = "https://github.com/AsahiLinux/linux/commit/385ea7b5023486aba7919cec8b6b3f6a843a1013.patch";
|
||||||
|
hash = "sha256-u7IzhJbUgBPfhJXAcpHw1I6OPzPHc1UKYjH91Ep3QHQ=";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{ name = "speakers-2";
|
||||||
|
patch = fetchpatch {
|
||||||
|
url = "https://github.com/AsahiLinux/linux/commit/6a24102c06c95951ab992e2d41336cc6d4bfdf23.patch";
|
||||||
|
hash = "sha256-wn5x2hN42/kCp/XHBvLWeNLfwlOBB+T6UeeMt2tSg3o=";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
] ++ lib.optionals (rustAtLeast "1.75.0") [
|
||||||
|
{ name = "rustc-1.75.0";
|
||||||
|
patch = ./0001-check-in-new-alloc-for-1.75.0.patch;
|
||||||
|
}
|
||||||
|
] ++ lib.optionals _4KBuild [
|
||||||
|
# thanks to Sven Peter
|
||||||
|
# https://lore.kernel.org/linux-iommu/20211019163737.46269-1-sven@svenpeter.dev/
|
||||||
|
{ name = "sven-iommu-4k";
|
||||||
|
patch = ./sven-iommu-4k.patch;
|
||||||
|
}
|
||||||
|
(builtins.throw "The Asahi 4K kernel patch is currently broken. Contributions to fix are welcome.")
|
||||||
|
] ++ lib.optionals (!_4KBuild) [
|
||||||
|
# patch the kernel to set the default size to 16k instead of modifying
|
||||||
|
# the config so we don't need to convert our config to the nixos
|
||||||
|
# infrastructure or patch it and thus introduce a dependency on the host
|
||||||
|
# system architecture
|
||||||
|
{ name = "default-pagesize-16k";
|
||||||
|
patch = ./default-pagesize-16k.patch;
|
||||||
|
}
|
||||||
|
] ++ _kernelPatches;
|
||||||
|
|
||||||
|
inherit configfile config;
|
||||||
|
} // (args.argsOverride or {})).overrideAttrs (old: if withRust then {
|
||||||
|
nativeBuildInputs = (old.nativeBuildInputs or []) ++ [
|
||||||
|
rust-bindgen
|
||||||
|
rustfmt
|
||||||
|
rustc
|
||||||
|
removeReferencesTo
|
||||||
|
];
|
||||||
|
# HACK: references shouldn't have been there in the first place
|
||||||
|
# TODO: remove once 23.05 is obsolete
|
||||||
|
postFixup = (old.postFixup or "") + ''
|
||||||
|
if [ -f $dev/lib/modules/${old.version}/build/vmlinux ]; then
|
||||||
|
remove-references-to -t $out $dev/lib/modules/${old.version}/build/vmlinux
|
||||||
|
fi
|
||||||
|
remove-references-to -t $dev $out/Image
|
||||||
|
'';
|
||||||
|
RUST_LIB_SRC = rustPlatform.rustLibSrc;
|
||||||
|
} else {});
|
||||||
|
|
||||||
|
linux-asahi = (callPackage linux-asahi-pkg { });
|
||||||
|
in lib.recurseIntoAttrs (linuxPackagesFor linux-asahi)
|
||||||
|
|
@ -0,0 +1,449 @@
|
|||||||
|
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
|
||||||
|
index 4f1a37bdd42d..c8c3ea81d818 100644
|
||||||
|
--- a/drivers/iommu/apple-dart.c
|
||||||
|
+++ b/drivers/iommu/apple-dart.c
|
||||||
|
@@ -97,7 +97,6 @@ struct apple_dart_hw {
|
||||||
|
* @lock: lock for hardware operations involving this dart
|
||||||
|
* @pgsize: pagesize supported by this DART
|
||||||
|
* @supports_bypass: indicates if this DART supports bypass mode
|
||||||
|
- * @force_bypass: force bypass mode due to pagesize mismatch?
|
||||||
|
* @sid2group: maps stream ids to iommu_groups
|
||||||
|
* @iommu: iommu core device
|
||||||
|
*/
|
||||||
|
@@ -115,7 +114,6 @@ struct apple_dart {
|
||||||
|
|
||||||
|
u32 pgsize;
|
||||||
|
u32 supports_bypass : 1;
|
||||||
|
- u32 force_bypass : 1;
|
||||||
|
|
||||||
|
struct iommu_group *sid2group[DART_MAX_STREAMS];
|
||||||
|
struct iommu_device iommu;
|
||||||
|
@@ -499,9 +497,6 @@ static int apple_dart_attach_dev(struct iommu_domain *domain,
|
||||||
|
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
|
||||||
|
struct apple_dart_domain *dart_domain = to_dart_domain(domain);
|
||||||
|
|
||||||
|
- if (cfg->stream_maps[0].dart->force_bypass &&
|
||||||
|
- domain->type != IOMMU_DOMAIN_IDENTITY)
|
||||||
|
- return -EINVAL;
|
||||||
|
if (!cfg->stream_maps[0].dart->supports_bypass &&
|
||||||
|
domain->type == IOMMU_DOMAIN_IDENTITY)
|
||||||
|
return -EINVAL;
|
||||||
|
@@ -630,8 +625,6 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args)
|
||||||
|
if (cfg_dart) {
|
||||||
|
if (cfg_dart->supports_bypass != dart->supports_bypass)
|
||||||
|
return -EINVAL;
|
||||||
|
- if (cfg_dart->force_bypass != dart->force_bypass)
|
||||||
|
- return -EINVAL;
|
||||||
|
if (cfg_dart->pgsize != dart->pgsize)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
@@ -736,8 +729,6 @@ static int apple_dart_def_domain_type(struct device *dev)
|
||||||
|
{
|
||||||
|
struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev);
|
||||||
|
|
||||||
|
- if (cfg->stream_maps[0].dart->force_bypass)
|
||||||
|
- return IOMMU_DOMAIN_IDENTITY;
|
||||||
|
if (!cfg->stream_maps[0].dart->supports_bypass)
|
||||||
|
return IOMMU_DOMAIN_DMA;
|
||||||
|
|
||||||
|
@@ -1121,8 +1121,6 @@ static int apple_dart_probe(struct platform_device *pdev)
|
||||||
|
goto err_clk_disable;
|
||||||
|
}
|
||||||
|
|
||||||
|
- dart->force_bypass = dart->pgsize > PAGE_SIZE;
|
||||||
|
-
|
||||||
|
ret = apple_dart_hw_reset(dart);
|
||||||
|
if (ret)
|
||||||
|
goto err_clk_disable;
|
||||||
|
@@ -1149,8 +1147,8 @@ static int apple_dart_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
|
dev_info(
|
||||||
|
&pdev->dev,
|
||||||
|
- "DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n",
|
||||||
|
- dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);
|
||||||
|
+ "DART [pagesize %x, %d streams, bypass support: %d] initialized\n",
|
||||||
|
+ dart->pgsize, dart->num_streams, dart->supports_bypass);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_sysfs_remove:
|
||||||
|
|
||||||
|
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
|
||||||
|
index 09f6e1c0f9c0..094592751cfa 100644
|
||||||
|
--- a/drivers/iommu/dma-iommu.c
|
||||||
|
+++ b/drivers/iommu/dma-iommu.c
|
||||||
|
@@ -20,9 +20,11 @@
|
||||||
|
#include <linux/iommu.h>
|
||||||
|
#include <linux/iova.h>
|
||||||
|
#include <linux/irq.h>
|
||||||
|
+#include <linux/kernel.h>
|
||||||
|
#include <linux/list_sort.h>
|
||||||
|
#include <linux/mm.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
+#include <linux/pfn.h>
|
||||||
|
#include <linux/pci.h>
|
||||||
|
#include <linux/scatterlist.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
@@ -710,6 +712,9 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
|
||||||
|
{
|
||||||
|
struct page **pages;
|
||||||
|
unsigned int i = 0, nid = dev_to_node(dev);
|
||||||
|
+ unsigned int j;
|
||||||
|
+ unsigned long min_order = __fls(order_mask);
|
||||||
|
+ unsigned int min_order_size = 1U << min_order;
|
||||||
|
|
||||||
|
order_mask &= (2U << MAX_ORDER) - 1;
|
||||||
|
if (!order_mask)
|
||||||
|
@@ -749,15 +754,37 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
|
||||||
|
split_page(page, order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
- if (!page) {
|
||||||
|
- __iommu_dma_free_pages(pages, i);
|
||||||
|
- return NULL;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * If we have no valid page here we might be trying to allocate
|
||||||
|
+ * the last block consisting of 1<<order pages (to guarantee
|
||||||
|
+ * alignment) but actually need less pages than that.
|
||||||
|
+ * In that case we just try to allocate the entire block and
|
||||||
|
+ * directly free the spillover pages again.
|
||||||
|
+ */
|
||||||
|
+ if (!page && !order_mask && count < min_order_size) {
|
||||||
|
+ page = alloc_pages_node(nid, gfp, min_order);
|
||||||
|
+ if (!page)
|
||||||
|
+ goto free_pages;
|
||||||
|
+ split_page(page, min_order);
|
||||||
|
+
|
||||||
|
+ for (j = count; j < min_order_size; ++j)
|
||||||
|
+ __free_page(page + j);
|
||||||
|
+
|
||||||
|
+ order_size = count;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ if (!page)
|
||||||
|
+ goto free_pages;
|
||||||
|
count -= order_size;
|
||||||
|
while (order_size--)
|
||||||
|
pages[i++] = page++;
|
||||||
|
}
|
||||||
|
return pages;
|
||||||
|
+
|
||||||
|
+free_pages:
|
||||||
|
+ __iommu_dma_free_pages(pages, i);
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -785,16 +787,28 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev,
|
||||||
|
bool coherent = dev_is_dma_coherent(dev);
|
||||||
|
int ioprot = dma_info_to_prot(DMA_BIDIRECTIONAL, coherent, attrs);
|
||||||
|
unsigned int count, min_size, alloc_sizes = domain->pgsize_bitmap;
|
||||||
|
+ struct sg_append_table sgt_append = {};
|
||||||
|
+ struct scatterlist *last_sg;
|
||||||
|
struct page **pages;
|
||||||
|
dma_addr_t iova;
|
||||||
|
ssize_t ret;
|
||||||
|
+ phys_addr_t orig_s_phys;
|
||||||
|
+ size_t orig_s_len, orig_s_off, s_iova_off, iova_size;
|
||||||
|
|
||||||
|
if (static_branch_unlikely(&iommu_deferred_attach_enabled) &&
|
||||||
|
iommu_deferred_attach(dev, domain))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
min_size = alloc_sizes & -alloc_sizes;
|
||||||
|
- if (min_size < PAGE_SIZE) {
|
||||||
|
+ if (iovad->granule > PAGE_SIZE) {
|
||||||
|
+ if (size < iovad->granule) {
|
||||||
|
+ /* ensure a single contiguous allocation */
|
||||||
|
+ min_size = ALIGN(size, PAGE_SIZE*(1U<<get_order(size)));
|
||||||
|
+ alloc_sizes = min_size;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ size = PAGE_ALIGN(size);
|
||||||
|
+ } else if (min_size < PAGE_SIZE) {
|
||||||
|
min_size = PAGE_SIZE;
|
||||||
|
alloc_sizes |= PAGE_SIZE;
|
||||||
|
} else {
|
||||||
|
@@ -797,13 +836,17 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev,
|
||||||
|
if (!pages)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- size = iova_align(iovad, size);
|
||||||
|
- iova = iommu_dma_alloc_iova(domain, size, dev->coherent_dma_mask, dev);
|
||||||
|
+ iova_size = iova_align(iovad, size);
|
||||||
|
+ iova = iommu_dma_alloc_iova(domain, iova_size, dev->coherent_dma_mask, dev);
|
||||||
|
if (!iova)
|
||||||
|
goto out_free_pages;
|
||||||
|
|
||||||
|
- if (sg_alloc_table_from_pages(sgt, pages, count, 0, size, GFP_KERNEL))
|
||||||
|
+ /* append_table is only used to get a pointer to the last entry */
|
||||||
|
+ if (sg_alloc_append_table_from_pages(&sgt_append, pages, count, 0,
|
||||||
|
+ iova_size, UINT_MAX, 0, GFP_KERNEL))
|
||||||
|
goto out_free_iova;
|
||||||
|
+ memcpy(sgt, &sgt_append.sgt, sizeof(*sgt));
|
||||||
|
+ last_sg = sgt_append.prv;
|
||||||
|
|
||||||
|
if (!(ioprot & IOMMU_CACHE)) {
|
||||||
|
struct scatterlist *sg;
|
||||||
|
@@ -825,18 +839,59 @@ static struct page **__iommu_dma_alloc_noncontiguous(struct device *dev,
|
||||||
|
arch_dma_prep_coherent(sg_page(sg), sg->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (iovad->granule > PAGE_SIZE) {
|
||||||
|
+ if (size < iovad->granule) {
|
||||||
|
+ /*
|
||||||
|
+ * we only have a single sg list entry here that is
|
||||||
|
+ * likely not aligned to iovad->granule. adjust the
|
||||||
|
+ * entry to represent the encapsulating IOMMU page
|
||||||
|
+ * and then later restore everything to its original
|
||||||
|
+ * values, similar to the impedance matching done in
|
||||||
|
+ * iommu_dma_map_sg.
|
||||||
|
+ */
|
||||||
|
+ orig_s_phys = sg_phys(sgt->sgl);
|
||||||
|
+ orig_s_len = sgt->sgl->length;
|
||||||
|
+ orig_s_off = sgt->sgl->offset;
|
||||||
|
+ s_iova_off = iova_offset(iovad, orig_s_phys);
|
||||||
|
+
|
||||||
|
+ sg_set_page(sgt->sgl,
|
||||||
|
+ pfn_to_page(PHYS_PFN(orig_s_phys - s_iova_off)),
|
||||||
|
+ iova_align(iovad, orig_s_len + s_iova_off),
|
||||||
|
+ sgt->sgl->offset & ~s_iova_off);
|
||||||
|
+ } else {
|
||||||
|
+ /*
|
||||||
|
+ * convince iommu_map_sg_atomic to map the last block
|
||||||
|
+ * even though it may be too small.
|
||||||
|
+ */
|
||||||
|
+ orig_s_len = last_sg->length;
|
||||||
|
+ last_sg->length = iova_align(iovad, last_sg->length);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
ret = iommu_map_sg_atomic(domain, iova, sgt->sgl, sgt->orig_nents, ioprot);
|
||||||
|
- if (ret < 0 || ret < size)
|
||||||
|
+ if (ret < 0 || ret < iova_size)
|
||||||
|
goto out_free_sg;
|
||||||
|
|
||||||
|
+ if (iovad->granule > PAGE_SIZE) {
|
||||||
|
+ if (size < iovad->granule) {
|
||||||
|
+ sg_set_page(sgt->sgl,
|
||||||
|
+ pfn_to_page(PHYS_PFN(orig_s_phys)),
|
||||||
|
+ orig_s_len, orig_s_off);
|
||||||
|
+
|
||||||
|
+ iova += s_iova_off;
|
||||||
|
+ } else {
|
||||||
|
+ last_sg->length = orig_s_len;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
sgt->sgl->dma_address = iova;
|
||||||
|
- sgt->sgl->dma_length = size;
|
||||||
|
+ sgt->sgl->dma_length = iova_size;
|
||||||
|
return pages;
|
||||||
|
|
||||||
|
out_free_sg:
|
||||||
|
sg_free_table(sgt);
|
||||||
|
out_free_iova:
|
||||||
|
- iommu_dma_free_iova(cookie, iova, size, NULL);
|
||||||
|
+ iommu_dma_free_iova(cookie, iova, iova_size, NULL);
|
||||||
|
out_free_pages:
|
||||||
|
__iommu_dma_free_pages(pages, count);
|
||||||
|
return NULL;
|
||||||
|
@@ -1040,8 +1124,9 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
|
||||||
|
unsigned int s_length = sg_dma_len(s);
|
||||||
|
unsigned int s_iova_len = s->length;
|
||||||
|
|
||||||
|
- s->offset += s_iova_off;
|
||||||
|
- s->length = s_length;
|
||||||
|
+ sg_set_page(s,
|
||||||
|
+ pfn_to_page(PHYS_PFN(sg_phys(s) + s_iova_off)),
|
||||||
|
+ s_length, s_iova_off & ~PAGE_MASK);
|
||||||
|
sg_dma_address(s) = DMA_MAPPING_ERROR;
|
||||||
|
sg_dma_len(s) = 0;
|
||||||
|
|
||||||
|
@@ -1082,13 +1167,17 @@ static int __finalise_sg(struct device *dev, struct scatterlist *sg, int nents,
|
||||||
|
static void __invalidate_sg(struct scatterlist *sg, int nents)
|
||||||
|
{
|
||||||
|
struct scatterlist *s;
|
||||||
|
+ phys_addr_t orig_paddr;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for_each_sg(sg, s, nents, i) {
|
||||||
|
- if (sg_dma_address(s) != DMA_MAPPING_ERROR)
|
||||||
|
- s->offset += sg_dma_address(s);
|
||||||
|
- if (sg_dma_len(s))
|
||||||
|
- s->length = sg_dma_len(s);
|
||||||
|
+ if (sg_dma_len(s)) {
|
||||||
|
+ orig_paddr = sg_phys(s) + sg_dma_address(s);
|
||||||
|
+ sg_set_page(s,
|
||||||
|
+ pfn_to_page(PHYS_PFN(orig_paddr)),
|
||||||
|
+ sg_dma_len(s),
|
||||||
|
+ sg_dma_address(s) & ~PAGE_MASK);
|
||||||
|
+ }
|
||||||
|
sg_dma_address(s) = DMA_MAPPING_ERROR;
|
||||||
|
sg_dma_len(s) = 0;
|
||||||
|
}
|
||||||
|
@@ -1166,15 +1255,16 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,
|
||||||
|
* stashing the unaligned parts in the as-yet-unused DMA fields.
|
||||||
|
*/
|
||||||
|
for_each_sg(sg, s, nents, i) {
|
||||||
|
- size_t s_iova_off = iova_offset(iovad, s->offset);
|
||||||
|
+ phys_addr_t s_phys = sg_phys(s);
|
||||||
|
+ size_t s_iova_off = iova_offset(iovad, s_phys);
|
||||||
|
size_t s_length = s->length;
|
||||||
|
size_t pad_len = (mask - iova_len + 1) & mask;
|
||||||
|
|
||||||
|
sg_dma_address(s) = s_iova_off;
|
||||||
|
sg_dma_len(s) = s_length;
|
||||||
|
- s->offset -= s_iova_off;
|
||||||
|
s_length = iova_align(iovad, s_length + s_iova_off);
|
||||||
|
- s->length = s_length;
|
||||||
|
+ sg_set_page(s, pfn_to_page(PHYS_PFN(s_phys - s_iova_off)),
|
||||||
|
+ s_length, s->offset & ~s_iova_off);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Due to the alignment of our single IOVA allocation, we can
|
||||||
|
@@ -1412,9 +1502,15 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt,
|
||||||
|
void *cpu_addr, dma_addr_t dma_addr, size_t size,
|
||||||
|
unsigned long attrs)
|
||||||
|
{
|
||||||
|
+ struct iommu_domain *domain = iommu_get_dma_domain(dev);
|
||||||
|
+ struct iommu_dma_cookie *cookie = domain->iova_cookie;
|
||||||
|
+ struct iova_domain *iovad = &cookie->iovad;
|
||||||
|
struct page *page;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
+ if (iovad->granule > PAGE_SIZE)
|
||||||
|
+ return -ENXIO;
|
||||||
|
+
|
||||||
|
if (is_vmalloc_addr(cpu_addr)) {
|
||||||
|
struct page **pages = dma_common_find_pages(cpu_addr);
|
||||||
|
|
||||||
|
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
|
||||||
|
index f2c45b85b9fc..0c370e486d6e 100644
|
||||||
|
--- a/drivers/iommu/iommu.c
|
||||||
|
+++ b/drivers/iommu/iommu.c
|
||||||
|
@@ -80,6 +80,8 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
|
||||||
|
unsigned type);
|
||||||
|
static int __iommu_attach_device(struct iommu_domain *domain,
|
||||||
|
struct device *dev);
|
||||||
|
+static void __iommu_detach_device(struct iommu_domain *domain,
|
||||||
|
+ struct device *dev);
|
||||||
|
static int __iommu_attach_group(struct iommu_domain *domain,
|
||||||
|
struct iommu_group *group);
|
||||||
|
static void __iommu_detach_group(struct iommu_domain *domain,
|
||||||
|
@@ -1976,6 +1978,24 @@ void iommu_domain_free(struct iommu_domain *domain)
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(iommu_domain_free);
|
||||||
|
|
||||||
|
+static int iommu_check_page_size(struct iommu_domain *domain,
|
||||||
|
+ struct device *dev)
|
||||||
|
+{
|
||||||
|
+ bool trusted = !(dev_is_pci(dev) && to_pci_dev(dev)->untrusted);
|
||||||
|
+
|
||||||
|
+ if (!iommu_is_paging_domain(domain))
|
||||||
|
+ return 0;
|
||||||
|
+ if (iommu_is_large_pages_domain(domain) && trusted)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ if (!(domain->pgsize_bitmap & (PAGE_SIZE | (PAGE_SIZE - 1)))) {
|
||||||
|
+ pr_warn("IOMMU pages cannot exactly represent CPU pages.\n");
|
||||||
|
+ return -EFAULT;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int __iommu_attach_device(struct iommu_domain *domain,
|
||||||
|
struct device *dev)
|
||||||
|
{
|
||||||
|
@@ -1985,9 +2005,23 @@ static int __iommu_attach_device(struct iommu_domain *domain,
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
ret = domain->ops->attach_dev(domain, dev);
|
||||||
|
- if (!ret)
|
||||||
|
- trace_attach_device_to_domain(dev);
|
||||||
|
- return ret;
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Check that CPU pages can be represented by the IOVA granularity.
|
||||||
|
+ * This has to be done after ops->attach_dev since many IOMMU drivers
|
||||||
|
+ * only limit domain->pgsize_bitmap after having attached the first
|
||||||
|
+ * device.
|
||||||
|
+ */
|
||||||
|
+ ret = iommu_check_page_size(domain, dev);
|
||||||
|
+ if (ret) {
|
||||||
|
+ __iommu_detach_device(domain, dev);
|
||||||
|
+ return ret;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ trace_attach_device_to_domain(dev);
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iommu_attach_device(struct iommu_domain *domain, struct device *dev)
|
||||||
|
diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
|
||||||
|
index db77aa675145..180ce65a6789 100644
|
||||||
|
--- a/drivers/iommu/iova.c
|
||||||
|
+++ b/drivers/iommu/iova.c
|
||||||
|
@@ -49,10 +49,11 @@ init_iova_domain(struct iova_domain *iovad, unsigned long granule,
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* IOVA granularity will normally be equal to the smallest
|
||||||
|
- * supported IOMMU page size; both *must* be capable of
|
||||||
|
- * representing individual CPU pages exactly.
|
||||||
|
+ * supported IOMMU page size; while both usually are capable of
|
||||||
|
+ * representing individual CPU pages exactly the IOVA allocator
|
||||||
|
+ * supports any granularities that are an exact power of two.
|
||||||
|
*/
|
||||||
|
- BUG_ON((granule > PAGE_SIZE) || !is_power_of_2(granule));
|
||||||
|
+ BUG_ON(!is_power_of_2(granule));
|
||||||
|
|
||||||
|
spin_lock_init(&iovad->iova_rbtree_lock);
|
||||||
|
iovad->rbroot = RB_ROOT;
|
||||||
|
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
|
||||||
|
index 9208eca4b0d1..dec2dd70a876 100644
|
||||||
|
--- a/include/linux/iommu.h
|
||||||
|
+++ b/include/linux/iommu.h
|
||||||
|
@@ -63,6 +63,8 @@ struct iommu_domain_geometry {
|
||||||
|
implementation */
|
||||||
|
#define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */
|
||||||
|
#define __IOMMU_DOMAIN_DMA_FQ (1U << 3) /* DMA-API uses flush queue */
|
||||||
|
+#define __IOMMU_DOMAIN_LP (1U << 4) /* Support for PAGE_SIZE smaller
|
||||||
|
+ than IOMMU page size */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This are the possible domain-types
|
||||||
|
@@ -82,10 +84,12 @@ struct iommu_domain_geometry {
|
||||||
|
#define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT)
|
||||||
|
#define IOMMU_DOMAIN_UNMANAGED (__IOMMU_DOMAIN_PAGING)
|
||||||
|
#define IOMMU_DOMAIN_DMA (__IOMMU_DOMAIN_PAGING | \
|
||||||
|
- __IOMMU_DOMAIN_DMA_API)
|
||||||
|
+ __IOMMU_DOMAIN_DMA_API | \
|
||||||
|
+ __IOMMU_DOMAIN_LP)
|
||||||
|
#define IOMMU_DOMAIN_DMA_FQ (__IOMMU_DOMAIN_PAGING | \
|
||||||
|
__IOMMU_DOMAIN_DMA_API | \
|
||||||
|
- __IOMMU_DOMAIN_DMA_FQ)
|
||||||
|
+ __IOMMU_DOMAIN_DMA_FQ | \
|
||||||
|
+ __IOMMU_DOMAIN_LP)
|
||||||
|
|
||||||
|
struct iommu_domain {
|
||||||
|
unsigned type;
|
||||||
|
@@ -102,6 +106,16 @@ static inline bool iommu_is_dma_domain(struct iommu_domain *domain)
|
||||||
|
return domain->type & __IOMMU_DOMAIN_DMA_API;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static inline bool iommu_is_paging_domain(struct iommu_domain *domain)
|
||||||
|
+{
|
||||||
|
+ return domain->type & __IOMMU_DOMAIN_PAGING;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static inline bool iommu_is_large_pages_domain(struct iommu_domain *domain)
|
||||||
|
+{
|
||||||
|
+ return domain->type & __IOMMU_DOMAIN_LP;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
enum iommu_cap {
|
||||||
|
IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
|
||||||
|
transactions */
|
101
galvatron/apple-silicon-support/packages/m1n1/default.nix
Normal file
101
galvatron/apple-silicon-support/packages/m1n1/default.nix
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
{ stdenv
|
||||||
|
, buildPackages
|
||||||
|
, lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
, python3
|
||||||
|
, dtc
|
||||||
|
, imagemagick
|
||||||
|
, isRelease ? false
|
||||||
|
, withTools ? true
|
||||||
|
, withChainloading ? false
|
||||||
|
, rust-bin ? null
|
||||||
|
, customLogo ? null
|
||||||
|
}:
|
||||||
|
|
||||||
|
assert withChainloading -> rust-bin != null;
|
||||||
|
|
||||||
|
let
|
||||||
|
pyenv = python3.withPackages (p: with p; [
|
||||||
|
construct
|
||||||
|
pyserial
|
||||||
|
]);
|
||||||
|
|
||||||
|
rustenv = rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal.override {
|
||||||
|
targets = [ "aarch64-unknown-none-softfloat" ];
|
||||||
|
});
|
||||||
|
in stdenv.mkDerivation rec {
|
||||||
|
pname = "m1n1";
|
||||||
|
version = "1.4.11";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
# tracking: https://src.fedoraproject.org/rpms/m1n1
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "m1n1";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-1lWI9tcOxgrcfaPfdSF+xRE9qofhNR3SQiA4h86VVeE=";
|
||||||
|
fetchSubmodules = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
makeFlags = [ "ARCH=${stdenv.cc.targetPrefix}" ]
|
||||||
|
++ lib.optional isRelease "RELEASE=1"
|
||||||
|
++ lib.optional withChainloading "CHAINLOADING=1";
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
dtc
|
||||||
|
buildPackages.gcc
|
||||||
|
] ++ lib.optional withChainloading rustenv
|
||||||
|
++ lib.optional (customLogo != null) imagemagick;
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace proxyclient/m1n1/asm.py \
|
||||||
|
--replace 'aarch64-linux-gnu-' 'aarch64-unknown-linux-gnu-' \
|
||||||
|
--replace 'TOOLCHAIN = ""' 'TOOLCHAIN = "'$out'/toolchain-bin/"'
|
||||||
|
'';
|
||||||
|
|
||||||
|
preConfigure = lib.optionalString (customLogo != null) ''
|
||||||
|
pushd data &>/dev/null
|
||||||
|
ln -fs ${customLogo} bootlogo_256.png
|
||||||
|
if [[ "$(magick identify bootlogo_256.png)" != 'bootlogo_256.png PNG 256x256'* ]]; then
|
||||||
|
echo "Custom logo is not a 256x256 PNG"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm bootlogo_128.png
|
||||||
|
convert bootlogo_256.png -resize 128x128 bootlogo_128.png
|
||||||
|
patchShebangs --build ./makelogo.sh
|
||||||
|
./makelogo.sh
|
||||||
|
popd &>/dev/null
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/build
|
||||||
|
cp build/m1n1.bin $out/build
|
||||||
|
'' + (lib.optionalString withTools ''
|
||||||
|
mkdir -p $out/{bin,script,toolchain-bin}
|
||||||
|
cp -r proxyclient $out/script
|
||||||
|
cp -r tools $out/script
|
||||||
|
|
||||||
|
for toolpath in $out/script/proxyclient/tools/*.py; do
|
||||||
|
tool=$(basename $toolpath .py)
|
||||||
|
script=$out/bin/m1n1-$tool
|
||||||
|
cat > $script <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
${pyenv}/bin/python $toolpath "\$@"
|
||||||
|
EOF
|
||||||
|
chmod +x $script
|
||||||
|
done
|
||||||
|
|
||||||
|
GCC=${buildPackages.gcc}
|
||||||
|
BINUTILS=${buildPackages.binutils-unwrapped}
|
||||||
|
|
||||||
|
ln -s $GCC/bin/${stdenv.cc.targetPrefix}gcc $out/toolchain-bin/
|
||||||
|
ln -s $GCC/bin/${stdenv.cc.targetPrefix}ld $out/toolchain-bin/
|
||||||
|
ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objcopy $out/toolchain-bin/
|
||||||
|
ln -s $BINUTILS/bin/${stdenv.cc.targetPrefix}objdump $out/toolchain-bin/
|
||||||
|
ln -s $GCC/bin/${stdenv.cc.targetPrefix}nm $out/toolchain-bin/
|
||||||
|
'') + ''
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
{ lib
|
||||||
|
, fetchFromGitLab
|
||||||
|
, mesa
|
||||||
|
, llvmPackages
|
||||||
|
}:
|
||||||
|
|
||||||
|
(mesa.override {
|
||||||
|
galliumDrivers = [ "swrast" "asahi" ];
|
||||||
|
vulkanDrivers = [ "swrast" ];
|
||||||
|
enableGalliumNine = false;
|
||||||
|
# libclc and other OpenCL components are needed for geometry shader support on Apple Silicon
|
||||||
|
enableOpenCL = true;
|
||||||
|
}).overrideAttrs (oldAttrs: {
|
||||||
|
# version must be the same length (i.e. no unstable or date)
|
||||||
|
# so that system.replaceRuntimeDependencies can work
|
||||||
|
version = "24.0.0";
|
||||||
|
src = fetchFromGitLab {
|
||||||
|
# tracking: https://pagure.io/fedora-asahi/mesa/commits/asahi
|
||||||
|
domain = "gitlab.freedesktop.org";
|
||||||
|
owner = "asahi";
|
||||||
|
repo = "mesa";
|
||||||
|
rev = "asahi-20231213";
|
||||||
|
hash = "sha256-hl0JtwWEXaCkhCMQJ393mzfw/eEx6m9DYNS+spQ3Vhs=";
|
||||||
|
};
|
||||||
|
|
||||||
|
mesonFlags =
|
||||||
|
# remove flag to configure xvmc functionality as having it
|
||||||
|
# breaks the build because that no longer exists in Mesa 23
|
||||||
|
(lib.filter (x: !(lib.hasPrefix "-Dxvmc-libs-path=" x)) oldAttrs.mesonFlags) ++ [
|
||||||
|
# we do not build any graphics drivers these features can be enabled for
|
||||||
|
"-Dgallium-va=disabled"
|
||||||
|
"-Dgallium-vdpau=disabled"
|
||||||
|
"-Dgallium-xa=disabled"
|
||||||
|
# does not make any sense
|
||||||
|
"-Dandroid-libbacktrace=disabled"
|
||||||
|
# do not want to add the dependencies
|
||||||
|
"-Dlibunwind=disabled"
|
||||||
|
"-Dlmsensors=disabled"
|
||||||
|
];
|
||||||
|
|
||||||
|
# replace patches with ones tweaked slightly to apply to this version
|
||||||
|
patches = [
|
||||||
|
./disk_cache-include-dri-driver-path-in-cache-key.patch
|
||||||
|
./opencl.patch
|
||||||
|
];
|
||||||
|
})
|
@ -0,0 +1,67 @@
|
|||||||
|
Author: David McFarland <corngood@gmail.com>
|
||||||
|
Date: Mon Aug 6 15:52:11 2018 -0300
|
||||||
|
|
||||||
|
[PATCH] disk_cache: include dri driver path in cache key
|
||||||
|
|
||||||
|
This fixes invalid cache hits on NixOS where all shared library
|
||||||
|
timestamps in /nix/store are zero.
|
||||||
|
|
||||||
|
diff --git a/meson_options.txt b/meson_options.txt
|
||||||
|
index 512e05d..93001da 100644
|
||||||
|
--- a/meson_options.txt
|
||||||
|
+++ b/meson_options.txt
|
||||||
|
@@ -513,6 +513,13 @@ option(
|
||||||
|
description : 'Enable direct rendering in GLX and EGL for DRI',
|
||||||
|
)
|
||||||
|
|
||||||
|
+option(
|
||||||
|
+ 'disk-cache-key',
|
||||||
|
+ type : 'string',
|
||||||
|
+ value : '',
|
||||||
|
+ description : 'Mesa cache key.'
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
option('egl-lib-suffix',
|
||||||
|
type : 'string',
|
||||||
|
value : '',
|
||||||
|
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
|
||||||
|
index 8298f9d..e622133 100644
|
||||||
|
--- a/src/util/disk_cache.c
|
||||||
|
+++ b/src/util/disk_cache.c
|
||||||
|
@@ -226,8 +226,10 @@ disk_cache_type_create(const char *gpu_name,
|
||||||
|
|
||||||
|
/* Create driver id keys */
|
||||||
|
size_t id_size = strlen(driver_id) + 1;
|
||||||
|
+ size_t key_size = strlen(DISK_CACHE_KEY) + 1;
|
||||||
|
size_t gpu_name_size = strlen(gpu_name) + 1;
|
||||||
|
cache->driver_keys_blob_size += id_size;
|
||||||
|
+ cache->driver_keys_blob_size += key_size;
|
||||||
|
cache->driver_keys_blob_size += gpu_name_size;
|
||||||
|
|
||||||
|
/* We sometimes store entire structs that contains a pointers in the cache,
|
||||||
|
@@ -248,6 +250,7 @@ disk_cache_type_create(const char *gpu_name,
|
||||||
|
uint8_t *drv_key_blob = cache->driver_keys_blob;
|
||||||
|
DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
|
||||||
|
DRV_KEY_CPY(drv_key_blob, driver_id, id_size)
|
||||||
|
+ DRV_KEY_CPY(drv_key_blob, DISK_CACHE_KEY, key_size)
|
||||||
|
DRV_KEY_CPY(drv_key_blob, gpu_name, gpu_name_size)
|
||||||
|
DRV_KEY_CPY(drv_key_blob, &ptr_size, ptr_size_size)
|
||||||
|
DRV_KEY_CPY(drv_key_blob, &driver_flags, driver_flags_size)
|
||||||
|
diff --git a/src/util/meson.build b/src/util/meson.build
|
||||||
|
index c0c1b9d..442163c 100644
|
||||||
|
--- a/src/util/meson.build
|
||||||
|
+++ b/src/util/meson.build
|
||||||
|
@@ -268,7 +268,12 @@ _libmesa_util = static_library(
|
||||||
|
include_directories : [inc_util, include_directories('format')],
|
||||||
|
dependencies : deps_for_libmesa_util,
|
||||||
|
link_with: [libmesa_util_sse41],
|
||||||
|
- c_args : [c_msvc_compat_args],
|
||||||
|
+ c_args : [
|
||||||
|
+ c_msvc_compat_args,
|
||||||
|
+ '-DDISK_CACHE_KEY="@0@"'.format(
|
||||||
|
+ get_option('disk-cache-key')
|
||||||
|
+ ),
|
||||||
|
+ ],
|
||||||
|
gnu_symbol_visibility : 'hidden',
|
||||||
|
build_by_default : false
|
||||||
|
)
|
@ -0,0 +1,84 @@
|
|||||||
|
From bbd0f154183e4d26a14bb005f6afc636629c201e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thomas Watson <twatson52@icloud.com>
|
||||||
|
Date: Sat, 16 Dec 2023 20:46:51 -0600
|
||||||
|
Subject: [PATCH] opencl.patch from nixpkgs
|
||||||
|
f416128e90ac75bec060e8b9435fe9c38423c036
|
||||||
|
|
||||||
|
---
|
||||||
|
meson.build | 2 +-
|
||||||
|
meson_options.txt | 6 ++++++
|
||||||
|
src/gallium/targets/opencl/meson.build | 6 +++---
|
||||||
|
src/gallium/targets/rusticl/meson.build | 3 +--
|
||||||
|
4 files changed, 11 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/meson.build b/meson.build
|
||||||
|
index 552ff196aa8..9e10156b875 100644
|
||||||
|
--- a/meson.build
|
||||||
|
+++ b/meson.build
|
||||||
|
@@ -1829,7 +1829,7 @@ endif
|
||||||
|
|
||||||
|
dep_clang = null_dep
|
||||||
|
if with_clc
|
||||||
|
- llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')
|
||||||
|
+ llvm_libdir = get_option('clang-libdir')
|
||||||
|
|
||||||
|
dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
|
||||||
|
|
||||||
|
diff --git a/meson_options.txt b/meson_options.txt
|
||||||
|
index c76fa6d3382..d2021f55634 100644
|
||||||
|
--- a/meson_options.txt
|
||||||
|
+++ b/meson_options.txt
|
||||||
|
@@ -1,6 +1,12 @@
|
||||||
|
# Copyright © 2017-2019 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
+option(
|
||||||
|
+ 'clang-libdir',
|
||||||
|
+ type : 'string',
|
||||||
|
+ value : '',
|
||||||
|
+ description : 'Locations to search for clang libraries.'
|
||||||
|
+)
|
||||||
|
option(
|
||||||
|
'platforms',
|
||||||
|
type : 'array',
|
||||||
|
diff --git a/src/gallium/targets/opencl/meson.build b/src/gallium/targets/opencl/meson.build
|
||||||
|
index 7c14135898e..cbcd67cc443 100644
|
||||||
|
--- a/src/gallium/targets/opencl/meson.build
|
||||||
|
+++ b/src/gallium/targets/opencl/meson.build
|
||||||
|
@@ -39,7 +39,8 @@ if dep_llvm.version().version_compare('>=10.0.0')
|
||||||
|
polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)
|
||||||
|
endif
|
||||||
|
|
||||||
|
-dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
|
||||||
|
+clang_libdir = get_option('clang-libdir')
|
||||||
|
+dep_clang = cpp.find_library('clang-cpp', dirs : clang_libdir, required : false)
|
||||||
|
|
||||||
|
# meson will return clang-cpp from system dirs if it's not found in llvm_libdir
|
||||||
|
linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)
|
||||||
|
@@ -123,8 +124,7 @@ if with_opencl_icd
|
||||||
|
configuration : _config,
|
||||||
|
input : 'mesa.icd.in',
|
||||||
|
output : 'mesa.icd',
|
||||||
|
- install : true,
|
||||||
|
- install_tag : 'runtime',
|
||||||
|
+ install : false,
|
||||||
|
install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
|
||||||
|
)
|
||||||
|
|
||||||
|
diff --git a/src/gallium/targets/rusticl/meson.build b/src/gallium/targets/rusticl/meson.build
|
||||||
|
index b2963fe6dfa..2f784bdccd4 100644
|
||||||
|
--- a/src/gallium/targets/rusticl/meson.build
|
||||||
|
+++ b/src/gallium/targets/rusticl/meson.build
|
||||||
|
@@ -76,8 +76,7 @@ configure_file(
|
||||||
|
configuration : _config,
|
||||||
|
input : 'rusticl.icd.in',
|
||||||
|
output : 'rusticl.icd',
|
||||||
|
- install : true,
|
||||||
|
- install_tag : 'runtime',
|
||||||
|
+ install : false,
|
||||||
|
install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
|
||||||
|
)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
11
galvatron/apple-silicon-support/packages/overlay.nix
Normal file
11
galvatron/apple-silicon-support/packages/overlay.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
final: prev: {
|
||||||
|
linux-asahi = final.callPackage ./linux-asahi { };
|
||||||
|
m1n1 = final.callPackage ./m1n1 { };
|
||||||
|
uboot-asahi = final.callPackage ./uboot-asahi { };
|
||||||
|
asahi-fwextract = final.callPackage ./asahi-fwextract { };
|
||||||
|
mesa-asahi-edge = final.callPackage ./mesa-asahi-edge { inherit (prev) mesa; };
|
||||||
|
alsa-ucm-conf-asahi = final.callPackage ./alsa-ucm-conf-asahi { inherit (prev) alsa-ucm-conf; };
|
||||||
|
speakersafetyd = final.callPackage ./speakersafetyd { };
|
||||||
|
bankstown-lv2 = final.callPackage ./bankstown-lv2 { };
|
||||||
|
asahi-audio = final.callPackage ./asahi-audio { };
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
{ rustPlatform
|
||||||
|
, stdenv
|
||||||
|
, rust
|
||||||
|
, fetchCrate
|
||||||
|
, pkg-config
|
||||||
|
, alsa-lib
|
||||||
|
}:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "speakersafetyd";
|
||||||
|
# tracking: https://src.fedoraproject.org/rpms/rust-speakersafetyd
|
||||||
|
version = "0.1.9";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkg-config ];
|
||||||
|
buildInputs = [ alsa-lib ];
|
||||||
|
|
||||||
|
src = fetchCrate {
|
||||||
|
inherit pname version;
|
||||||
|
hash = "sha256-I1fL1U4vqKxPS1t6vujMTdi/JAAOCcPkvUqv6FqkId4=";
|
||||||
|
};
|
||||||
|
cargoHash = "sha256-Adwct+qFhUsOIao8XqNK2zcn13DBlQNA+X4aRFeIAXM=";
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace speakersafetyd.service --replace "/usr" "$out"
|
||||||
|
substituteInPlace Makefile --replace "target/release" "target/${rust.lib.toRustTargetSpec stdenv.hostPlatform}/$cargoBuildType"
|
||||||
|
'';
|
||||||
|
|
||||||
|
installFlags = [
|
||||||
|
"DESTDIR=${placeholder "out"}"
|
||||||
|
"BINDIR=/bin"
|
||||||
|
"SHAREDIR=/share"
|
||||||
|
"TMPFILESDIR=/lib/tmpfiles.d"
|
||||||
|
];
|
||||||
|
|
||||||
|
dontCargoInstall = true;
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
{ lib
|
||||||
|
, fetchFromGitHub
|
||||||
|
, buildUBoot
|
||||||
|
, m1n1
|
||||||
|
}:
|
||||||
|
|
||||||
|
(buildUBoot rec {
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
# tracking: https://pagure.io/fedora-asahi/uboot-tools/commits/main
|
||||||
|
owner = "AsahiLinux";
|
||||||
|
repo = "u-boot";
|
||||||
|
rev = "asahi-v2023.07.02-4";
|
||||||
|
hash = "sha256-M4qkEyNgwV2AKSr5VzPGfhHo1kGy8Tw8TfyP36cgYjc=";
|
||||||
|
};
|
||||||
|
version = "2023.07.02.asahi4-1";
|
||||||
|
|
||||||
|
defconfig = "apple_m1_defconfig";
|
||||||
|
extraMeta.platforms = [ "aarch64-linux" ];
|
||||||
|
filesToInstall = [
|
||||||
|
"u-boot-nodtb.bin.gz"
|
||||||
|
"m1n1-u-boot.bin"
|
||||||
|
];
|
||||||
|
extraConfig = ''
|
||||||
|
CONFIG_IDENT_STRING=" ${version}"
|
||||||
|
CONFIG_VIDEO_FONT_4X6=n
|
||||||
|
CONFIG_VIDEO_FONT_8X16=n
|
||||||
|
CONFIG_VIDEO_FONT_SUN12X22=n
|
||||||
|
CONFIG_VIDEO_FONT_16X32=y
|
||||||
|
'';
|
||||||
|
}).overrideAttrs (o: {
|
||||||
|
# nixos's downstream patches are not applicable
|
||||||
|
patches = [
|
||||||
|
];
|
||||||
|
|
||||||
|
# flag somehow breaks DTC compilation so we remove it
|
||||||
|
makeFlags = builtins.filter (s: s != "DTC=dtc") o.makeFlags;
|
||||||
|
|
||||||
|
preInstall = ''
|
||||||
|
# compress so that m1n1 knows U-Boot's size and can find things after it
|
||||||
|
gzip -n u-boot-nodtb.bin
|
||||||
|
cat ${m1n1}/build/m1n1.bin arch/arm/dts/t[68]*.dtb u-boot-nodtb.bin.gz > m1n1-u-boot.bin
|
||||||
|
'';
|
||||||
|
})
|
26
home.nix
26
home.nix
@ -26,12 +26,12 @@
|
|||||||
pkgs.nerdfonts
|
pkgs.nerdfonts
|
||||||
# pkgs.gnupg
|
# pkgs.gnupg
|
||||||
# pkgs.python3
|
# pkgs.python3
|
||||||
# (pkgs.python3.withPackages(
|
(pkgs.python3.withPackages(
|
||||||
# ps: with ps; [
|
ps: with ps; [
|
||||||
# epc sexpdata six pynput inflect
|
epc sexpdata six pynput inflect
|
||||||
# pyqt6
|
pyqt6
|
||||||
# # pyqt6-qt6
|
# pyqt6-qt6
|
||||||
# pyqt6-sip]))
|
pyqt6-sip]))
|
||||||
# (pkgs.emacsWithPackagesFromUsePackage {
|
# (pkgs.emacsWithPackagesFromUsePackage {
|
||||||
# package = pkgs.emacs29-pgtk;
|
# package = pkgs.emacs29-pgtk;
|
||||||
# config = ~/.emacs.d/init.el;
|
# config = ~/.emacs.d/init.el;
|
||||||
@ -123,13 +123,13 @@
|
|||||||
|
|
||||||
programs.gpg = {
|
programs.gpg = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# package = pkgs.gnupg.overrideAttrs (orig: {
|
package = pkgs.gnupg.overrideAttrs (orig: {
|
||||||
# version = "2.4.0";
|
version = "2.4.0";
|
||||||
# src = pkgs.fetchurl {
|
src = pkgs.fetchurl {
|
||||||
# url = "mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2";
|
url = "mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2";
|
||||||
# hash = "sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=";
|
hash = "sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=";
|
||||||
# };
|
};
|
||||||
# });
|
});
|
||||||
# agent = {
|
# agent = {
|
||||||
# pinentryFlavor = "gnome3";
|
# pinentryFlavor = "gnome3";
|
||||||
# };
|
# };
|
||||||
|
Loading…
Reference in New Issue
Block a user