Add NoDM (display session autostart config)

This commit is contained in:
NullBite 2024-03-19 03:30:20 -04:00
parent 0c58a9ea1b
commit 2144789bb2
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A
4 changed files with 35 additions and 10 deletions

View File

@ -2,5 +2,6 @@
{
imports = [
./wm.nix
./nodm.nix
];
}

31
home/common/nodm.nix Normal file
View File

@ -0,0 +1,31 @@
{ lib, pkgs, config, osConfig ? {}, options, ... }:
let
cfg = config.nixfiles.common.nodm;
in
{
config = let
hyprland="${config.wayland.windowManager.hyprland.finalPackage}/bin/Hyprland";
tty="${pkgs.coreutils}/bin/tty";
initCommands =
''
if [[ "$(${tty})" == "/dev/tty1" && -z "''${WAYLAND_DISPLAY:+x}" ]] ; then
${hyprland}
fi
'';
in lib.mkIf cfg.enable {
# auto start Hyprland on tty1
programs.zsh.initExtra = initCommands;
programs.bash.initExtra = initCommands;
};
options.nixfiles.common.nodm = {
enable = lib.mkOption {
type = lib.types.bool;
description = "Whether to automatically start a desktop session on TTY1, behaving like a rudimentary display manager.";
default = osConfig ? systemd
&& config.nixfiles.meta.graphical
&& (!(osConfig.systemd.services.display-manager.enable or false));
example = true;
};
};
}

View File

@ -59,6 +59,9 @@
packageSets.gaming.enable = true;
};
services.xserver.displayManager.sddm.enable = false;
services.xserver.displayManager.startx.enable = true;
# bootloader setup
boot.loader = {
efi = {

View File

@ -10,16 +10,6 @@
};
home.stateVersion = "23.11";
# auto start Hyprland on tty1
programs.zsh.initExtraFirst = let
hyprland="${config.wayland.windowManager.hyprland.finalPackage}/bin/Hyprland";
tty="${pkgs.coreutils}/bin/tty";
in lib.mkIf config.wayland.windowManager.hyprland.enable ''
if [[ "$(${tty})" == "/dev/tty1" && -z "''${WAYLAND_DISPLAY:+x}" ]] ; then
${hyprland}
fi
'';
wayland.windowManager.hyprland.settings = {
monitor = ",preferred,auto,1.25";
};