chore: format repo using treefmt-nix and nixfmt-rfc-style

This commit is contained in:
Andre
2025-06-04 12:11:03 -04:00
parent fc7c471412
commit 51e51e6014
266 changed files with 3721 additions and 2733 deletions

View File

@@ -1,4 +1,5 @@
{ lib, pkgs, ...}: {
{ lib, pkgs, ... }:
{
imports = [
../common
../common/intel.nix
@@ -6,7 +7,10 @@
# Requires at least 5.16 for working wi-fi and bluetooth.
# https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.16") (lib.mkDefault pkgs.linuxPackages_latest);
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.16") (
lib.mkDefault pkgs.linuxPackages_latest
);
hardware.framework.laptop13.audioEnhancement.rawDeviceName = lib.mkDefault "alsa_output.pci-0000_00_1f.3.analog-stereo";
hardware.framework.laptop13.audioEnhancement.rawDeviceName =
lib.mkDefault "alsa_output.pci-0000_00_1f.3.analog-stereo";
}

View File

@@ -9,7 +9,8 @@
{
hardware.intelgpu.loadInInitrd = lib.versionOlder config.boot.kernelPackages.kernel.version "6.2";
# same as 13th gen framework 13-inch
hardware.framework.laptop13.audioEnhancement.rawDeviceName = lib.mkDefault "alsa_output.pci-0000_00_1f.3.analog-stereo";
hardware.framework.laptop13.audioEnhancement.rawDeviceName =
lib.mkDefault "alsa_output.pci-0000_00_1f.3.analog-stereo";
}
# https://community.frame.work/t/tracking-hard-freezing-on-fedora-36-with-the-new-12th-gen-system/20675/391
(lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.2") {

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.framework.amd-7040;
@@ -27,12 +32,15 @@ in
config = {
# Workaround applied upstream in Linux >=6.7 (on BIOS 03.03)
# https://github.com/torvalds/linux/commit/a55bdad5dfd1efd4ed9ffe518897a21ca8e4e193
services.udev.extraRules = lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.7" && cfg.preventWakeOnAC) ''
# Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See:
# https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45
ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled"
'';
services.udev.extraRules =
lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.7" && cfg.preventWakeOnAC)
''
# Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See:
# https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45
ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled"
'';
hardware.framework.laptop13.audioEnhancement.rawDeviceName = lib.mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo";
hardware.framework.laptop13.audioEnhancement.rawDeviceName =
lib.mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo";
};
}

View File

@@ -1,9 +1,15 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
imports = [
../common
../common/amd.nix
];
config.hardware.framework.laptop13.audioEnhancement.rawDeviceName = lib.mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo";
config.hardware.framework.laptop13.audioEnhancement.rawDeviceName =
lib.mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo";
}

View File

