nixos/home/sway/nixos.nix

50 lines
1.3 KiB
Nix
Raw Normal View History

2025-01-13 11:52:09 +08:00
{
pkgs,
lib,
config,
...
}:
with lib;
let
2024-01-27 22:14:03 +08:00
gui = with config.global.gpu; enable && session;
nvidia = with config.global.gpu; type == "nvidia" || type == "prime";
2025-01-13 11:52:09 +08:00
in
mkIf gui {
2024-04-19 08:15:03 +08:00
services.displayManager.sessionPackages = [
2025-01-13 11:52:09 +08:00
(
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 ];
}
)
2024-01-04 11:48:30 +08:00
];
programs.light.enable = true;
}