feat: add musnix for realtime audio

This commit is contained in:
Youwen Wu 2025-01-23 23:03:54 -08:00
parent af59cdd252
commit ccf58bcf15
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
5 changed files with 68 additions and 11 deletions

View file

@ -625,6 +625,26 @@
"type": "github" "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": { "nix-darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -887,6 +907,7 @@
"homebrew-cask": "homebrew-cask", "homebrew-cask": "homebrew-cask",
"homebrew-core": "homebrew-core", "homebrew-core": "homebrew-core",
"lanzaboote": "lanzaboote", "lanzaboote": "lanzaboote",
"musnix": "musnix",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nix-flatpak": "nix-flatpak", "nix-flatpak": "nix-flatpak",
"nix-homebrew": "nix-homebrew", "nix-homebrew": "nix-homebrew",

View file

@ -102,6 +102,11 @@
}; };
zenTyp.url = "github:youwen5/zen.typ"; zenTyp.url = "github:youwen5/zen.typ";
musnix = {
url = "github:musnix/musnix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
@ -171,6 +176,7 @@
inputs.nixos-wsl.nixosModules.default inputs.nixos-wsl.nixosModules.default
inputs.stylix.nixosModules.stylix inputs.stylix.nixosModules.stylix
inputs.agenix.nixosModules.age inputs.agenix.nixosModules.age
inputs.musnix.nixosModules.musnix
./modules/default.nix ./modules/default.nix
./overlays ./overlays
( (

View file

@ -6,25 +6,53 @@
}: }:
let let
cfg = config.liminalOS.system.audio.prod; cfg = config.liminalOS.system.audio.prod;
forAllUsers = lib.genAttrs cfg.realtimeAudioUsers;
in 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 { config = {
liminalOS = { liminalOS = lib.mkIf cfg.enable {
programs.wine.enable = true; programs.wine.enable = true;
system.audio.enable = true; system.audio.enable = true;
config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [
"reaper"
];
}; };
environment.systemPackages = with pkgs; [ environment.systemPackages = lib.mkIf cfg.enable (
reaper (with pkgs; [
yabridge yabridge
yabridgectl yabridgectl
alsa-scarlett-gui alsa-scarlett-gui
]; ])
++ (lib.optionals config.liminalOS.config.allowUnfree [
pkgs.reaper
])
);
liminalOS.config.extraUnfreePackages = lib.mkIf config.liminalOS.config.allowUnfree [ musnix.enable = cfg.enable;
"reaper" # 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"
]; ];
}; };
} }

View file

@ -20,6 +20,7 @@
formFactor = "desktop"; formFactor = "desktop";
system = { system = {
audio.prod.enable = true; audio.prod.enable = true;
audio.prod.realtimeAudioUsers = [ "youwen" ];
networking = { networking = {
firewallPresets.vite = true; firewallPresets.vite = true;
cloudflareNameservers.enable = true; cloudflareNameservers.enable = true;

View file

@ -20,6 +20,7 @@
formFactor = "desktop"; formFactor = "desktop";
system = { system = {
audio.prod.enable = true; audio.prod.enable = true;
audio.prod.realtimeAudioUsers = [ "youwen" ];
networking = { networking = {
firewallPresets.vite = true; firewallPresets.vite = true;
cloudflareNameservers.enable = true; cloudflareNameservers.enable = true;