Skip to content

Commit

Permalink
modules: add hardware.asahi.enable (true by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpwrules committed Mar 12, 2024
1 parent 2aa4089 commit 09b0a8e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apple-silicon-support/modules/boot-m1n1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let
'';
};
in {
config = {
config = lib.mkIf config.hardware.asahi.enable {
# install m1n1 with the boot loader
boot.loader.grub.extraFiles = bootFiles;
boot.loader.systemd-boot.extraFiles = bootFiles;
Expand Down
13 changes: 10 additions & 3 deletions apple-silicon-support/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
./sound
];

config =
let
config = let
cfg = config.hardware.asahi;
in {
in lib.mkIf cfg.enable {
nixpkgs.overlays = lib.mkBefore [ cfg.overlay ];

hardware.asahi.pkgs =
Expand All @@ -26,6 +25,14 @@
};

options.hardware.asahi = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable the basic Asahi Linux components, such as kernel and boot setup.
'';
};

pkgsSystem = lib.mkOption {
type = lib.types.str;
default = "aarch64-linux";
Expand Down
2 changes: 1 addition & 1 deletion apple-silicon-support/modules/kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{ config, pkgs, lib, ... }:
{
config = {
config = lib.mkIf config.hardware.asahi.enable {
boot.kernelPackages = let
pkgs' = config.hardware.asahi.pkgs;
in
Expand Down
4 changes: 2 additions & 2 deletions apple-silicon-support/modules/mesa/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
config = let
isMode = mode: (config.hardware.asahi.useExperimentalGPUDriver
&& config.hardware.asahi.experimentalGPUInstallMode == mode);
in lib.mkMerge [
in lib.mkIf config.hardware.asahi.enable (lib.mkMerge [
{
# required for proper DRM setup even without GPU driver
services.xserver.config = ''
Expand Down Expand Up @@ -41,7 +41,7 @@
})
];
})
];
]);

options.hardware.asahi.useExperimentalGPUDriver = lib.mkOption {
type = lib.types.bool;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }:
{
config = {
config = lib.mkIf config.hardware.asahi.enable {
assertions = lib.mkIf config.hardware.asahi.extractPeripheralFirmware [
{ assertion = config.hardware.asahi.peripheralFirmwareDirectory != null;
message = ''
Expand Down
8 changes: 5 additions & 3 deletions apple-silicon-support/modules/sound/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# 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; }
{ config.hardware.pulseaudio.enable = (!config.hardware.asahi.enable); }
];

options.hardware.asahi = {
setupAsahiSound = lib.mkOption {
type = lib.types.bool;
default = config.sound.enable;
default = config.sound.enable && config.hardware.asahi.enable;
description = ''
Set up the Asahi DSP components so that the speakers and headphone jack
work properly and safely.
Expand All @@ -20,6 +20,8 @@
};

config = let
cfg = config.hardware.asahi;

asahi-audio = pkgs.asahi-audio; # the asahi-audio we use

lsp-plugins = pkgs.lsp-plugins; # the lsp-plugins we use
Expand All @@ -39,7 +41,7 @@
newHotness = builtins.hasAttr "configPackages" options.services.pipewire;

lv2Path = lib.makeSearchPath "lib/lv2" [ lsp-plugins pkgs.bankstown-lv2 ];
in lib.mkIf config.hardware.asahi.setupAsahiSound (lib.mkMerge [
in lib.mkIf (cfg.setupAsahiSound && cfg.enable) (lib.mkMerge [
{
# enable pipewire to run real-time and avoid audible glitches
security.rtkit.enable = true;
Expand Down

0 comments on commit 09b0a8e

Please sign in to comment.