Setup roles as modules and switch to sway

This commit is contained in:
2024-09-08 13:49:28 -07:00
parent f22ff0e286
commit 692cebc839
14 changed files with 307 additions and 471 deletions

View File

@@ -1,47 +1,62 @@
{ autologin ? false, wayland ? false, lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
with lib;
let
kodiBasePkg = if wayland then pkgs.kodi-wayland else pkgs.kodi;
kodiPkg = kodiBasePkg.withPackages (pkgs: with pkgs; [
jellyfin
steam-launcher
steam-library
youtube
]);
cfg = config.roles.kodi;
in
{
users.extraUsers.kodi.isNormalUser = true;
networking.firewall = {
allowedTCPPorts = [ 8080 ];
allowedUDPPorts = [ 8080 ];
options.roles.kodi = {
enable = mkEnableOption "Enable Kodi";
autologin = mkOption {
default = false;
};
wayland = mkOption {
default = true;
};
};
services = mkIf autologin {
cage = mkIf wayland {
user = "kodi";
program = "${kodiPkg}/bin/kodi-standalone";
enable = true;
config = let
kodiBasePkg = if cfg.wayland then pkgs.kodi-wayland else pkgs.kodi;
kodiPkg = kodiBasePkg.withPackages (pkgs: with pkgs; [
jellyfin
steam-launcher
steam-library
youtube
]);
in {
users.extraUsers.kodi.isNormalUser = true;
networking.firewall = {
allowedTCPPorts = [ 8080 ];
allowedUDPPorts = [ 8080 ];
};
xserver = mkIf (!wayland) {
enable = true;
desktopManager.kodi = {
services = mkIf cfg.autologin {
cage = mkIf cfg.wayland {
user = "kodi";
program = "${kodiPkg}/bin/kodi-standalone";
enable = true;
package = kodiPkg;
};
displayManager.lightdm = {
xserver = mkIf (!cfg.wayland) {
enable = true;
greeter.enable = false;
desktopManager.kodi = {
enable = true;
package = kodiPkg;
};
displayManager.lightdm = {
enable = true;
greeter.enable = false;
};
};
displayManager = mkIf (!cfg.wayland) {
autoLogin.enable = true;
autoLogin.user = "kodi";
defaultSession = "kodi";
sessionData.autologinSession = "kodi";
};
};
displayManager = mkIf (!wayland) {
autoLogin.enable = true;
autoLogin.user = "kodi";
defaultSession = "kodi";
sessionData.autologinSession = "kodi";
};
};
}