refactor: modularize audio-prod, audio, wsl, wine, networking

This commit is contained in:
Youwen Wu 2024-12-22 22:26:41 -08:00
parent 5cbd9e60cb
commit ee6f29eb57
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
9 changed files with 200 additions and 73 deletions

View file

@ -14,6 +14,17 @@
# ./apple-silicon-support
];
liminalOS = {
system = {
audio.enable = true;
networking = {
enable = true;
firewallPresets.vite = true;
cloudflareNameservers.enable = true;
};
};
};
boot = {
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = false;

30
modules/default.nix Normal file
View file

@ -0,0 +1,30 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.liminalOS;
in
{
imports = [
./linux
];
options.liminalOS = {
linux.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable liminalOS's default modules and options for Linux.
'';
};
darwin.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable liminalOS's default modules and options for Darwin.
'';
};
};
}

View file

@ -1,11 +1,25 @@
{ pkgs, ... }:
{
imports = [
../wine
];
environment.systemPackages = with pkgs; [
reaper
yabridge
yabridgectl
];
pkgs,
lib,
config,
...
}:
let
cfg = config.liminalOS.system.audio.prod;
in
{
options.liminalOS.system.audio.prod.enable = lib.mkEnableOption "audio production";
config = lib.mkIf cfg.enable {
liminalOS = {
programs.wine.enable = true;
system.audio.enable = true;
};
environment.systemPackages = with pkgs; [
reaper
yabridge
yabridgectl
];
};
}

View file

@ -1,14 +1,27 @@
{ lib, config, ... }:
let
cfg = config.liminalOS.system.audio;
in
{
# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
options.liminalOS.system.audio.enable = lib.mkOption {
type = lib.types.bool;
default = config.liminalOS.linux.enable;
description = ''
Whether to set up PipeWire and default audio utilities.
'';
};
services.playerctld.enable = true;
config = {
services.playerctld.enable = lib.mkIf cfg.enable true;
hardware.pulseaudio.enable = lib.mkIf cfg.enable false;
# TODO: move to other file
security.rtkit.enable = true;
services.pipewire = lib.mkIf cfg.enable {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}

20
modules/linux/default.nix Normal file
View file

@ -0,0 +1,20 @@
{ lib, ... }:
{
imports = [
./audio
./audio-prod
./core
./desktop-portal
./distrobox
./flatpak
./fonts
./gaming
./greeter
./hamachi
./networking
./spotifyd
./stylix
./wine
./wsl
];
}

View file

@ -1,35 +1,53 @@
{ lib, config, ... }:
let
universalAllowedPorts = [
27016 # grim dawn
42805 # grim dawn
42852 # grim dawn
42872 # grim dawn
27015 # grim dawn
27036 # grim dawn
cfg = config.liminalOS.system.networking;
5173 # vite test server
4173 # vite test server
];
universalAllowedPorts =
(lib.optionals cfg.firewallPresets.grimDawn [
27016 # grim dawn
42805 # grim dawn
42852 # grim dawn
42872 # grim dawn
27015 # grim dawn
27036 # grim dawn
])
++ (lib.optionals cfg.firewallPresets.vite [
5173 # vite test server
4173 # vite test server
]);
universalAllowedRanges = [ ];
in
{
services.openssh.enable = true;
networking.firewall = {
enable = true;
allowedTCPPorts = universalAllowedPorts;
allowedUDPPorts = universalAllowedPorts;
allowedUDPPortRanges = universalAllowedRanges ++ [
{
from = 27031;
to = 27036;
}
];
allowedTCPPortRanges = universalAllowedRanges;
options.liminalOS.system.networking = {
enable = lib.mkEnableOption "networking";
firewallPresets = {
grimDawn = lib.mkEnableOption "firewall ports for Grim Dawn";
vite = lib.mkEnableOption "firewall ports for Vite";
};
cloudflareNameservers.enable = lib.mkEnableOption "Cloudflare DNS servers";
};
networking.nameservers = [
"1.1.1.1"
"1.0.0.1"
];
config = lib.mkIf cfg.enable {
services.openssh.enable = true;
networking.firewall = {
enable = true;
allowedTCPPorts = universalAllowedPorts;
allowedUDPPorts = universalAllowedPorts;
allowedUDPPortRanges =
universalAllowedRanges
++ (lib.optionals cfg.firewallPresets.grimDawn [
{
from = 27031;
to = 27036;
}
]);
allowedTCPPortRanges = universalAllowedRanges;
};
networking.nameservers = lib.mkIf cfg.cloudflareNameservers.enable [
"1.1.1.1"
"1.0.0.1"
];
};
}

View file

@ -1,13 +0,0 @@
{ pkgs, ... }:
{
services.spotifyd = {
enable = true;
settings = {
global = {
bitrate = 320;
use_mpris = true;
device_type = "computer";
};
};
};
}

View file

@ -1,12 +1,27 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
winetricks
wine
];
nixpkgs.overlays = [
(self: super: {
wine = super.wineWowPackages.stable;
})
];
pkgs,
config,
lib,
...
}:
let
cfg = config.liminalOS.programs.wine;
in
{
options.liminalOS.programs.wine.enable = lib.mkEnableOption "wine";
config = lib.mkIf cfg.enable {
environment.systemPackages = (
with pkgs;
[
winetricks
wine
]
);
nixpkgs.overlays = [
(self: super: {
wine = super.wineWowPackages.stable;
})
];
};
}

View file

@ -1,12 +1,31 @@
{ inputs, ... }:
{
imports = [
inputs,
config,
lib,
...
}:
let
cfg = config.liminalOS.wsl;
in
{
imports = lib.mkIf cfg.enable [
inputs.nixos-wsl.nixosModules.default
];
wsl = {
options = {
enable = lib.mkEnableOption "wsl";
module = lib.mkOption {
type = lib.types.submodule;
default = inputs.nixos-wsl.nixosModules.default;
description = ''
NixOS WSL module. Defaults to <https://github.com/nix-community/NixOS-WSL>
'';
};
};
config.wsl = lib.mkIf cfg.enable {
enable = true;
defaultUser = "youwen";
defaultUser = config.liminalOS.username;
useWindowsDriver = true;
};
}