refactor(system): flatten

This commit is contained in:
ooks-io 2024-05-24 23:44:07 +12:00
parent 24dee2cadc
commit f47154c234
29 changed files with 32 additions and 268 deletions

View file

@ -23,7 +23,7 @@ in
cpu.type = "amd";
cpu.amd.pstate.enable = true;
gpu.type = "amd";
features = [ "ssd" ];
features = [ "ssd" "audio" "video" ];
};
};

View file

@ -1,111 +0,0 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf;
inherit (lib.generators) toLua;
inherit (lib.lists) any elem optionals;
# inherit (builtins) elem;
hasBT = (elem "bluetooth" config.systemModules.host.hardware.features);
hasFunction = f: elem f config.systemModules.host.function;
in
{
config = mkIf (any hasFunction ["workstation" "gaming" "media-server"]) {
hardware.pulseaudio.enable = !config.services.pipewire.enable;
security.rtkit.enable = config.services.pipewire.enable;
services.pipewire =
let
quantum = 64;
rate = 48000;
qr = "${toString quantum}/${toString rate}";
in
{
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
# Low latency module provided by notashelf/nyx
extraConfig.pipewire."99-lowlatency" = {
context = {
properties.default.clock.min-quantum = quantum;
modules = [
{
name = "libpipewire-module-rtkit";
flags = ["ifexists" "nofail"];
args = {
nice.level = -15;
rt = {
prio = 88;
time.soft = 200000;
time.hard = 200000;
};
};
}
{
name = "libpipewire-module-protocol-pulse";
args = {
server.address = ["unix:native"];
pulse.min = {
req = qr;
quantum = qr;
frag = qr;
};
};
}
];
stream.properties = {
node.latency = qr;
resample.quality = 1;
};
};
};
wireplumber = {
enable = true;
configPackages = let
matches = toLua {
multiline = false;
indent = false;
} [[["node.name" "matches" "alsa_output.*"]]];
apply_properties = toLua {} {
"audio.format" = "S32LE";
"audio.rate" = rate * 2;
"api.alsa.period-size" = 2;
};
in
[
(pkgs.writeTextDir "share/lowlatency.lua.d/99-alsa-lowlatency.lua" ''
alsa_monitor.rules = {
{
matches = ${matches};
apply_properties = ${apply_properties};
}
}
'')
]
++ optionals hasBT [
(pkgs.writeTextDir "share/bluetooth.lua.d/51-bluez-config.lua" ''
bluez_monitor.properties = {
["bluez5.enable-sbc-xq"] = true,
["bluez5.enable-msbc"] = true,
["bluez5.enable-hw-volume"] = true,
["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]"
}
'')
];
};
};
systemd.user.services = {
pipewire.wantedBy = ["default.target"];
pipewire-pulse.wantedBy = ["default.target"];
};
};
}

View file

@ -5,16 +5,13 @@
./shell
./boot
./nix
./programs
./displayManager
./networking
./locale.nix
./virtualization
./security
./services
./audio
./host
./video
];

View file

@ -19,8 +19,9 @@ in
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = [
pkgs.xdg-desktop-portal-gtk
extraPortals = with pkgs; [
xdg-desktop-portal-hyprland
xdg-desktop-portal-gtk
];
config = {
common.default = ["gtk"];

View file

@ -6,4 +6,9 @@
mtr
tcpdump
];
programs = {
wireshark.enable = true;
bandwhich.enable = true;
};
}

View file

@ -38,7 +38,7 @@ in
options = "--delete-older-than 30d";
};
settings = {
flake-registry = "etc/nix/registry.json";
flake-registry = "/etc/nix/registry.json";
allowed-users = [ "root" "@wheel" ];
trusted-users = [ "root" "@wheel" ];
experimental-features = [ "nix-command" "flakes" ];

View file

@ -1,13 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
host = config.systemModules.host;
in
{
config = mkIf (elem "workstation" host.function) {
programs.bandwhich.enable = true;
};
}

View file

@ -1,9 +0,0 @@
{
imports = [
./dconf
./kdeconnect
./seahorse
./wireshark
./bandwhich
];
}

View file

@ -1,13 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
host = config.systemModules.host;
in
{
config = mkIf (elem "workstation" host.function) {
programs.seahorse.enable = true;
};
}

View file

@ -1,13 +0,0 @@
{ lib, config, ... }:
let
inherit (lib) mkIf;
inherit (builtins) elem;
host = config.systemModules.host;
in
{
config = mkIf (elem "workstation" host.function) {
programs.wireshark.enable = true;
};
}

View file

@ -1,9 +1,8 @@
{
imports = [
./1password
./kernel
./pam
./polkit
./sudo
./kernel.nix
./pam.nix
./polkit.nix
./sudo.nix
];
}

View file

@ -1,18 +1,8 @@
{ lib, ... }:
{
imports = [
./mediaServer
./system76Scheduler
./dbus
./gnome
./gvfs
./system76Scheduler.nix
./dbus.nix
./gnome.nix
./gvfs.nix
];
options.systemModules.services = {
mediaServer = {
enable = lib.mkEnableOption "Enable mediaserver service module";
};
};
}

View file

@ -1,51 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.systemModules.services.mediaServer;
in
{
config = lib.mkIf cfg.enable {
users.groups.media = { };
environment.systemPackages = with pkgs; [
jellyfin
jellyfin-web
jellyfin-ffmpeg
];
services = {
jellyfin = {
group = "media";
enable = true;
openFirewall = true;
};
deluge = {
group = "media";
enable = true;
web.enable = true;
};
radarr = {
group = "media";
enable = true;
openFirewall = true;
};
sonarr = {
group = "media";
enable = true;
openFirewall = true;
};
prowlarr.enable = true;
};
systemd.tmpfiles.rules = [
"d /jellyfin 0770 - media - -"
];
fileSystems."/jellyfin" = {
device = "/dev/disk/by-label/jellyfin";
fsType = "btrfs";
};
};
}

View file

@ -1,31 +0,0 @@
{ lib, config, pkgs, ... }:
let
inherit (lib) mkIf;
isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86;
host = config.systemModules.host;
in
{
config = mkIf (host.type != "phone") {
hardware = {
opengl = {
enable = true;
driSupport = true;
driSupport32Bit = isx86Linux pkgs;
};
};
xdg.portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
];
config = {
common.default = ["gtk"];
hyprland.default = ["gtk" "hyprland"];
};
};
};
}

View file

@ -1,5 +1,5 @@
{
imports = [
./pipewire
./programs
];
}

View file

@ -0,0 +1,7 @@
{
imports = [
./dconf.nix
./kdeconnect.nix
./1password.nix
];
}

View file

@ -9,6 +9,10 @@ let
hosts = "${systemInputs}/hosts";
base = "${systemInputs}/modules/base";
gaming = "${systemInputs}/modules/roles/gaming";
workstation = "${systemInputs}/modules/roles/workstation";
specialArgs = {inherit inputs self;};
in
@ -20,6 +24,8 @@ in
"${hosts}/ooksdesk"
hm
base
gaming
workstation
];
};
}