Personal Nix setup

Update service setup for desktop modules

Changed files
+97 -68
modules
+1 -1
modules/desktop/affinity.nix
···
};
nix.sliceConfig = mkIf cfg.affinity.isolateNixDaemon {
CPUQuota = "80%";
+
IOWeight = 90;
ManagedOOMMemoryPressure = "kill";
ManagedOOMMemoryPressureLimit = "80%";
-
Nice = 9;
};
};
services = {
+2 -26
modules/desktop/default.nix
···
};
} // helpers.linuxAttrs {
imports = [
-
./services.nix
./session.nix
./affinity.nix
./fonts.nix
./rawaccel.nix
+
./audio.nix
+
./networking.nix
];
config = mkIf cfg.enable {
users.users."${user}".extraGroups = [ "video" ];
-
-
networking = {
-
firewall = {
-
enable = mkDefault true;
-
checkReversePath = "loose";
-
};
-
nftables = {
-
enable = mkForce true;
-
checkRuleset = false;
-
flushRuleset = true;
-
};
-
networkmanager = {
-
enable = mkDefault true;
-
wifi = {
-
backend = "iwd";
-
powersave = true;
-
};
-
};
-
};
-
-
hardware = {
-
steam-hardware.enable = true;
-
};
-
-
security.rtkit.enable = true;
};
}
+67
modules/desktop/networking.nix
···
+
{ lib, pkgs, config, user, ... }:
+
+
with lib;
+
let
+
inherit (generators) toLua;
+
cfg = config.modules.desktop;
+
in {
+
options.modules.desktop.networking = {
+
enable = mkOption {
+
default = cfg.enable;
+
example = true;
+
description = "Whether to enable networking.";
+
type = types.bool;
+
};
+
+
printing = mkOption {
+
default = cfg.networking.enable;
+
example = true;
+
description = "Whether to enable printing.";
+
type = types.bool;
+
};
+
};
+
+
config = mkIf cfg.networking.enable {
+
networking = {
+
firewall = {
+
enable = mkDefault true;
+
checkReversePath = "loose";
+
allowedUDPPorts = [ 5353 ];
+
};
+
nftables = {
+
enable = mkForce true;
+
checkRuleset = false;
+
flushRuleset = true;
+
};
+
networkmanager = {
+
enable = mkDefault true;
+
dns = mkDefault (if config.servies.resolved.enable then "systemd-resolved" else "default");
+
connectionConfig = {
+
"connection.mdns" = mkDefault 2;
+
"connection.llmnr" = 0;
+
};
+
wifi = {
+
backend = "iwd";
+
powersave = true;
+
};
+
};
+
};
+
+
services = {
+
resolved = {
+
enable = true;
+
llmnr = "false";
+
extraConfig = ''
+
[Resolve]
+
MulticastDNS=yes
+
'';
+
};
+
+
printing = mkIf cfg.networking.printing {
+
enable = true;
+
stateless = true;
+
webInterface = false;
+
};
+
};
+
};
+
}
+27 -41
modules/desktop/services.nix modules/desktop/audio.nix
···
inherit (generators) toLua;
cfg = config.modules.desktop;
in {
-
options.modules.desktop.services = {
+
options.modules.desktop.audio = {
enable = mkOption {
-
default = cfg.enable;
+
default = true;
example = true;
-
description = "Whether to enable services.";
+
description = "Whether to enable Pipewire audio.";
type = types.bool;
};
-
pipewire = {
-
enable = mkOption {
-
default = cfg.services.enable;
-
example = true;
-
description = "Whether to enable Pipewire low latency.";
-
type = types.bool;
-
};
-
-
lowLatency = mkOption {
-
default = true;
-
example = true;
-
description = "Whether to enable Pipewire low latency.";
-
type = types.bool;
-
};
+
lowLatency = mkOption {
+
default = true;
+
example = true;
+
description = "Whether to enable Pipewire low latency.";
+
type = types.bool;
+
};
-
quantum = mkOption {
-
description = "Minimum quantum to set";
-
type = types.int;
-
default = 64;
-
example = 32;
-
};
+
quantum = mkOption {
+
description = "Minimum quantum to set";
+
type = types.int;
+
default = 64;
+
example = 32;
+
};
-
rate = mkOption {
-
description = "Rate to set";
-
type = types.int;
-
default = 48000;
-
example = 96000;
-
};
+
rate = mkOption {
+
description = "Rate to set";
+
type = types.int;
+
default = 48000;
+
example = 96000;
};
};
-
config = mkIf cfg.services.enable {
-
users.users."${user}".extraGroups = [ "video" ];
+
config = mkIf cfg.audio.enable {
+
security.rtkit.enable = true;
services = {
-
hardware.bolt.enable = true;
-
printing.enable = true;
-
colord.enable = true;
-
fwupd.enable = true;
-
pipewire = let
-
quantum = cfg.services.pipewire.quantum;
-
rate = cfg.services.pipewire.rate;
+
quantum = cfg.audio.quantum;
+
rate = cfg.audio.rate;
qr = "${toString quantum}/${toString rate}";
in {
-
enable = cfg.services.pipewire.enable;
+
enable = cfg.audio.enable;
pulse.enable = true;
jack.enable = true;
alsa = {
enable = true;
-
support32Bit = true;
+
support32Bit = mkDefault true;
};
# write extra config
-
extraConfig.pipewire = mkIf cfg.services.pipewire.lowLatency {
+
extraConfig.pipewire = mkIf cfg.audio.lowLatency {
"99-lowlatency" = {
context = {
properties.default.clock.min-quantum = quantum;