refactor: complete rewrite

This commit is contained in:
ooks-io 2024-10-23 23:46:25 +13:00
parent 19a4bbda3c
commit 8e81943cf9
399 changed files with 3396 additions and 8042 deletions

View file

@ -0,0 +1,70 @@
{
lib,
config,
...
}: let
inherit (builtins) elem;
inherit (lib) mkIf;
inherit (config.ooknet.hardware) features;
in {
# generic audio configuration
config = mkIf (elem "audio" features) {
hardware.pulseaudio.enable = false;
services = {
pipewire = {
enable = true;
audio.enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
jack.enable = true;
wireplumber.enable = true;
};
# realtime audio
udev.extraRules = ''
KERNEL=="cpu_dma_latency", GROUP="audio"
KERNEL=="rtc0", GROUP="audio"
KERNEL=="hpet", GROUP="audio"
'';
};
security = {
rtkit.enable = true;
pam.loginLimits = [
{
domain = "@audio";
item = "nofile";
type = "soft";
value = "99999";
}
{
domain = "@audio";
item = "nofile";
type = "hard";
value = "99999";
}
{
domain = "@audio";
item = "rtprio";
type = "-";
value = "99";
}
{
domain = "@audio";
item = "memlock";
type = "-";
value = "unlimited";
}
{
domain = "@audio";
type = "-";
item = "nice";
value = -11;
}
];
};
};
}

View file

@ -0,0 +1,13 @@
{
lib,
config,
...
}: let
inherit (config.ooknet.hardware) features;
inherit (lib) mkIf;
inherit (builtins) elem;
in {
config = mkIf (elem "backlight" features) {
hardware.brillo.enable = true;
};
}

View file

@ -0,0 +1,44 @@
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem attrValues;
inherit (config.ooknet.hardware) features;
in {
config = mkIf (elem "battery" features) {
services = {
# cpu power usage optimizer
auto-cpufreq = {enable = true;};
# application interface for power management
upower = {
enable = true;
percentageLow = 25;
percentageCritical = 5;
percentageAction = 3;
criticalPowerAction = "Hibernate";
};
# daemon for monitoring and controlling temperature
thermald = {enable = true;};
# put this here because if we are enabling the battery modules
# we are most likely using a laptop
# lidSwitch defines the action to perform when the laptop lid is
# closed
logind = {lidSwitch = "suspend";};
};
boot = {
kernelModules = ["acpi_call"];
extraModulePackages = attrValues {
inherit (config.boot.kernelPackages) acpi_call cpupower;
};
};
environment.systemPackages = attrValues {
inherit (pkgs) acpi powertop;
};
};
}

View file

@ -0,0 +1,26 @@
{
config,
lib,
pkgs,
self,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem attrValues;
inherit (config.ooknet.hardware) features;
in {
config = mkIf (elem "bluetooth" features) {
hardware.bluetooth = {
enable = true;
package = pkgs.bluez5-experimental;
};
environment.systemPackages = attrValues {
#inherit (self.packages.${pkgs.system}) live-buds-cli;
inherit (pkgs) bluetuith;
};
# https://github.com/NixOS/nixpkgs/issues/114222
systemd.user.services.telephony_client.enable = false;
};
}

View file

@ -0,0 +1,11 @@
{
imports = [
./video.nix
./printing.nix
./audio.nix
./battery.nix
./backlight.nix
./ssd.nix
# ./bluetooth.nix
];
}

View file

@ -0,0 +1,24 @@
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem;
inherit (config.ooknet.hardware) features;
in {
config = mkIf (elem "printing" features) {
services = {
printing = {
enable = true;
drivers = [pkgs.hplip];
};
avahi = {
enable = true;
openFirewall = true;
nssmdns4 = true;
};
};
};
}

View file

@ -0,0 +1,23 @@
{
lib,
config,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem;
inherit (config.ooknet.hardware) features;
in {
config = mkIf (elem "ssd" features) {
services.fstrim = {
enable = true;
};
# only run fstrim while connected on AC
systemd.services.fstrim = {
unitConfig.ConditionACPower = true;
serviceConfig = {
Nice = 19;
IOSchedulingClass = "idle";
};
};
};
}

View file

@ -0,0 +1,19 @@
{
lib,
config,
pkgs,
...
}: let
inherit (lib) mkIf;
inherit (builtins) elem;
inherit (config.ooknet.hardware) features;
in {
config = mkIf (elem "video" features) {
hardware = {
graphics = {
enable = true;
enable32Bit = true;
};
};
};
}