fix: add option to not install package for sway / swaylock

avoid problems with nix on Debian
This commit is contained in:
Yorick Barbanneau 2024-06-19 01:03:52 +02:00
parent ce7338040e
commit dea3740249
4 changed files with 42 additions and 6 deletions

View file

@ -7,6 +7,12 @@ in
options.modules.desktop.sway = {
enable = mkEnableOption "enable Sway Windows Manager";
installPackage = mkOption {
type = types.bool;
default = true;
description = "install Package, if false relies on distribution packages";
};
kanshi = mkOption {
type = types.bool;
default = false;

View file

@ -7,6 +7,14 @@ in
config = mkIf config.modules.desktop.sway.enable {
wayland.windowManager.sway = {
enable = true;
# Do not install sway package on other system that NixOS
# because performance issue
package =
if cfg.installPackage
then pkgs.sway
else null;
wrapperFeatures.gtk = true;
systemd.enable = true;
config = {
@ -61,7 +69,10 @@ in
"${mod}+Shift+q" = "kill";
"${mod}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel";
"${mod}+Shift+c" = "reload";
"${mod}+Alt+l" = "exec ${pkgs.swaylock}/bin/swaylock";
"${mod}+Alt+l" =
if cfg.installPackage
then "exec ${pkgs.swaylock}/bin/swaylock"
else "exec swaylock";
"${mod}+${left} focus" = "left";
"${mod}+${down} focus" = "down";
"${mod}+${up} focus" = "up";

View file

@ -1,5 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop.sway;
in
{
config = mkIf config.modules.desktop.sway.enable {
services.swayidle = {
@ -7,22 +10,34 @@ with lib;
timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock -f";
command =
if cfg.installPackage
then "${pkgs.swaylock}/bin/swaylock -f"
else "swaylock -f";
}
{
timeout = 600;
command = ''${pkgs.sway}/bin/swaymsg "output * power off"'';
resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * power on"'';
resumeCommand =
if cfg.installPackage
then ''${pkgs.sway}/bin/swaymsg "output * power on"''
else ''swaymsg "output * power on"'';
}
];
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f";
command =
if cfg.installPackage
then "${pkgs.swaylock}/bin/swaylock -f"
else "swaylock -f";
}
{
event = "lock";
command = "${pkgs.swaylock}/bin/swaylock -f";
command =
if cfg.installPackage
then "${pkgs.swaylock}/bin/swaylock -f"
else "swaylock -f";
}
];
};

View file

@ -1,4 +1,4 @@
{ config, lib, ... }:
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop.sway;
@ -7,6 +7,10 @@ in
config = mkIf config.modules.desktop.sway.enable {
programs.swaylock = {
enable = true;
package =
if cfg.installPackage
then pkgs.swaylock
else pkgs.emptyDirectory;
settings = {
image = "${cfg.wallpapers.lockscreen}";
scaling = "center";