nix-dotfiles/modules/desktop/default.nix

69 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop;
in {
options.modules.desktop = {
envProto = mkOption {
type = types.nullOr (types.enum ["x11" "wayland"]);
description = "What display protocol to use";
};
};
config = mkMerge [
{
modules.desktop.fonts.enable = true;
modules.desktop.fonts.baseFonts = true;
# bootloader
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.consoleMode = "auto";
boot.loader.efi.canTouchEfiVariables = true;
# enable networking
networking.networkmanager.enable = true;
# speed up boot
# https://discourse.nixos.org/t/boot-faster-by-disabling-udev-settle-and-nm-wait-online/6339
systemd.services.systemd-udev-settle.enable = false;
systemd.services.NetworkManager-wait-online.enable = false;
# mounting, trash, and mtp support
services.gvfs.enable = true;
# various evironment variables that are needed for everything desktop related
environment.sessionVariables = {
# automatic hidpi for qt apps
QT_AUTO_SCREEN_SCALE_FACTOR = "1";
QT_ENABLE_HIGHDPI_SCALING = "1";
};
}
(mkIf (cfg.envProto == "wayland") {
environment.sessionVariables = {
# magic environment variables that improve wayland compat
NIXOS_OZONE_WL = "1";
_JAVA_AWT_WM_NONEREPARENTING = "1";
GDK_BACKEND = "wayland,x11";
ANKI_WAYLAND = "1";
MOZ_ENABLE_WAYLAND = "1";
ELECTRON_OZONE_PLATFORM_HINT = "wayland";
XDG_SESSION_TYPE = "wayland";
SDL_VIDEODRIVER = "wayland";
CLUTTER_BACKEND = "wayland";
};
hm.home.packages = with pkgs; [
wl-clipboard
wl-clipboard-x11 # compat with xclip
];
})
(mkIf (cfg.envProto == "x11") {
services.xserver.excludePackages = [ pkgs.xterm ];
hm.home.packages = with pkgs; [
xclip
];
})
];
}