refactor(system): flatten
This commit is contained in:
parent
ef1482a65a
commit
8298fc375a
42 changed files with 239 additions and 89 deletions
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
imports = [
|
||||
./admin
|
||||
./name
|
||||
./type
|
||||
./function
|
||||
./admin.nix
|
||||
./name.nix
|
||||
./type.nix
|
||||
./role.nix
|
||||
./hardware
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
{ lib, config, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
function = config.systemModules.host.function;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "workstation" function) {
|
||||
systemModules = {
|
||||
|
||||
audio.enable = true;
|
||||
video.enable = true;
|
||||
|
||||
programs = {
|
||||
dconf.enable = true;
|
||||
wireshark.enable = true;
|
||||
bandwhich.enable = true;
|
||||
kdeconnect.enable = true;
|
||||
};
|
||||
|
||||
services = {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ in
|
|||
|
||||
{
|
||||
imports = [
|
||||
./amd
|
||||
./intel
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
];
|
||||
|
||||
options.systemModules.host.hardware.cpu.type = mkOption {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
./cpu
|
||||
./gpu
|
||||
./features
|
||||
./common
|
||||
./common.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
111
inputs/system/modules/base/host/hardware/features/audio.nix
Normal file
111
inputs/system/modules/base/host/hardware/features/audio.nix
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.generators) toLua;
|
||||
inherit (lib.lists) elem optionals;
|
||||
# inherit (builtins) elem;
|
||||
features = config.systemModules.host.hardware.features;
|
||||
hasBT = (elem "bluetooth" features);
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "audio" features) {
|
||||
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" /* 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"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -6,14 +6,16 @@ in
|
|||
|
||||
{
|
||||
imports = [
|
||||
./bluetooth
|
||||
./backlight
|
||||
./battery
|
||||
./ssd
|
||||
./bluetooth.nix
|
||||
./backlight.nix
|
||||
./battery.nix
|
||||
./ssd.nix
|
||||
./audio.nix
|
||||
./video.nix
|
||||
];
|
||||
|
||||
options.systemModules.host.hardware.features = mkOption {
|
||||
type = with types; listOf (enum ["bluetooth" "backlight" "battery" "ssd"]);
|
||||
type = with types; listOf (enum ["audio" "video" "bluetooth" "backlight" "battery" "ssd"]);
|
||||
default = [];
|
||||
description = "What extra hardware feature system modules to use";
|
||||
};
|
||||
|
|
|
|||
31
inputs/system/modules/base/host/hardware/features/video.nix
Normal file
31
inputs/system/modules/base/host/hardware/features/video.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf;
|
||||
inherit (builtins) elem;
|
||||
isx86Linux = pkgs: with pkgs.stdenv; hostPlatform.isLinux && hostPlatform.isx86;
|
||||
features = config.systemModules.host.hardware.features;
|
||||
in
|
||||
|
||||
{
|
||||
config = mkIf (elem "video" features) {
|
||||
hardware = {
|
||||
opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = isx86Linux pkgs;
|
||||
};
|
||||
};
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
xdgOpenUsePortal = true;
|
||||
extraPortals = [
|
||||
pkgs.xdg-desktop-portal-gtk
|
||||
];
|
||||
config = {
|
||||
common.default = ["gtk"];
|
||||
hyprland.default = ["gtk" "hyprland"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -6,9 +6,9 @@ in
|
|||
|
||||
{
|
||||
imports = [
|
||||
./amd
|
||||
./intel
|
||||
./nvidia
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
./nvidia.nix
|
||||
];
|
||||
|
||||
options.systemModules.host.hardware.gpu.type = mkOption {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue