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 # ./apple-silicon-support
]; ];
liminalOS = {
system = {
audio.enable = true;
networking = {
enable = true;
firewallPresets.vite = true;
cloudflareNameservers.enable = true;
};
};
};
boot = { boot = {
loader.systemd-boot.enable = true; loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = false; 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 = [ pkgs,
../wine lib,
]; config,
environment.systemPackages = with pkgs; [ ...
reaper }:
yabridge let
yabridgectl 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. options.liminalOS.system.audio.enable = lib.mkOption {
hardware.pulseaudio.enable = false; type = lib.types.bool;
security.rtkit.enable = true; default = config.liminalOS.linux.enable;
services.pipewire = { description = ''
enable = true; Whether to set up PipeWire and default audio utilities.
alsa.enable = true; '';
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
}; };
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 let
universalAllowedPorts = [ cfg = config.liminalOS.system.networking;
27016 # grim dawn
42805 # grim dawn
42852 # grim dawn
42872 # grim dawn
27015 # grim dawn
27036 # grim dawn
5173 # vite test server universalAllowedPorts =
4173 # vite test server (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 = [ ]; universalAllowedRanges = [ ];
in in
{ {
services.openssh.enable = true; options.liminalOS.system.networking = {
enable = lib.mkEnableOption "networking";
networking.firewall = { firewallPresets = {
enable = true; grimDawn = lib.mkEnableOption "firewall ports for Grim Dawn";
allowedTCPPorts = universalAllowedPorts; vite = lib.mkEnableOption "firewall ports for Vite";
allowedUDPPorts = universalAllowedPorts; };
allowedUDPPortRanges = universalAllowedRanges ++ [ cloudflareNameservers.enable = lib.mkEnableOption "Cloudflare DNS servers";
{
from = 27031;
to = 27036;
}
];
allowedTCPPortRanges = universalAllowedRanges;
}; };
networking.nameservers = [ config = lib.mkIf cfg.enable {
"1.1.1.1" services.openssh.enable = true;
"1.0.0.1"
]; 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; [ pkgs,
winetricks config,
wine lib,
]; ...
nixpkgs.overlays = [ }:
(self: super: { let
wine = super.wineWowPackages.stable; 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 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; enable = true;
defaultUser = "youwen"; defaultUser = config.liminalOS.username;
useWindowsDriver = true; useWindowsDriver = true;
}; };
} }