nixos/suites/desktop: modularize submodules into dedicated profiles

It's practically enabled every time so why not set them as profiles instead.
The structure should be enough for some control over what is enabled.
This commit is contained in:
Gabriel Arazas 2024-01-25 18:52:07 +08:00
parent 8b349c895b
commit 3cafa9f613
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
6 changed files with 111 additions and 122 deletions

View File

@ -8,21 +8,8 @@ in {
options.suites.desktop = {
enable =
lib.mkEnableOption "basic desktop-related services and default programs";
audio.enable =
lib.mkEnableOption "desktop audio-related configurations";
fonts.enable = lib.mkEnableOption "font-related configuration";
hardware.enable =
lib.mkEnableOption "the common hardware-related configuration";
cleanup.enable = lib.mkEnableOption "activation of various cleanup services";
autoUpgrade.enable = lib.mkEnableOption "auto-upgrade service with this system";
wine = {
enable = lib.mkEnableOption "Wine and Wine-related tools";
package = lib.mkOption {
type = lib.types.package;
description = "The Wine package to be used for related tools.";
default = pkgs.wineWowPackages.stable;
};
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
@ -113,102 +100,6 @@ in {
boot.kernelModules = [ "v4l2loopback" ];
})
(lib.mkIf cfg.audio.enable {
# Enable the preferred audio workflow.
sound.enable = false;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
# This is enabled by default but I want to explicit since
# this is my preferred way of managing anyways.
wireplumber.enable = true;
# Enable all the bi-...bridges.
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
# This is based from https://jackaudio.org/faq/linux_rt_config.html.
security.pam.loginLimits = [
{
domain = "@audio";
type = "-";
item = "rtprio";
value = "95";
}
{
domain = "@audio";
type = "-";
item = "memlock";
value = "unlimited";
}
];
})
(lib.mkIf cfg.fonts.enable {
fonts = {
enableDefaultPackages = true;
fontDir.enable = true;
fontconfig = {
enable = true;
includeUserConf = true;
defaultFonts = {
monospace = [ "Iosevka" "Jetbrains Mono" "Source Code Pro" ];
sansSerif = [ "Source Sans Pro" "Noto Sans" ];
serif = [ "Source Serif Pro" "Noto Serif" ];
emoji = [ "Noto Color Emoji" ];
};
};
packages = with pkgs; [
# Some monospace fonts.
iosevka
monaspace
jetbrains-mono
# Noto font family
noto-fonts
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-lgc-plus
noto-fonts-extra
noto-fonts-emoji
noto-fonts-emoji-blob-bin
# Adobe Source font family
source-code-pro
source-sans-pro
source-han-sans
source-serif-pro
source-han-serif
source-han-mono
# Math fonts
stix-two # Didn't know rivers can have sequels.
xits-math # NOTE TO SELF: I wouldn't consider to name the fork with its original project's name backwards.
];
};
})
(lib.mkIf cfg.hardware.enable {
# Enable tablet support with OpenTabletDriver.
hardware.opentabletdriver.enable = true;
# Enable support for Bluetooth.
hardware.bluetooth.enable = true;
# Enable yer game controllers.
hardware.steam-hardware.enable = true;
hardware.xone.enable = true;
hardware.xpadneo.enable = true;
})
(lib.mkIf cfg.cleanup.enable {
# Weekly garbage collection of Nix store.
nix.gc = {
@ -250,14 +141,5 @@ in {
randomizedDelaySec = "1min";
};
})
# I try to avoid using Wine on NixOS because most of them uses FHS or
# something and I just want it to work but here goes.
(lib.mkIf cfg.wine.enable {
environment.systemPackages = with pkgs; [
cfg.wine.package # The star of the show.
bottles # The Windows environment package manager.
];
})
]);
}

View File

@ -44,10 +44,6 @@ in
hardware.steam-hardware.enable = true;
hardware.xone.enable = true;
hardware.xpadneo.enable = true;
# Enabling all hardware settings for the desktop (unless the user
# explicitly disabled it).
suites.desktop.hardware.enable = lib.mkDefault true;
}
(lib.mkIf cfg.emulators.enable {

View File

@ -0,0 +1,37 @@
# Enable the preferred audio workflow.
{ lib, ... }:
{
security.rtkit.enable = lib.mkDefault true;
# The main preferred setup of our audio system.
services.pipewire = {
enable = lib.mkDefault true;
# This is enabled by default but I want to explicit since
# this is my preferred way of managing anyways.
wireplumber.enable = true;
# Enable all the bi-...bridges.
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
# This is based from https://jackaudio.org/faq/linux_rt_config.html.
security.pam.loginLimits = [
{
domain = "@audio";
type = "-";
item = "rtprio";
value = "95";
}
{
domain = "@audio";
type = "-";
item = "memlock";
value = "unlimited";
}
];
}

View File

@ -0,0 +1,10 @@
# A common profile for desktop systems. Most of the configurations featured
# here should be enough in common to the typical desktop setups found on
# non-NixOS systems.
{
imports = [
./fonts.nix
./audio.nix
./hardware.nix
];
}

View File

@ -0,0 +1,48 @@
# A subprofile for desktop handling the fonts.
{ config, lib, pkgs, ... }:
{
fonts.enableDefaultPackages = lib.mkDefault true;
fonts.fontDir.enable = lib.mkDefault true;
fonts.fontconfig = {
enable = lib.mkDefault true;
includeUserConf = true;
defaultFonts = {
monospace = [ "Iosevka" "Jetbrains Mono" "Source Code Pro" ];
sansSerif = [ "Source Sans Pro" "Noto Sans" ];
serif = [ "Source Serif Pro" "Noto Serif" ];
emoji = [ "Noto Color Emoji" ];
};
};
fonts.packages = with pkgs; [
# Some monospace fonts.
iosevka
monaspace
jetbrains-mono
# Noto font family
noto-fonts
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-lgc-plus
noto-fonts-extra
noto-fonts-emoji
noto-fonts-emoji-blob-bin
# Adobe Source font family
source-code-pro
source-sans-pro
source-han-sans
source-serif-pro
source-han-serif
source-han-mono
# Math fonts
stix-two # Didn't know rivers can have sequels.
xits-math # NOTE TO SELF: I wouldn't consider to name the fork with its original project's name backwards.
];
}

View File

@ -0,0 +1,16 @@
# A bunch of common hardware settings for desktop systems. Mostly, we're just
# adding drivers for common gaming peripherals.
{ lib, ... }:
{
# Enable tablet support with OpenTabletDriver.
hardware.opentabletdriver.enable = lib.mkDefault true;
# Enable support for Bluetooth.
hardware.bluetooth.enable = lib.mkDefault true;
# Enable yer game controllers.
hardware.steam-hardware.enable = lib.mkDefault true;
hardware.xone.enable = lib.mkDefault true;
hardware.xpadneo.enable = lib.mkDefault true;
}