fix: apple silicon (#205)

* fix: pavucontrol on apple-silicon

* fix: apple-silicon - touchbar
This commit is contained in:
Ryan Yin
2025-07-25 22:37:50 +08:00
committed by GitHub
parent 88f85bb5d7
commit 9bd5c5b727
5 changed files with 210 additions and 39 deletions

6
flake.lock generated
View File

@@ -754,11 +754,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1751984180,
"narHash": "sha256-LwWRsENAZJKUdD3SpLluwDmdXY9F45ZEgCb0X+xgOL0=",
"lastModified": 1753250450,
"narHash": "sha256-i+CQV2rPmP8wHxj0aq4siYyohHwVlsh40kV89f3nw1s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9807714d6944a957c2e036f84b0ff8caf9930bc0",
"rev": "fc02ee70efb805d3b2865908a13ddd4474557ecf",
"type": "github"
},
"original": {

View File

@@ -122,7 +122,7 @@
"scroll-step": 5.0,
// Commands to execute on events
"on-click": "amixer set Master toggle",
"on-click-right": "pavucontrol",
"on-click-right": "GSK_RENDERER=opengl pavucontrol",
"smooth-scrolling-threshold": 1,
},
"temperature": {

View File

@@ -0,0 +1,196 @@
{
pkgs-unstable,
nixos-apple-silicon,
my-asahi-firmware,
...
}:
{
imports = [
nixos-apple-silicon.nixosModules.default
];
networking.wireless.iwd = {
enable = true;
settings.General.EnableNetworkConfiguration = true;
};
# configures the network interface(include wireless) via `nmcli` & `nmtui`
networking.networkmanager.enable = true;
# Specify path to peripheral firmware files.
hardware.asahi = {
enable = true;
peripheralFirmwareDirectory = "${my-asahi-firmware}/macbook-pro-m2-a2338";
# build the Asahi Linux Kernel with Rust support
withRust = true;
# use apple-silicon's GPU instead of CPU
useExperimentalGPUDriver = true;
# How to install the Asahi Mesa driver
experimentalGPUInstallMode = "driver"; # driver / replace(for non-flakes) / overlay
};
hardware.apple.touchBar = {
enable = true;
package = pkgs-unstable.tiny-dfr;
# https://github.com/WhatAmISupposedToPutHere/tiny-dfr/blob/master/share/tiny-dfr/config.toml
settings = {
# F{number} keys are shown when Fn is not pressed by default.
# Set this to true if you want the media keys to be shown without Fn pressed
MediaLayerDefault = true;
# Set this to false if you want to hide the button outline,
# leaving only the text/logo
ShowButtonOutlines = true;
# Set this to true to slowly shift the entire screen contents.
# In theory this helps with screen longevity, but macos does not bother doing it
# Disabling ShowButtonOutlines will make this effect less noticeable to the eye
EnablePixelShift = true;
# This key defines the contents of the primary layer
# (the one with F{number} keys)
# You can change the individual buttons, add, or remove them
# Any number of keys that is greater than 0 is allowed
# however rendering will start to break around 24 keys
# Buttons can be made larger by setting the optional Stretch field
# to a number greater than 1 (which means the button will take up
# that many button spaces).
PrimaryLayerKeys = [
# Action defines the key code to send when the button is pressed
# Text defines the button label
# Icon specifies the icon to be used for the button.
# Theme specifies the XDG icons theme.
# Stretch specifies how many button spaces the button should take up
# and defaults to 1
# Icons can either be svgs or pngs, with svgs being preferred
# For best results with pngs, they should be 48x48
# Do not include the extension in the file name.
# If a Theme is set, icons are looked up in XDG_DATA_DIRS.
# Otherwise, they are first looked up in /etc/tiny-dfr, and then in /usr/share/tiny-dfr.
# Time can be either 24hr, or 12hr. Locale is optional and will default to POSIX.
# Only one of Text, Icon or Time is allowed,
# if both are present, the behavior is undefined.
# For the list of supported key codes see
# https://docs.rs/input-linux/latest/input_linux/enum.Key.html
# Note that the escape key is not specified here, as it is added
# automatically on Macs without a physical one
{
Text = "F1";
Action = "F1";
}
{
Text = "F2";
Action = "F2";
}
{
Text = "F3";
Action = "F3";
}
{
Text = "F4";
Action = "F4";
}
{
Text = "F5";
Action = "F5";
}
{
Text = "F6";
Action = "F6";
}
{
Text = "F7";
Action = "F7";
}
{
Text = "F8";
Action = "F8";
}
{
Text = "F9";
Action = "F9";
}
{
Text = "F10";
Action = "F10";
}
{
Text = "F11";
Action = "F11";
}
{
Text = "F12";
Action = "F12";
}
# for screenshot shortcut
{
Text = "Print";
Action = "Print";
}
];
# This key defines the contents of the media key layer
MediaLayerKeys = [
{
Icon = "brightness_low";
Action = "BrightnessDown";
}
{
Icon = "brightness_high";
Action = "BrightnessUp";
}
{
Icon = "mic_off";
Action = "MicMute";
}
{
Icon = "search";
Action = "Search";
}
{
Icon = "backlight_low";
Action = "IllumDown";
}
{
Icon = "backlight_high";
Action = "IllumUp";
}
{
Icon = "fast_rewind";
Action = "PreviousSong";
}
{
Icon = "play_pause";
Action = "PlayPause";
}
{
Icon = "fast_forward";
Action = "NextSong";
}
{
Icon = "volume_off";
Action = "Mute";
}
{
Icon = "volume_down";
Action = "VolumeDown";
}
{
Icon = "volume_up";
Action = "VolumeUp";
}
# for screenshot shortcut
{
Text = "Print";
Action = "Print";
}
];
};
};
# For ` to < and ~ to > (for those with US keyboards)
# boot.extraModprobeConfig = ''
# options hid_apple iso_layout=0
# '';
}

View File

@@ -1,4 +1,4 @@
{myvars, ...}:
{ myvars, ... }:
#############################################################
#
# Shoukei - NixOS running on Macbook Pro 2022 M2 16G
@@ -6,7 +6,8 @@
#############################################################
let
hostName = "shoukei"; # Define your hostname.
in {
in
{
imports = [
./hardware-configuration.nix
../idols-ai/preservation.nix
@@ -15,9 +16,6 @@ in {
networking = {
inherit hostName;
inherit (myvars.networking) nameservers;
# configures the network interface(include wireless) via `nmcli` & `nmtui`
networkmanager.enable = true;
};
# This value determines the NixOS release from which the default

View File

@@ -6,46 +6,23 @@
lib,
pkgs,
modulesPath,
nixos-apple-silicon,
my-asahi-firmware,
...
}: let
}:
let
device = "/dev/disk/by-uuid/c2e8b249-240e-4eef-bf4e-81e7dbbf4887";
in {
in
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
nixos-apple-silicon.nixosModules.default
./apple-silicon.nix
];
# Specify path to peripheral firmware files.
hardware.asahi = {
enable = true;
peripheralFirmwareDirectory = "${my-asahi-firmware}/macbook-pro-m2-a2338";
# build the Asahi Linux Kernel with Rust support
withRust = true;
# use apple-silicon's GPU instead of CPU
useExperimentalGPUDriver = true;
# How to install the Asahi Mesa driver
experimentalGPUInstallMode = "driver"; # driver / replace(for non-flakes) / overlay
};
networking.wireless.iwd = {
enable = true;
settings.General.EnableNetworkConfiguration = true;
};
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = false;
# depending on how you configured your disk mounts, change this to /boot or /boot/efi.
boot.loader.efi.efiSysMountPoint = "/boot";
# For ` to < and ~ to > (for those with US keyboards)
# boot.extraModprobeConfig = ''
# options hid_apple iso_layout=0
# '';
# supported file systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = lib.mkForce [
"ext4"
@@ -153,7 +130,7 @@ in {
# remount swapfile in read-write mode
fileSystems."/swap/swapfile" = {
# the swapfile is located in /swap subvolume, so we need to mount /swap first.
depends = ["/swap"];
depends = [ "/swap" ];
device = "/swap/swapfile";
fsType = "none";
@@ -164,7 +141,7 @@ in {
};
swapDevices = [
{device = "/swap/swapfile";}
{ device = "/swap/swapfile"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking