{ pkgs, lib, config, ... }: with lib; let gui = with config.global.gpu; enable && session; nvidia = with config.global.gpu; type == "nvidia" || type == "prime"; in mkIf gui { services.displayManager.sessionPackages = [ ( pkgs.writeTextFile { name = "sway-session"; destination = "/share/wayland-sessions/sway.desktop"; text = '' [Desktop Entry] Name=Sway Comment=An i3-compatible Wayland compositor Exec=${ pkgs.writeTextFile { name = "sway-wrapper"; executable = true; text = '' #!${pkgs.zsh}/bin/zsh SHLVL=0 for profile in ''${(z)NIX_PROFILES}; do fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions) done exec sway${if nvidia then " --unsupported-gpu" else ""} 2>&1 >> $XDG_CACHE_HOME/sway ''; checkPhase = '' ${pkgs.stdenv.shellDryRun} "$target" ''; } } Type=Application ''; } // { providedSessions = [ pkgs.sway.meta.mainProgram ]; } ) ]; programs.light.enable = true; }