diff --git a/flake.lock b/flake.lock index 13a8483..a6d73a5 100644 --- a/flake.lock +++ b/flake.lock @@ -625,6 +625,26 @@ "type": "github" } }, + "musnix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1735772949, + "narHash": "sha256-lvee0rhKTpJEDl1SC4F3Kvz88snOU8OMTJBsPH1pVBo=", + "owner": "musnix", + "repo": "musnix", + "rev": "86ef22cbdd7551ef325bce88143be9f37da64c26", + "type": "github" + }, + "original": { + "owner": "musnix", + "repo": "musnix", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -887,6 +907,7 @@ "homebrew-cask": "homebrew-cask", "homebrew-core": "homebrew-core", "lanzaboote": "lanzaboote", + "musnix": "musnix", "nix-darwin": "nix-darwin", "nix-flatpak": "nix-flatpak", "nix-homebrew": "nix-homebrew", diff --git a/flake.nix b/flake.nix index 3149784..0280c9b 100755 --- a/flake.nix +++ b/flake.nix @@ -102,6 +102,11 @@ }; zenTyp.url = "github:youwen5/zen.typ"; + + musnix = { + url = "github:musnix/musnix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -171,6 +176,7 @@ inputs.nixos-wsl.nixosModules.default inputs.stylix.nixosModules.stylix inputs.agenix.nixosModules.age + inputs.musnix.nixosModules.musnix ./modules/default.nix ./overlays ( diff --git a/modules/linux/audio-prod/default.nix b/modules/linux/audio-prod/default.nix index 7aeadb8..3802bf2 100644 --- a/modules/linux/audio-prod/default.nix +++ b/modules/linux/audio-prod/default.nix @@ -6,25 +6,53 @@ }: let cfg = config.liminalOS.system.audio.prod; + forAllUsers = lib.genAttrs cfg.realtimeAudioUsers; in { - options.liminalOS.system.audio.prod.enable = lib.mkEnableOption "audio production"; + options.liminalOS.system.audio.prod = { + enable = lib.mkEnableOption "audio production"; + realtimeAudioUsers = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = '' + List of users to add to the audio group for realtime capabilities. + ''; + }; + }; - config = lib.mkIf cfg.enable { - liminalOS = { + config = { + liminalOS = lib.mkIf cfg.enable { programs.wine.enable = true; system.audio.enable = true; + config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [ + "reaper" + ]; }; - environment.systemPackages = with pkgs; [ - reaper - yabridge - yabridgectl - alsa-scarlett-gui - ]; + environment.systemPackages = lib.mkIf cfg.enable ( + (with pkgs; [ + yabridge + yabridgectl + alsa-scarlett-gui + ]) + ++ (lib.optionals config.liminalOS.config.allowUnfree [ + pkgs.reaper + ]) + ); - liminalOS.config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [ - "reaper" + musnix.enable = cfg.enable; + # PREEMPT_RT is merged into master + musnix.kernel.realtime = false; + + musnix.das_watchdog.enable = cfg.enable; + musnix.alsaSeq.enable = cfg.enable; + musnix.rtcqs.enable = cfg.enable; + users.users = forAllUsers (_: { + extraGroups = [ "audio" ]; + }); + + boot.kernelParams = lib.mkIf cfg.enable [ + "threadirqs" ]; }; } diff --git a/reference/hosts/adrastea/configuration.nix b/reference/hosts/adrastea/configuration.nix index 88210d2..99fdc9c 100755 --- a/reference/hosts/adrastea/configuration.nix +++ b/reference/hosts/adrastea/configuration.nix @@ -20,6 +20,7 @@ formFactor = "desktop"; system = { audio.prod.enable = true; + audio.prod.realtimeAudioUsers = [ "youwen" ]; networking = { firewallPresets.vite = true; cloudflareNameservers.enable = true; diff --git a/reference/hosts/demeter/configuration.nix b/reference/hosts/demeter/configuration.nix index 2a8e6a6..a53c027 100755 --- a/reference/hosts/demeter/configuration.nix +++ b/reference/hosts/demeter/configuration.nix @@ -20,6 +20,7 @@ formFactor = "desktop"; system = { audio.prod.enable = true; + audio.prod.realtimeAudioUsers = [ "youwen" ]; networking = { firewallPresets.vite = true; cloudflareNameservers.enable = true;