From 3726ba4f1170e62b92f780e697b5c65281447452 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Sun, 7 Aug 2022 18:42:28 +0200 Subject: [PATCH] add audio module --- home/home.nix | 45 ++++++++++-------------- home/modules/audio.nix | 78 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 27 deletions(-) create mode 100644 home/modules/audio.nix diff --git a/home/home.nix b/home/home.nix index 2cd85ffd..48a58bc6 100644 --- a/home/home.nix +++ b/home/home.nix @@ -11,26 +11,29 @@ rec { # Feel free to split up your configuration and import pieces of it here. ./modules/emacs.nix + ./modules/audio.nix # inputs.nixvim.homeManagerModules.nixvim ]; # Config my modules - modules = { - emacs.enable = true; - emacs.useDoom = true; - emacs.autosync = true; + modules.emacs = { + enable = true; + useDoom = true; + autosync = true; + }; + + modules.audio = { + enable = true; + carla = true; + yabridge.enable = true; + yabridge.autosync = true; }; # TODO: Email # TODO: Run noisetorch as login script # TODO: Gnome terminal config - # TODO: Update flatpak on rebuild? Make a setting/module for this, emacs update and yabridgectl update... Use home.activation... - home.activation.syncYabridge = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - yabridgectl sync - ''; - # Disabled since HomeManager should use global pkgs # https://github.com/nix-community/home-manager/issues/2942 # nixpkgs.config.allowUnfreePredicate = (pkg: true); @@ -49,6 +52,8 @@ rec { # NOTE: I don't think I need this anymore as all fonts are installed through the system config but let's keep this just in case fonts.fontconfig.enable = true; # Also updates the font-cache + # TODO: Add to flatpak module + # TODO: Update flatpak on rebuild? # We link like this to be able to address the absolute location, also the fonts won't get copied to store # NOTE: This path contains all the fonts because fonts.fontDir.enable is true home.activation.linkFontDir = lib.hm.dag.entryAfter [ "writeBoundary" ] '' @@ -63,7 +68,6 @@ rec { ln -sf /etc/profiles/per-user/christoph/share/icons ${home.homeDirectory}/.local/share/icons fi ''; - # Allow access to linked fonts/icons home.file.".local/share/flatpak/overrides/global".text = '' [Context] @@ -89,19 +93,7 @@ rec { in formatted; - # TODO: Music module - # NOTE: This desktop entry is created in /etc/profiles/per-user/christoph/share/applications - # This location is part of XDG_DATA_DIRS - xdg.desktopEntries.guitar = { - name = "Guitar Amp (Carla)"; - genericName = "Guitar Amp Simulation"; - icon = "carla"; - exec = "env PIPEWIRE_LATENCY=256/48000 gamemoderun carla ${home.homeDirectory}/Documents/Carla/GuitarDefault.carxp"; - terminal = false; - categories = [ "Music" "Audio" ]; - }; - - # TODO: Does this has to be set manually or is it set by flatpak.enable? + # NOTE: Is set by flatpak.enable # xdg.systemDirs.data = [ # "/var/lib/flatpak/exports/share" # "${home.homeDirectory}/.local/share/flatpak/exports/share" @@ -273,13 +265,12 @@ rec { # godot # Audio - # TODO: Make a module, autosync yabridge on rebuild? # vcv-rack bitwig-studio # audacity - carla - yabridge - yabridgectl + # Module carla + # Module yabridge + # Module yabridgectl # Use NixCommunity binary cache cachix diff --git a/home/modules/audio.nix b/home/modules/audio.nix new file mode 100644 index 00000000..edc813f7 --- /dev/null +++ b/home/modules/audio.nix @@ -0,0 +1,78 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.modules.audio; +in { + imports = [ ]; + + options.modules.audio = { + enable = mkOption { + type = types.bool; + default = false; + description = "Configure for realtime audio and enable a bunch of music production tools"; + }; + + carla = mkOption { + type = types.bool; + default = false; + description = "Enable Carla + guitar-specific stuff"; + }; + + yabridge = { + enable = { + type = types.bool; + default = false; + description = "Enable yabridge + yabridgectl"; + }; + + autosync = { + type = types.bool; + default = false; + description = "Sync yabridge plugins on nixos-rebuild"; + }; + }; + }; + + config = mkIf cfg.enable { + + home.packages = with pkgs; (mkMerge [ + (mkIf cfg.carla [ carla ]) + + (mkIf cfg.yabridge.enable [ yabridge yabridgectl ]) + ]); + + + # NOTE: This desktop entry is created in /etc/profiles/per-user/christoph/share/applications + # This location is part of XDG_DATA_DIRS + xdg.desktopEntries.guitar = mkIf cfg.carla { + name = "Guitar Amp (Carla)"; + genericName = "Guitar Amp Simulation"; + icon = "carla"; + exec = "env PIPEWIRE_LATENCY=256/48000 gamemoderun carla ${home.homeDirectory}/.config/carla/GuitarDefault.carxp"; + terminal = false; + categories = [ "Music" "Audio" ]; + }; + + home.activation = (mkMerge [ + (mkIf cfg.carla { + + # The module includes the default carla project with ArchetypePetrucci + ArchetypeGojira + # TODO: I don't know if I should keep this + linkCarlaConfig = hm.dag.entryAfter [ "writeBoundary" ] '' + if [ ! -L "${config.home.homeDirectory}/.config/carla" ]; then + ln -sf ${config.home.homeDirectory}/NixFlake/config/carla ${config.home.homeDirectory}/.config/carla + fi + ''; + }) + + (mkIf cfg.yabridge.autosync { + syncYabridge = hm.dag.entryAfter [ "writeBoundary" ] '' + yabridgectl sync + ''; + }) + ]); + + }; +}