@@ -1,4 +1,5 @@
{ lib, config, ... }: {
{ lib, config, ... }:
{
imports = [
../../../common/cpu/amd
../../../common/cpu/amd/pstate.nix
@@ -15,7 +16,9 @@
"amdgpu.dcdebugmask=0x10"
]
# Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") ["rtc_cmos.use_acpi_alarm=1"];
++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [
"rtc_cmos.use_acpi_alarm=1"
];
# AMD has better battery life with PPD over TLP:
# https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.hardware.framework.laptop13.audioEnhancement;
in
@@ -51,332 +56,335 @@ in
};
};
config = lib.mkIf cfg.enable (let
outputName = cfg.rawDeviceName;
prettyName = "Framework Speakers";
config = lib.mkIf cfg.enable (
let
outputName = cfg.rawDeviceName;
prettyName = "Framework Speakers";
# These are pre-made decibel to linear value conversions, since Nix doesn't have pow().
# Use the formula `10 ** (db / 20)` to calculate.
db = {
"-18.1" = 0.1244514611771385;
"-5.48" = 0.5321082592667942;
"-4.76" = 0.5780960474057181;
"8.1" = 2.5409727055493048;
"-36" = 1.5848931924611134e-2;
};
json = pkgs.formats.json { };
# The filter chain, heavily inspired by the asahi-audio project: https://github.com/AsahiLinux/asahi-audio
filter-chain = json.generate "filter-chain.json" {
"node.description" = prettyName;
"media.name" = prettyName;
"filter.graph" = {
nodes = [
# Psychoacoustic bass extension,
# it creates harmonics of the missing bass to fool our ears into hearing it.
{
type = "lv2";
plugin = "https://chadmed.au/bankstown";
name = "bassex";
control = {
bypass = 0;
amt = 1.2;
sat_second = 1.3;
sat_third = 2.5;
blend = 1.0;
ceil = 200.0;
floor = 20.0;
};
}
# Loudness compensation,
# it ensures that the sound profile stays consistent across different volumes.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/loud_comp_stereo";
name = "el";
control = {
enabled = 1;
input = 1.0;
fft = 4;
};
}
# 8-band equalizer,
# it tries to lessen frequencies where the laptop might resonate,
# and tries to make the frequency curve more pleasing;
# this is the "Lappy McTopface" profile (https://github.com/ceiphr/ee-framework-presets)
# further tuned for the Framework Laptop 13 AMD 7040 series
# and might need some tuning on other models.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/para_equalizer_x8_lr";
name = "fw13eq";
control = {
mode = 0;
react = 0.2;
zoom = db."-36";
fl_0 = 101.0;
fml_0 = 0;
ftl_0 = 5;
gl_0 = db."-18.1";
huel_0 = 0.0;
ql_0 = 4.36;
sl_0 = 0;
wl_0 = 4.0;
fl_1 = 451.0;
fml_1 = 0;
ftl_1 = 1;
gl_1 = db."-5.48";
huel_1 = 3.125e-2;
ql_1 = 2.46;
sl_1 = 0;
wl_1 = 4.0;
fl_2 = 918.0;
fml_2 = 0;
ftl_2 = 1;
gl_2 = db."-4.76";
huel_2 = 6.25e-2;
ql_2 = 2.44;
sl_2 = 0;
wl_2 = 4.0;
fl_3 = 9700.0;
fml_3 = 0;
ftl_3 = 1;
gl_3 = db."8.1";
huel_3 = 9.375e-2;
ql_3 = 2.0;
sl_3 = 0;
wl_3 = 4.0;
fr_0 = 101.0;
fmr_0 = 0;
ftr_0 = 5;
gr_0 = db."-18.1";
huer_0 = 0.0;
qr_0 = 4.36;
sr_0 = 0;
wr_0 = 4.0;
fr_1 = 451.0;
fmr_1 = 0;
ftr_1 = 1;
gr_1 = db."-5.48";
huer_1 = 3.125e-2;
qr_1 = 2.46;
sr_1 = 0;
wr_1 = 4.0;
fr_2 = 918.0;
fmr_2 = 0;
ftr_2 = 1;
gr_2 = db."-4.76";
huer_2 = 6.25e-2;
qr_2 = 2.44;
sr_2 = 0;
wr_2 = 4.0;
fr_3 = 9700.0;
fmr_3 = 0;
ftr_3 = 1;
gr_3 = db."8.1";
huer_3 = 9.375e-2;
qr_3 = 2.0;
sr_3 = 0;
wr_3 = 4.0;
};
}
# Compressors. The settings were taken from the asahi-audio project.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/mb_compressor_stereo";
name = "woofer_bp";
control = {
mode = 0;
ce_0 = 1;
sla_0 = 5.0;
cr_0 = 1.75;
al_0 = 0.725;
at_0 = 1.0;
rt_0 = 100;
kn_0 = 0.125;
cbe_1 = 1;
sf_1 = 200.0;
ce_1 = 0;
cbe_2 = 0;
ce_2 = 0;
cbe_3 = 0;
ce_3 = 0;
cbe_4 = 0;
ce_4 = 0;
cbe_5 = 0;
ce_5 = 0;
cbe_6 = 0;
ce_6 = 0;
};
}
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/compressor_stereo";
name = "woofer_lim";
control = {
sla = 5.0;
al = 1.0;
at = 1.0;
rt = 100.0;
cr = 15.0;
kn = 0.5;
};
}
];
# Now, we're chaining together the modules instantiated above.
links = [
{
output = "bassex:out_l";
input = "el:in_l";
}
{
output = "bassex:out_r";
input = "el:in_r";
}
{
output = "el:out_l";
input = "fw13eq:in_l";
}
{
output = "el:out_r";
input = "fw13eq:in_r";
}
{
output = "fw13eq:out_l";
input = "woofer_bp:in_l";
}
{
output = "fw13eq:out_r";
input = "woofer_bp:in_r";
}
{
output = "woofer_bp:out_l";
input = "woofer_lim:in_l";
}
{
output = "woofer_bp:out_r";
input = "woofer_lim:in_r";
}
];
inputs = [
"bassex:in_l"
"bassex:in_r"
];
outputs = [
"woofer_lim:out_l"
"woofer_lim:out_r"
];
# This makes pipewire's volume control actually control the loudness comp module
"capture.volumes" = [
{
control = "el:volume";
min = -47.5;
max = 0.0;
scale = "cubic";
}
];
# These are pre-made decibel to linear value conversions, since Nix doesn't have pow().
# Use the formula `10 ** (db / 20)` to calculate.
db = {
"-18.1" = 0.1244514611771385;
"-5.48" = 0.5321082592667942;
"-4.76" = 0.5780960474057181;
"8.1" = 2.5409727055493048;
"-36" = 1.5848931924611134e-2;
};
"capture.props" = {
"node.name" = "audio_effect.laptop-convolver";
"media.class" = "Audio/Sink";
"audio.channels" = "2";
"audio.position" = [
"FL"
"FR"
];
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"device.api" = "dsp";
"node.virtual" = "false";
# Lower seems to mean "more preferred",
# bluetooth devices seem to be ~1000, speakers seem to be ~2000
# since this is between the two, bluetooth devices take over when they connect,
# and hand over to this instead of the speakers when they disconnect.
"priority.session" = 1500;
"priority.driver" = 1500;
"state.default-volume" = 0.343;
"device.icon-name" = "audio-card-analog-pci";
};
"playback.props" = {
"node.name" = "audio_effect.laptop-convolver";
"target.object" = outputName;
"node.passive" = "true";
"audio.channels" = "2";
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"audio.position" = [
"FL"
"FR"
];
"device.icon-name" = "audio-card-analog-pci";
};
};
json = pkgs.formats.json { };
configPackage =
(pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/99-laptop.conf" ''
monitor.alsa.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
update-props = {
audio.allowed-rates = [44100, 48000, 88200, 96000, 176400, 192000]
# The filter chain, heavily inspired by the asahi-audio project: https://github.com/AsahiLinux/asahi-audio
filter-chain = json.generate "filter-chain.json" {
"node.description" = prettyName;
"media.name" = prettyName;
"filter.graph" = {
nodes = [
# Psychoacoustic bass extension,
# it creates harmonics of the missing bass to fool our ears into hearing it.
{
type = "lv2";
plugin = "https://chadmed.au/bankstown";
name = "bassex";
control = {
bypass = 0;
amt = 1.2;
sat_second = 1.3;
sat_third = 2.5;
blend = 1.0;
ceil = 200.0;
floor = 20.0;
};
}
# Loudness compensation,
# it ensures that the sound profile stays consistent across different volumes.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/loud_comp_stereo";
name = "el";
control = {
enabled = 1;
input = 1.0;
fft = 4;
};
}
# 8-band equalizer,
# it tries to lessen frequencies where the laptop might resonate,
# and tries to make the frequency curve more pleasing;
# this is the "Lappy McTopface" profile (https://github.com/ceiphr/ee-framework-presets)
# further tuned for the Framework Laptop 13 AMD 7040 series
# and might need some tuning on other models.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/para_equalizer_x8_lr";
name = "fw13eq";
control = {
mode = 0;
react = 0.2;
zoom = db."-36";
fl_0 = 101.0;
fml_0 = 0;
ftl_0 = 5;
gl_0 = db."-18.1";
huel_0 = 0.0;
ql_0 = 4.36;
sl_0 = 0;
wl_0 = 4.0;
fl_1 = 451.0;
fml_1 = 0;
ftl_1 = 1;
gl_1 = db."-5.48";
huel_1 = 3.125e-2;
ql_1 = 2.46;
sl_1 = 0;
wl_1 = 4.0;
fl_2 = 918.0;
fml_2 = 0;
ftl_2 = 1;
gl_2 = db."-4.76";
huel_2 = 6.25e-2;
ql_2 = 2.44;
sl_2 = 0;
wl_2 = 4.0;
fl_3 = 9700.0;
fml_3 = 0;
ftl_3 = 1;
gl_3 = db."8.1";
huel_3 = 9.375e-2;
ql_3 = 2.0;
sl_3 = 0;
wl_3 = 4.0;
fr_0 = 101.0;
fmr_0 = 0;
ftr_0 = 5;
gr_0 = db."-18.1";
huer_0 = 0.0;
qr_0 = 4.36;
sr_0 = 0;
wr_0 = 4.0;
fr_1 = 451.0;
fmr_1 = 0;
ftr_1 = 1;
gr_1 = db."-5.48";
huer_1 = 3.125e-2;
qr_1 = 2.46;
sr_1 = 0;
wr_1 = 4.0;
fr_2 = 918.0;
fmr_2 = 0;
ftr_2 = 1;
gr_2 = db."-4.76";
huer_2 = 6.25e-2;
qr_2 = 2.44;
sr_2 = 0;
wr_2 = 4.0;
fr_3 = 9700.0;
fmr_3 = 0;
ftr_3 = 1;
gr_3 = db."8.1";
huer_3 = 9.375e-2;
qr_3 = 2.0;
sr_3 = 0;
wr_3 = 4.0;
};
}
# Compressors. The settings were taken from the asahi-audio project.
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/mb_compressor_stereo";
name = "woofer_bp";
control = {
mode = 0;
ce_0 = 1;
sla_0 = 5.0;
cr_0 = 1.75;
al_0 = 0.725;
at_0 = 1.0;
rt_0 = 100;
kn_0 = 0.125;
cbe_1 = 1;
sf_1 = 200.0;
ce_1 = 0;
cbe_2 = 0;
ce_2 = 0;
cbe_3 = 0;
ce_3 = 0;
cbe_4 = 0;
ce_4 = 0;
cbe_5 = 0;
ce_5 = 0;
cbe_6 = 0;
ce_6 = 0;
};
}
{
type = "lv2";
plugin = "http://lsp-plug.in/plugins/lv2/compressor_stereo";
name = "woofer_lim";
control = {
sla = 5.0;
al = 1.0;
at = 1.0;
rt = 100.0;
cr = 15.0;
kn = 0.5;
};
}
];
# Now, we're chaining together the modules instantiated above.
links = [
{
output = "bassex:out_l";
input = "el:in_l";
}
{
output = "bassex:out_r";
input = "el:in_r";
}
{
output = "el:out_l";
input = "fw13eq:in_l";
}
{
output = "el:out_r";
input = "fw13eq:in_r";
}
{
output = "fw13eq:out_l";
input = "woofer_bp:in_l";
}
{
output = "fw13eq:out_r";
input = "woofer_bp:in_r";
}
{
output = "woofer_bp:out_l";
input = "woofer_lim:in_l";
}
{
output = "woofer_bp:out_r";
input = "woofer_lim:in_r";
}
];
inputs = [
"bassex:in_l"
"bassex:in_r"
];
outputs = [
"woofer_lim:out_l"
"woofer_lim:out_r"
];
# This makes pipewire's volume control actually control the loudness comp module
"capture.volumes" = [
{
control = "el:volume";
min = -47.5;
max = 0.0;
scale = "cubic";
}
];
};
"capture.props" = {
"node.name" = "audio_effect.laptop-convolver";
"media.class" = "Audio/Sink";
"audio.channels" = "2";
"audio.position" = [
"FL"
"FR"
];
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"device.api" = "dsp";
"node.virtual" = "false";
# Lower seems to mean "more preferred",
# bluetooth devices seem to be ~1000, speakers seem to be ~2000
# since this is between the two, bluetooth devices take over when they connect,
# and hand over to this instead of the speakers when they disconnect.
"priority.session" = 1500;
"priority.driver" = 1500;
"state.default-volume" = 0.343;
"device.icon-name" = "audio-card-analog-pci";
};
"playback.props" = {
"node.name" = "audio_effect.laptop-convolver";
"target.object" = outputName;
"node.passive" = "true";
"audio.channels" = "2";
"audio.allowed-rates" = [
44100
48000
88200
96000
176400
192000
];
"audio.position" = [
"FL"
"FR"
];
"device.icon-name" = "audio-card-analog-pci";
};
};
configPackage =
(pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/99-laptop.conf" ''
monitor.alsa.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
update-props = {
audio.allowed-rates = [44100, 48000, 88200, 96000, 176400, 192000]
}
}
}
}
]
]
node.software-dsp.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
create-filter = {
filter-path = "${filter-chain}"
hide-parent = ${lib.boolToString cfg.hideRawDevice}
node.software-dsp.rules = [
{
matches = [{ node.name = "${outputName}" }]
actions = {
create-filter = {
filter-path = "${filter-chain}"
hide-parent = ${lib.boolToString cfg.hideRawDevice}
}
}
}
]
wireplumber.profiles = {
main = { node.software-dsp = "required" }
}
]
'')
// {
passthru.requiredLv2Packages = with pkgs; [
lsp-plugins
bankstown-lv2
];
};
in
{
services.pipewire.wireplumber.configPackages = [ configPackage ];
wireplumber.profiles = {
main = { node.software-dsp = "required" }
}
'')
// {
passthru.requiredLv2Packages = with pkgs; [
lsp-plugins
bankstown-lv2
];
};
in {
services.pipewire.wireplumber.configPackages = [ configPackage ];
# Pipewire is needed for this.
services.pipewire.enable = lib.mkDefault true;
});
# Pipewire is needed for this.
services.pipewire.enable = lib.mkDefault true;
}
);
}

