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,
...
}:
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; [ environment.systemPackages = with pkgs; [
reaper reaper
yabridge yabridge
yabridgectl 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;
default = config.liminalOS.linux.enable;
description = ''
Whether to set up PipeWire and default audio utilities.
'';
};
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; security.rtkit.enable = true;
services.pipewire = { services.pipewire = lib.mkIf cfg.enable {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
jack.enable = true; jack.enable = true;
}; };
};
services.playerctld.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;
universalAllowedPorts =
(lib.optionals cfg.firewallPresets.grimDawn [
27016 # grim dawn 27016 # grim dawn
42805 # grim dawn 42805 # grim dawn
42852 # grim dawn 42852 # grim dawn
42872 # grim dawn 42872 # grim dawn
27015 # grim dawn 27015 # grim dawn
27036 # grim dawn 27036 # grim dawn
])
++ (lib.optionals cfg.firewallPresets.vite [
5173 # vite test server 5173 # vite test server
4173 # vite test server 4173 # vite test server
]; ]);
universalAllowedRanges = [ ]; universalAllowedRanges = [ ];
in in
{ {
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";
};
config = lib.mkIf cfg.enable {
services.openssh.enable = true; services.openssh.enable = true;
networking.firewall = { networking.firewall = {
enable = true; enable = true;
allowedTCPPorts = universalAllowedPorts; allowedTCPPorts = universalAllowedPorts;
allowedUDPPorts = universalAllowedPorts; allowedUDPPorts = universalAllowedPorts;
allowedUDPPortRanges = universalAllowedRanges ++ [ allowedUDPPortRanges =
universalAllowedRanges
++ (lib.optionals cfg.firewallPresets.grimDawn [
{ {
from = 27031; from = 27031;
to = 27036; to = 27036;
} }
]; ]);
allowedTCPPortRanges = universalAllowedRanges; allowedTCPPortRanges = universalAllowedRanges;
}; };
networking.nameservers = [ networking.nameservers = lib.mkIf cfg.cloudflareNameservers.enable [
"1.1.1.1" "1.1.1.1"
"1.0.0.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,
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 winetricks
wine wine
]; ]
);
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
wine = super.wineWowPackages.stable; 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;
}; };
} }