summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/wayland/pinnacle.nix
blob: 2b341136c58357dc55a58f19892235c124af644d (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  pkgs,
  config,
  lib,
  ...
}:
let
  cfg = config.programs.pinnacle;
  inherit (lib.options) mkEnableOption mkPackageOption;
in
{
  options.programs.pinnacle = {
    enable = mkEnableOption "pinnacle";
    package = mkPackageOption pkgs "pinnacle" {
      default = "pinnacle";
      example = "pkgs.pinnacle";
      extraDescription = "package containing the pinnacle server binary";
    };
    xdg-portals.enable = mkEnableOption "enable xdg-portals for pinnacle";
    withUWSM = mkEnableOption ''
      manage the pinnacle session with [UWSM](https://github.com/Vladimir-csp/uwsm) instead
      of independent systemd services and targets.
    '';
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        environment.systemPackages = [
          cfg.package
          pkgs.protobuf
          cfg.package.lua-client-api
        ];
        environment.pathsToLink = [
          # For /run/current-system/sw/share/pinnacle protobuf files - for
          # pinnacle to be able to launch with a non-default config out of the
          # box.
          "/share/pinnacle"
        ];
        xdg.portal = lib.mkIf cfg.xdg-portals.enable {
          enable = true;
          wlr.enable = true;
          configPackages = [ cfg.package ];
          extraPortals = [
            pkgs.xdg-desktop-portal-wlr
            pkgs.xdg-desktop-portal-gtk
            pkgs.gnome-keyring
          ];
        };
      }
      (lib.mkIf (cfg.withUWSM) {
        programs.uwsm.enable = true;
        # Configure UWSM to launch Pinnacle from a display manager like SDDM
        programs.uwsm.waylandCompositors = {
          pinnacle = {
            prettyName = "Pinnacle";
            comment = "Pinnacle compositor managed by UWSM";
            binPath = "/run/current-system/sw/bin/pinnacle";
            extraArgs = [ "--session" ];
          };
        };
      })
      (lib.mkIf (!cfg.withUWSM) {
        services.displayManager.sessionPackages = [ cfg.package ];
      })
    ]
  );

  meta.maintainers = with lib.maintainers; [ cassandracomar ];
}