Created
June 11, 2025 16:58
-
-
Save dysinger/8a39cc1f57569edf23c7c369d5d1759e to your computer and use it in GitHub Desktop.
Sonic w/ SuperCollider on relatime kernel on NixOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "NixOS configuration with real-time kernel, Sonic Pi, and SuperCollider"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
musnix.url = "github:musnix/musnix"; | |
}; | |
outputs = { self, nixpkgs, musnix, ... }@inputs: { | |
nixosConfigurations.example-config = nixpkgs.lib.nixosSystem { | |
system = "x86_64-linux"; | |
modules = [ | |
# Import musnix for real-time kernel and audio optimizations | |
musnix.nixosModules.musnix | |
{ | |
# Musnix configuration | |
musnix = { | |
enable = true; | |
kernel.realtime = true; # Enable real-time kernel with CONFIG_PREEMPT_RT | |
kernel.packages = nixpkgs.lib.mkDefault nixpkgs.legacyPackages.x86_64-linux.linuxPackages_latest; | |
# Optional: Enable ALSA sequencer for MIDI support | |
alsaSeq.enable = true; | |
# Optional: Enable additional real-time optimizations | |
rtirq.enable = true; | |
}; | |
# Enable JACK audio server | |
services.jack = { | |
jackd.enable = true; | |
# Use ALSA backend for JACK | |
alsa.enable = true; | |
# Ensure JACK is compatible with PulseAudio | |
pulseaudio.enable = true; | |
}; | |
# Enable PipeWire for modern audio handling (optional, for compatibility) | |
services.pipewire = { | |
enable = true; | |
alsa.enable = true; | |
pulse.enable = true; | |
jack.enable = true; | |
}; | |
# Enable real-time kit for low-latency audio | |
security.rtkit.enable = true; | |
# System packages including Sonic Pi and SuperCollider | |
environment.systemPackages = with nixpkgs.legacyPackages.x86_64-linux; [ | |
sonic-pi | |
supercollider | |
qjackctl # GUI for controlling JACK | |
]; | |
# User configuration | |
users.users.yourusername = { | |
isNormalUser = true; | |
extraGroups = [ "wheel" "audio" ]; # Add user to audio group for real-time privileges | |
}; | |
# Kernel parameters for low-latency audio | |
boot.kernelParams = [ "threadirqs" ]; | |
boot.kernel.sysctl = { | |
"vm.swappiness" = 10; | |
"fs.inotify.max_user_watches" = 524288; | |
}; | |
# PAM limits for audio group (reduce xruns) | |
security.pam.loginLimits = [ | |
{ domain = "@audio"; item = "memlock"; type = "-"; value = "unlimited"; } | |
{ domain = "@audio"; item = "rtprio"; type = "-"; value = "99"; } | |
{ domain = "@audio"; item = "nofile"; type = "soft"; value = "99999"; } | |
{ domain = "@audio"; item = "nofile"; type = "hard"; value = "99999"; } | |
]; | |
# Ensure VST and other plugin paths are set for audio applications | |
environment.variables = { | |
VST_PATH = "/nix/var/nix/profiles/default/lib/vst:/var/run/current-system/sw/lib/vst:~/.vst"; | |
LV2_PATH = "/nix/var/nix/profiles/default/lib/lv2:/var/run/current-system/sw/lib/lv2:~/.lv2"; | |
LADSPA_PATH = "/nix/var/nix/profiles/default/lib/ladspa:/var/run/current-system/sw/lib/ladspa:~/.ladspa"; | |
DSSI_PATH = "/nix/var/nix/profiles/default/lib/dssi:/var/run/current-system/sw/lib/dssi:~/.dssi"; | |
}; | |
# System-wide configuration | |
nix.settings.experimental-features = [ "nix-command" "flakes" ]; | |
system.stateVersion = "24.11"; # Adjust to your NixOS version | |
} | |
]; | |
specialArgs = { inherit inputs; }; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment