nixos-config/modules/nixos/profiles/desktop.nix

223 lines
6.5 KiB
Nix
Raw Normal View History

# This is where extra desktop goodies can be found.
# As a note, this is not where you set the aesthetics of your graphical sessions.
# That can be found in the `themes` module.
{ config, options, lib, pkgs, ... }:
let cfg = config.profiles.desktop;
2021-11-25 13:45:48 +00:00
in {
options.profiles.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;
};
};
};
2021-11-25 13:45:48 +00:00
config = lib.mkIf cfg.enable (lib.mkMerge [
({
# Enable Flatpak for additional options for installing desktop applications.
services.flatpak.enable = true;
xdg.portal.enable = true;
2022-08-20 06:13:54 +00:00
environment.etc =
let
urls = {
"flathub" = {
url = "https://flathub.org/repo/flathub.flatpakrepo";
hash = "sha256-M3HdJQ5h2eFjNjAHP+/aFTzUQm9y9K+gwzc64uj+oDo=";
2022-08-20 06:13:54 +00:00
};
"flathub-beta" = {
url = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo";
hash = "sha256-WCyuPJ+dRjnwJ976/m+jO9oKOk1EEpDZJq2For4PcgY=";
2022-08-20 06:13:54 +00:00
};
"gnome-nightly" = {
url = "https://nightly.gnome.org/gnome-nightly.flatpakrepo";
hash = "sha256-rFluVpCvgs1iy7YKVnkPh3p6YuF4orbVuOhLUUFRyYM=";
2022-08-20 06:13:54 +00:00
};
"kdeapps" = {
url = "https://distribute.kde.org/kdeapps.flatpakrepo";
hash = "sha256-dCF9QQYMmqMuzwAS+HYoPAAtwfzO7aVCl8s4RwhneqI=";
2022-08-20 06:13:54 +00:00
};
};
in
lib.mapAttrs'
(name: remote: lib.nameValuePair "flatpak/remotes.d/${name}.flatpakrepo" {
source = pkgs.fetchurl remote;
})
urls;
2022-08-13 00:31:09 +00:00
programs.extra-container.enable = true;
# Enable font-related options for more smoother and consistent experience.
fonts.fontconfig.enable = true;
# Run unpatched binaries with these!
programs.nix-ld.enable = true;
environment.systemPackages = with pkgs; [
steam-run # For the heathens that still uses FHS.
];
2022-06-09 05:00:07 +00:00
# Enable running GNOME apps outside GNOME.
programs.dconf.enable = true;
})
(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;
2022-05-20 06:47:09 +00:00
# This is enabled by default but I want to explicit since
# this is my preferred way of managing anyways.
wireplumber.enable = true;
2022-08-20 06:13:54 +00:00
# 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";
}
];
2021-11-25 13:45:48 +00:00
})
(lib.mkIf cfg.fonts.enable {
fonts = {
enableDefaultPackages = true;
fontDir.enable = true;
2021-11-25 13:45:48 +00:00
fontconfig = {
enable = true;
includeUserConf = true;
2021-11-27 08:04:01 +00:00
defaultFonts = {
2022-07-07 23:28:59 +00:00
monospace = [ "Iosevka" "Jetbrains Mono" "Source Code Pro" ];
2021-11-27 08:04:01 +00:00
sansSerif = [ "Source Sans Pro" "Noto Sans" ];
serif = [ "Source Serif Pro" "Noto Serif" ];
2022-07-07 23:28:59 +00:00
emoji = [ "Noto Color Emoji" ];
2021-11-27 08:04:01 +00:00
};
2021-11-25 13:45:48 +00:00
};
packages = with pkgs; [
2022-07-07 23:28:59 +00:00
# Some monospace fonts.
iosevka
jetbrains-mono
2021-11-27 08:04:01 +00:00
2021-11-29 09:58:02 +00:00
# Noto font family
noto-fonts
noto-fonts-cjk
noto-fonts-cjk-sans
noto-fonts-cjk-serif
2021-11-29 09:58:02 +00:00
noto-fonts-extra
noto-fonts-emoji
noto-fonts-emoji-blob-bin
2021-11-27 08:04:01 +00:00
2021-11-29 09:58:02 +00:00
# Adobe Source font family
source-code-pro
source-sans-pro
source-han-sans
source-serif-pro
source-han-serif
source-han-mono
2021-11-25 13:45:48 +00:00
2021-11-29 09:58:02 +00:00
# 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.
2021-11-29 09:58:02 +00:00
];
2021-11-25 13:45:48 +00:00
};
})
2021-12-06 07:27:51 +00:00
(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;
2021-12-06 07:27:51 +00:00
})
(lib.mkIf cfg.cleanup.enable {
# Weekly garbage collection of Nix store.
nix.gc = {
automatic = true;
persistent = true;
dates = "weekly";
2022-02-11 04:31:44 +00:00
options = "--delete-older-than 7d";
};
# Run the optimizer.
nix.optimise = {
automatic = true;
dates = [ "weekly" ];
};
# Journal settings for retention.
services.journald.extraConfig = ''
MaxRetentionSec="3 month"
'';
})
(lib.mkIf cfg.autoUpgrade.enable {
system.autoUpgrade = {
enable = true;
flake = "github:foo-dogsquared/nixos-config";
allowReboot = true;
2022-08-20 06:13:54 +00:00
persistent = true;
rebootWindow = {
lower = "22:00";
upper = "00:00";
};
dates = "weekly";
flags = [
2022-11-19 03:05:31 +00:00
"--update-input"
"nixpkgs"
"--commit-lock-file"
"--no-write-lock-file"
];
randomizedDelaySec = "1min";
};
})
2022-07-09 06:04:17 +00:00
# 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 {
2022-01-11 12:22:08 +00:00
environment.systemPackages = with pkgs; [
cfg.wine.package # The star of the show.
bottles # The Windows environment package manager.
2022-01-11 12:22:08 +00:00
];
})
]);
}