nixos/global/io/default.nix

86 lines
2.3 KiB
Nix
Raw Normal View History

2025-01-13 11:52:09 +08:00
{
pkgs,
lib,
config,
...
}:
with lib;
let
2024-01-07 22:01:31 +08:00
cfg = config.global.io;
2024-01-27 22:14:03 +08:00
gui = with config.global.gpu; enable && session;
2025-01-13 11:52:09 +08:00
in
{
2024-01-07 22:01:31 +08:00
options.global.io = {
2025-01-13 11:52:09 +08:00
betaflight = mkEnableOption "betaflight udev rules" // {
default = gui;
};
bluetooth = mkEnableOption "bluetooth daemons and state persistence" // {
default = gui;
};
audio = mkEnableOption "pulseaudio server configuration" // {
default = gui;
};
coredump = mkEnableOption "save coredumps handled by systemd";
};
config = {
2025-01-13 11:52:09 +08:00
services.udev.extraRules =
''
# ignore zvols
KERNEL=="zd*", ENV{UDISKS_IGNORE}="1"
''
+ (
if cfg.betaflight then
''
# DFU (Internal bootloader for STM32 and AT32 MCUs)
SUBSYSTEM=="usb", ATTRS{idVendor}=="2e3c", ATTRS{idProduct}=="df11", MODE="0664", GROUP="dialout"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="0664", GROUP="dialout"
''
else
""
);
networking.networkmanager.enable = mkDefault true;
2024-03-29 10:29:57 +08:00
networking.hosts = {
"10.5.14.0" = [ "codec" ];
2024-03-30 14:01:48 +08:00
"10.5.14.1" = [ "redir" ];
2024-04-11 14:44:32 +08:00
"10.5.14.2" = [ "compat" ];
2024-03-29 10:33:23 +08:00
"192.168.123.1" = [ "netvm" ];
2024-03-29 10:29:57 +08:00
};
2024-05-14 10:48:16 +08:00
networking.firewall.logRefusedConnections = true;
hardware.bluetooth.enable = mkDefault cfg.bluetooth;
# rtkit is optional but recommended
security.rtkit.enable = cfg.audio;
services.pipewire = mkIf cfg.audio {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
2025-01-13 11:52:09 +08:00
security.pam.loginLimits = mkIf (!cfg.coredump) (singleton {
domain = "*";
item = "core";
type = "hard";
value = "0";
});
systemd.coredump.extraConfig = mkIf (!cfg.coredump) "Storage=none";
2025-01-13 11:52:09 +08:00
environment.persistence."/nix/persist/fhs".directories =
[
"/var/log"
"/var/lib/nixos"
"/var/lib/systemd/backlight"
]
++ optional config.networking.networkmanager.enable "/etc/NetworkManager/system-connections"
++ optional cfg.bluetooth "/var/lib/bluetooth"
++ optional cfg.coredump "/var/lib/systemd/coredump";
environment.persistence."/nix/persist/fhs".hideMounts = true;
2025-01-13 11:52:09 +08:00
users.home.persist.directories = [ ] ++ optional cfg.audio ".local/state/wireplumber";
};
}