From aaf47f1d846e1c0af5dc64d4caaed2213fbd64f3 Mon Sep 17 00:00:00 2001 From: Annika Merris Date: Sat, 25 May 2024 08:57:34 -0400 Subject: [PATCH] Moving Basic Audio Config To nixos Module --- hosts/envy/audio.nix | 30 ++++++++++++++++++++++++++++++ hosts/envy/default.nix | 24 ++++++++++++------------ hosts/envy/gui.nix | 15 +++++++++++++++ hosts/kim/audio.nix | 17 +---------------- hosts/kim/default.nix | 3 +++ modules/nixos/hardware/audio.nix | 29 +++++++++++++++++++++++++++++ modules/nixos/hardware/default.nix | 1 + 7 files changed, 91 insertions(+), 28 deletions(-) create mode 100644 hosts/envy/audio.nix create mode 100644 hosts/envy/gui.nix create mode 100644 modules/nixos/hardware/audio.nix diff --git a/hosts/envy/audio.nix b/hosts/envy/audio.nix new file mode 100644 index 0000000..9f149a1 --- /dev/null +++ b/hosts/envy/audio.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: +{ + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + systemd.user.services.pipewire-patching = { + enable = true; + description = "pipewire patches"; + + wantedBy = [ "default.target" ]; + + script = '' + ${pkgs.pipewire}/bin/pw-link alsa_input.pci-0000_0e_00.4.analog-stereo:capture_FL alsa_output.pci-0000_0e_00.4.iec958-stereo:playback_FL + ${pkgs.pipewire}/bin/pw-link alsa_input.pci-0000_0e_00.4.analog-stereo:capture_FR alsa_output.pci-0000_0e_00.4.iec958-stereo:playback_FR + ''; + }; +} diff --git a/hosts/envy/default.nix b/hosts/envy/default.nix index 96616df..de9e089 100644 --- a/hosts/envy/default.nix +++ b/hosts/envy/default.nix @@ -13,6 +13,7 @@ inputs.nixpkgs.lib.nixosSystem { home-manager.nixosModules.home-manager sops-nix.nixosModules.sops ./hardware-configuration.nix + ./gui.nix ../../modules/common ../../modules/nixos { @@ -36,26 +37,16 @@ inputs.nixpkgs.lib.nixosSystem { }; # TODO: Temporary, remove eventually! - networking.networkmanager.enable = true; time.timeZone = "America/New_York"; nix.settings.experimental-features = [ "nix-command" "flakes" ]; - services.xserver.enable = true; - services.displayManager.sddm.enable = true; - services.xserver.desktopManager.plasma5.enable = true; - services.xserver.xkb = { - layout = "us"; - variant = ""; - }; users.users.annika = { isNormalUser = true; description = "Annika Merris"; - extraGroups = [ "networkmanager" "wheel" ]; + extraGroups = [ "networkmanager" "wheel" "audio" ]; }; nixpkgs.config.allowUnfree = true; system.stateVersion = "23.11"; home-manager.backupFileExtension = "backup"; - services.openssh.enable = true; - services.flatpak.enable = true; hardware.bluetooth.enable = true; hardware.bluetooth.powerOnBoot = true; # Enable sound with pipewire. @@ -75,8 +66,17 @@ inputs.nixpkgs.lib.nixosSystem { #media-session.enable = true; }; + services.openssh = { + enable = true; + hostKeys = [ + { + path = "/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + } + ]; + }; - gui.enable = true; + services.flatpak.enable = true; # Apps discord.enable = true; element.enable = true; diff --git a/hosts/envy/gui.nix b/hosts/envy/gui.nix new file mode 100644 index 0000000..d89d294 --- /dev/null +++ b/hosts/envy/gui.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: +{ + gui.enable = true; + + services.xserver.enable = true; + services.displayManager.sddm.enable = true; + services.xserver = { + desktopManager.plasma5.enable = true; + xkb = { + layout = "us"; + variant = ""; + }; + }; + networking.networkmanager.enable = true; +} diff --git a/hosts/kim/audio.nix b/hosts/kim/audio.nix index 9f149a1..2ff3e6d 100644 --- a/hosts/kim/audio.nix +++ b/hosts/kim/audio.nix @@ -1,21 +1,6 @@ { config, lib, pkgs, ... }: { - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; + # Enable a passthrough from kim's line in port to her optical output. systemd.user.services.pipewire-patching = { enable = true; description = "pipewire patches"; diff --git a/hosts/kim/default.nix b/hosts/kim/default.nix index 76187af..029a7b7 100644 --- a/hosts/kim/default.nix +++ b/hosts/kim/default.nix @@ -53,6 +53,9 @@ inputs.nixpkgs.lib.nixosSystem { hardware.bluetooth.enable = true; hardware.bluetooth.powerOnBoot = true; + # Enable hardware features + audio.enable = true; + services.openssh.enable = true; services.flatpak.enable = true; # Apps diff --git a/modules/nixos/hardware/audio.nix b/modules/nixos/hardware/audio.nix new file mode 100644 index 0000000..6a49048 --- /dev/null +++ b/modules/nixos/hardware/audio.nix @@ -0,0 +1,29 @@ +{ config, lib, pkgs, ... }: +{ + options = { + audio = { + enable = lib.mkEnableOption { + description = "Enable audio via pipewire"; + default = false; + }; + }; + }; + config = lib.mkIf (config.audio.enable) { + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + }; +} diff --git a/modules/nixos/hardware/default.nix b/modules/nixos/hardware/default.nix index f760ee4..f060663 100644 --- a/modules/nixos/hardware/default.nix +++ b/modules/nixos/hardware/default.nix @@ -1,6 +1,7 @@ { lib, ... }: { imports = [ + ./audio.nix ./boot.nix ];