summary refs log tree commit diff
path: root/nixos/modules/services/x11/desktop-managers/phosh.nix
blob: e768f6f4c6312c4e7a7f9d37576160ba1a12f449 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.xserver.desktopManager.phosh;
in

{
  options = {
    services.xserver.desktopManager.phosh = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Enable the Phone Shell.";
      };

      package = mkOption {
        type = types.package;
        default = pkgs.phosh;
        defaultText = literalExpression "pkgs.phosh";
        example = literalExpression "pkgs.phosh";
        description = ''
          Package that should be used for Phosh.
        '';
      };

      user = mkOption {
        description = "The user to run the Phosh service.";
        type = types.str;
        example = "alice";
      };

      group = mkOption {
        description = "The group to run the Phosh service.";
        type = types.str;
        example = "users";
      };
    };
  };

  config = mkIf cfg.enable {
    programs.phosh.enable = true;

    systemd.defaultUnit = "graphical.target";
    # Inspired by https://gitlab.gnome.org/World/Phosh/phosh/-/blob/main/data/phosh.service
    systemd.services.phosh = {
      wantedBy = [ "graphical.target" ];
      serviceConfig = {
        ExecStart = "${cfg.package}/bin/phosh";
        User = cfg.user;
        Group = cfg.group;
        PAMName = "login";
        WorkingDirectory = "~";
        Restart = "always";

        TTYPath = "/dev/tty7";
        TTYReset = "yes";
        TTYVHangup = "yes";
        TTYVTDisallocate = "yes";

        # Fail to start if not controlling the tty.
        StandardInput = "tty-fail";
        StandardOutput = "journal";
        StandardError = "journal";

        # Log this user with utmp, letting it show up with commands 'w' and 'who'.
        UtmpIdentifier = "tty7";
        UtmpMode = "user";
      };
    };
  };
}