View File

@@ -1,21 +1,30 @@
{ config, lib, pkgs, ... }: {
{
config,
lib,
pkgs,
...
}:
{
imports = [
../../../common/cpu/intel
];
boot.kernelParams = [
# For Power consumption
# https://community.frame.work/t/linux-battery-life-tuning/6665/156
"nvme.noacpi=1"
]
# Fixes a regression in s2idle, making it more power efficient than deep sleep
# Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM)
# (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657)
++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\"";
boot.kernelParams =
[
# For Power consumption
# https://community.frame.work/t/linux-battery-life-tuning/6665/156
"nvme.noacpi=1"
]
# Fixes a regression in s2idle, making it more power efficient than deep sleep
# Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM)
# (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657)
++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\"";
# Requires at least 5.16 for working wi-fi and bluetooth.
# https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.16") (lib.mkDefault pkgs.linuxPackages_latest);
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.16") (
lib.mkDefault pkgs.linuxPackages_latest
);
# Module is not used for Framework EC but causes boot time error log.
boot.blacklistedKernelModules = [ "cros-usbpd-charger" ];

View File

@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
{
imports = [
@@ -8,7 +13,9 @@
# Need at least 6.9 to make suspend properly
# Specifically this patch: https://github.com/torvalds/linux/commit/073237281a508ac80ec025872ad7de50cfb5a28a
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.9") (lib.mkDefault pkgs.linuxPackages_latest);
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.9") (
lib.mkDefault pkgs.linuxPackages_latest
);
# Intel NPU Driver
# https://discourse.nixos.org/t/new-installation-on-asus-zenbook-ux5406-intel-vpu-firmware-error-2/58732/2
@@ -32,6 +39,6 @@
warnings = lib.mkIf (!config.hardware.enableRedistributableFirmware) [
''For Intel NPU support, set the option: hardware.enableRedistributableFirmware = true;''
];
];
}