about summary refs log tree commit diff
path: root/modules/workstation/windowing/sway/default.nix
blob: 2b5787c0339a91beee94aae4d0e15bc416baf78e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ pkgs, lib, config, ... }:

let
  inherit (lib) mkOption optionalString;
  inherit (lib.types) lines nullOr path;
  inherit (pkgs) callPackage substituteAll;

  cfg = config.programs.sway;
in

{
  imports = [ ./swayidle ./swaylock ./wlsunset ./xdg-desktop-portal-wlr ];

  options = {
    programs.sway.extraConfig = mkOption {
      type = lines;
      description = "Lines to append to sway's config file";
      default = "";
    };

    programs.sway.wallpaper = mkOption {
      type = nullOr path;
      description = "Path to wallpaper for sway and swaylock";
      default = null;
    };
  };

  config = {
    environment.systemPackages = with pkgs; [ bemenu choose swayidle ];

    programs.sway.enable = true;
    programs.sway.wallpaper = callPackage ./wallpaper.nix { };
    programs.sway.extraPackages = []; # extra packages can go in systemPackages.

    programs.swayidle.enable = true;

    users.users.qyliss.xdg.config.paths."sway/config" = substituteAll {
      src = ./config.in;
      choose_workspace =
        "${callPackage ./choose_workspace.nix { }}/bin/choose_workspace";
      status_command = "${callPackage ./status.nix { }}/bin/status";
      extraConfig = cfg.extraConfig + optionalString (cfg.wallpaper != null) ''
        output * bg ${cfg.wallpaper} fill
      '';
    };

    xdg.portal.extraPortals = with pkgs; [ xdg-desktop-portal-gtk ];
  };
}